From 77773599e7cde203dce6fccab29164feaa78049d Mon Sep 17 00:00:00 2001 From: astraone-ssp <57891367+astraone-ssp@users.noreply.github.com> Date: Thu, 5 Dec 2019 11:08:49 +0300 Subject: [PATCH 01/41] Added AstraOne adapter (#4475) * Added AstraOne adapter * Fixed an argument in function createRenderer * Added unit tests. Added example with GPT in the documentation. Removed bid renderer. * Fixed a small typo --- modules/astraoneBidAdapter.js | 140 +++++++++++++ modules/astraoneBidAdapter.md | 198 +++++++++++++++++ test/spec/modules/astraoneBidAdapter_spec.js | 210 +++++++++++++++++++ 3 files changed, 548 insertions(+) create mode 100644 modules/astraoneBidAdapter.js create mode 100644 modules/astraoneBidAdapter.md create mode 100644 test/spec/modules/astraoneBidAdapter_spec.js diff --git a/modules/astraoneBidAdapter.js b/modules/astraoneBidAdapter.js new file mode 100644 index 000000000000..efff699b0dc3 --- /dev/null +++ b/modules/astraoneBidAdapter.js @@ -0,0 +1,140 @@ +import * as utils from '../src/utils' +import { registerBidder } from '../src/adapters/bidderFactory' +import { BANNER } from '../src/mediaTypes' + +const BIDDER_CODE = 'astraone'; +const SSP_ENDPOINT = 'https://ssp.astraone.io/auction/prebid'; +const TTL = 60; + +function buildBidRequests(validBidRequests) { + return utils._map(validBidRequests, function(validBidRequest) { + const params = validBidRequest.params; + const bidRequest = { + bidId: validBidRequest.bidId, + transactionId: validBidRequest.transactionId, + sizes: validBidRequest.sizes, + placement: params.placement, + placeId: params.placeId, + imageUrl: params.imageUrl + }; + + return bidRequest; + }) +} + +function buildBid(bidData) { + const bid = { + requestId: bidData.bidId, + cpm: bidData.price, + width: bidData.width, + height: bidData.height, + creativeId: bidData.content.seanceId, + currency: bidData.currency, + netRevenue: true, + mediaType: BANNER, + ttl: TTL, + content: bidData.content + }; + + bid.ad = wrapAd(bid, bidData); + + return bid; +} + +function getMediaTypeFromBid(bid) { + return bid.mediaTypes && Object.keys(bid.mediaTypes)[0] +} + +function wrapAd(bid, bidData) { + return ` + + + + + + + + +
+ + + `; +} + +export const spec = { + code: BIDDER_CODE, + supportedMediaTypes: [BANNER], + + /** + * Determines whether or not the given bid request is valid. + * + * @param {BidRequest} bid The bid params to validate. + * @return boolean True if this is a valid bid, and false otherwise. + */ + isBidRequestValid(bid) { + return ( + getMediaTypeFromBid(bid) === BANNER && + !!bid.params.placeId && + !!bid.params.imageUrl && + !!bid.params.placement && + (bid.params.placement === 'inImage') + ); + }, + + /** + * Make a server request from the list of BidRequests. + * + * @param {validBidRequests[]} - an array of bids + * @return ServerRequest Info describing the request to the server. + */ + buildRequests(validBidRequests, bidderRequest) { + const payload = { + url: bidderRequest.refererInfo.referer, + cmp: !!bidderRequest.gdprConsent, + bidRequests: buildBidRequests(validBidRequests) + }; + + if (payload.cmp) { + const gdprApplies = bidderRequest.gdprConsent.gdprApplies; + if (gdprApplies !== undefined) payload['ga'] = gdprApplies; + payload['cs'] = bidderRequest.gdprConsent.consentString; + } + + const payloadString = JSON.stringify(payload); + return { + method: 'POST', + url: SSP_ENDPOINT, + data: payloadString, + options: { + contentType: 'application/json' + } + } + }, + + /** + * Unpack the response from the server into a list of bids. + * + * @param {ServerResponse} serverResponse A successful response from the server. + * @return {Bid[]} An array of bids which were nested inside the server. + */ + interpretResponse: function(serverResponse) { + const serverBody = serverResponse.body; + if (serverBody && utils.isArray(serverBody)) { + return utils._map(serverBody, function(bid) { + return buildBid(bid); + }); + } else { + return []; + } + } + +} +registerBidder(spec); diff --git a/modules/astraoneBidAdapter.md b/modules/astraoneBidAdapter.md new file mode 100644 index 000000000000..0c7b79489a5c --- /dev/null +++ b/modules/astraoneBidAdapter.md @@ -0,0 +1,198 @@ +# Overview + + +**Module Name**: AstraOne Bidder Adapter +**Module Type**: Bidder Adapter +**Maintainer**: prebid@astraone.io + +# Description + +You can use this adapter to get a bid from AstraOne. +Please reach out to your AstraOne account team before using this plugin to get placeId. +The code below returns a demo ad. + +About us: https://astraone.io + +# Test Parameters +```js +var adUnits = [{ + code: 'test-div', + mediaTypes: { + banner: { + sizes: [], + } + }, + bids: [{ + bidder: "astraone", + params: { + placement: "inImage", + placeId: "5af45ad34d506ee7acad0c26", + imageUrl: "https://creative.astraone.io/files/default_image-1-600x400.jpg" + } + }] +}]; +``` + +# Example page + +```html + + + + + Prebid.js Banner Example + + + + + + +

Prebid.js InImage Banner Test

+ +
+ + +
+ + + +``` +# Example page with GPT + +```html + + + + + Prebid.js Banner Example + + + + + + +

Prebid.js Banner Ad Unit Test

+ +
+ + + +
+ + +``` diff --git a/test/spec/modules/astraoneBidAdapter_spec.js b/test/spec/modules/astraoneBidAdapter_spec.js new file mode 100644 index 000000000000..cd80e742b7d2 --- /dev/null +++ b/test/spec/modules/astraoneBidAdapter_spec.js @@ -0,0 +1,210 @@ +import { expect } from 'chai' +import { spec } from 'modules/astraoneBidAdapter' + +function getSlotConfigs(mediaTypes, params) { + return { + params: params, + sizes: [], + bidId: '2df8c0733f284e', + bidder: 'astraone', + mediaTypes: mediaTypes, + transactionId: '31a58515-3634-4e90-9c96-f86196db1459' + } +} + +describe('AstraOne Adapter', function() { + describe('isBidRequestValid method', function() { + const PLACE_ID = '5af45ad34d506ee7acad0c26'; + const IMAGE_URL = 'https://creative.astraone.io/files/default_image-1-600x400.jpg'; + + describe('returns true', function() { + describe('when banner slot config has all mandatory params', () => { + describe('and placement has the correct value', function() { + const createBannerSlotConfig = placement => { + return getSlotConfigs( + { banner: {} }, + { + placeId: PLACE_ID, + imageUrl: IMAGE_URL, + placement + } + ) + } + const placements = ['inImage']; + placements.forEach(placement => { + it('should be ' + placement, function() { + const isBidRequestValid = spec.isBidRequestValid( + createBannerSlotConfig(placement) + ) + expect(isBidRequestValid).to.equal(true) + }) + }) + }) + }) + }) + describe('returns false', function() { + describe('when params are not correct', function() { + function createSlotconfig(params) { + return getSlotConfigs({ banner: {} }, params) + } + it('does not have the placeId.', function() { + const isBidRequestValid = spec.isBidRequestValid( + createSlotconfig({ + imageUrl: IMAGE_URL, + placement: 'inImage' + }) + ) + expect(isBidRequestValid).to.equal(false) + }) + it('does not have the imageUrl.', function() { + const isBidRequestValid = spec.isBidRequestValid( + createSlotconfig({ + placeId: PLACE_ID, + placement: 'inImage' + }) + ) + expect(isBidRequestValid).to.equal(false) + }) + it('does not have the placement.', function() { + const isBidRequestValid = spec.isBidRequestValid( + createSlotconfig({ + placeId: PLACE_ID, + imageUrl: IMAGE_URL, + }) + ) + expect(isBidRequestValid).to.equal(false) + }) + it('does not have a the correct placement.', function() { + const isBidRequestValid = spec.isBidRequestValid( + createSlotconfig({ + placeId: PLACE_ID, + imageUrl: IMAGE_URL, + placement: 'something' + }) + ) + expect(isBidRequestValid).to.equal(false) + }) + }) + }) + }) + + describe('buildRequests method', function() { + const bidderRequest = { + refererInfo: { referer: 'referer' } + } + const mandatoryParams = { + placeId: '5af45ad34d506ee7acad0c26', + imageUrl: 'https://creative.astraone.io/files/default_image-1-600x400.jpg', + placement: 'inImage' + } + const validBidRequests = [ + getSlotConfigs({ banner: {} }, mandatoryParams) + ] + it('Url params should be correct ', function() { + const request = spec.buildRequests(validBidRequests, bidderRequest) + expect(request.method).to.equal('POST') + expect(request.url).to.equal('https://ssp.astraone.io/auction/prebid') + }) + + it('Common data request should be correct', function() { + const request = spec.buildRequests(validBidRequests, bidderRequest) + const data = JSON.parse(request.data) + expect(Array.isArray(data.bidRequests)).to.equal(true) + data.bidRequests.forEach(bid => { + expect(bid.placeId).to.equal('5af45ad34d506ee7acad0c26') + expect(typeof bid.imageUrl).to.equal('string') + }) + }) + + describe('GDPR params', function() { + describe('when there are not consent management platform', function() { + it('cmp should be false', function() { + const request = spec.buildRequests(validBidRequests, bidderRequest) + const data = JSON.parse(request.data) + expect(data.cmp).to.equal(false) + }) + }) + describe('when there are consent management platform', function() { + it('cmps should be true and ga should not sended, when gdprApplies is undefined', function() { + bidderRequest['gdprConsent'] = { + gdprApplies: undefined, + consentString: 'consentString' + } + const request = spec.buildRequests(validBidRequests, bidderRequest) + const data = JSON.parse(request.data) + expect(data.cmp).to.equal(true) + expect(Object.keys(data).indexOf('data')).to.equal(-1) + expect(data.cs).to.equal('consentString') + }) + it('cmps should be true and all gdpr parameters should be sended, when there are gdprApplies', function() { + bidderRequest['gdprConsent'] = { + gdprApplies: true, + consentString: 'consentString' + } + const request = spec.buildRequests(validBidRequests, bidderRequest) + const data = JSON.parse(request.data) + expect(data.cmp).to.equal(true) + expect(data.ga).to.equal(true) + expect(data.cs).to.equal('consentString') + }) + }) + }) + + describe('BidRequests params', function() { + const request = spec.buildRequests(validBidRequests, bidderRequest) + const data = JSON.parse(request.data) + const bidRequests = data.bidRequests + it('should request a Banner', function() { + const bannerBid = bidRequests[0] + expect(bannerBid.bidId).to.equal('2df8c0733f284e') + expect(bannerBid.transactionId).to.equal('31a58515-3634-4e90-9c96-f86196db1459') + expect(bannerBid.placeId).to.equal('5af45ad34d506ee7acad0c26') + }) + }) + }) + + describe('interpret response method', function() { + it('should return a void array, when the server response have not got bids.', function() { + const serverResponse = { + body: [] + } + const bids = spec.interpretResponse(serverResponse) + expect(Array.isArray(bids)).to.equal(true) + expect(bids.length).to.equal(0) + }) + describe('when the server response return a bid', function() { + describe('the bid is a banner', function() { + it('should return a banner bid', function() { + const serverResponse = { + body: [ + { + bidId: '2df8c0733f284e', + price: 0.5, + currency: 'USD', + content: { + content: 'html', + actionUrls: {}, + seanceId: '123123' + }, + width: 100, + height: 100, + ttl: 360 + } + ] + } + const bids = spec.interpretResponse(serverResponse) + expect(bids.length).to.equal(1) + expect(bids[0].requestId).to.equal('2df8c0733f284e') + expect(bids[0].creativeId).to.equal('123123') + expect(bids[0].cpm).to.equal(0.5) + expect(bids[0].width).to.equal(100) + expect(bids[0].height).to.equal(100) + expect(bids[0].currency).to.equal('USD') + expect(bids[0].netRevenue).to.equal(true) + expect(typeof bids[0].ad).to.equal('string') + expect(typeof bids[0].content).to.equal('object') + }) + }) + }) + }) +}) From 8e12e5f436c6530ca620a616a76a2393aebf63ba Mon Sep 17 00:00:00 2001 From: Harshad Mane Date: Fri, 6 Dec 2019 09:42:26 -0800 Subject: [PATCH 02/41] PubMatic bid adapter to support CCPA/USP (#4533) * added support for pubcommon, digitrust, id5id * added support for IdentityLink * changed the source for id5 * added unit test cases * changed source param for identityLink * added CCPA/USP support in PubMatic adapter --- modules/pubmaticBidAdapter.js | 12 +- test/spec/modules/pubmaticBidAdapter_spec.js | 109 +++++++++++++++++++ 2 files changed, 120 insertions(+), 1 deletion(-) diff --git a/modules/pubmaticBidAdapter.js b/modules/pubmaticBidAdapter.js index 34beb4d8745b..4281c4a449e3 100644 --- a/modules/pubmaticBidAdapter.js +++ b/modules/pubmaticBidAdapter.js @@ -917,6 +917,11 @@ export const spec = { }; } + // CCPA + if (bidderRequest && bidderRequest.uspConsent) { + utils.deepSetValue(payload, 'regs.ext.us_privacy', bidderRequest.uspConsent); + } + // coppa compliance if (config.getConfig('coppa') === true) { utils.deepSetValue(payload, 'regs.coppa', 1); @@ -1012,7 +1017,7 @@ export const spec = { /** * Register User Sync. */ - getUserSyncs: (syncOptions, responses, gdprConsent) => { + getUserSyncs: (syncOptions, responses, gdprConsent, uspConsent) => { let syncurl = USYNCURL + publisherId; // Attaching GDPR Consent Params in UserSync url @@ -1021,6 +1026,11 @@ export const spec = { syncurl += '&gdpr_consent=' + encodeURIComponent(gdprConsent.consentString || ''); } + // CCPA + if (uspConsent) { + syncurl += '&us_privacy=' + encodeURIComponent(uspConsent); + } + // coppa compliance if (config.getConfig('coppa') === true) { syncurl += '&coppa=1'; diff --git a/test/spec/modules/pubmaticBidAdapter_spec.js b/test/spec/modules/pubmaticBidAdapter_spec.js index b2c2da99d233..764897b596b2 100644 --- a/test/spec/modules/pubmaticBidAdapter_spec.js +++ b/test/spec/modules/pubmaticBidAdapter_spec.js @@ -982,6 +982,43 @@ 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 params check with USP/CCPA Consent', function () { + let bidRequest = { + uspConsent: '1NYN' + }; + let request = spec.buildRequests(bidRequests, bidRequest); + let data = JSON.parse(request.data); + expect(data.regs.ext.us_privacy).to.equal('1NYN');// USP/CCPAs + 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 + expect(data.site.page).to.equal(bidRequests[0].params.kadpageurl); // forced pageURL + expect(data.site.publisher.id).to.equal(bidRequests[0].params.publisherId); // publisher Id + expect(data.user.yob).to.equal(parseInt(bidRequests[0].params.yob)); // YOB + expect(data.user.gender).to.equal(bidRequests[0].params.gender); // Gender + expect(data.device.geo.lat).to.equal(parseFloat(bidRequests[0].params.lat)); // Latitude + expect(data.device.geo.lon).to.equal(parseFloat(bidRequests[0].params.lon)); // Lognitude + expect(data.user.geo.lat).to.equal(parseFloat(bidRequests[0].params.lat)); // Latitude + expect(data.user.geo.lon).to.equal(parseFloat(bidRequests[0].params.lon)); // Lognitude + expect(data.ext.wrapper.wv).to.equal($$REPO_AND_VERSION$$); // Wrapper Version + expect(data.ext.wrapper.transactionId).to.equal(bidRequests[0].transactionId); // Prebid TransactionId + expect(data.ext.wrapper.wiid).to.equal(bidRequests[0].params.wiid); // OpenWrap: Wrapper Impression ID + expect(data.ext.wrapper.profile).to.equal(parseInt(bidRequests[0].params.profId)); // OpenWrap: Wrapper Profile ID + expect(data.ext.wrapper.version).to.equal(parseInt(bidRequests[0].params.verId)); // OpenWrap: Wrapper Profile Version ID + + expect(data.imp[0].id).to.equal(bidRequests[0].bidId); // Prebid bid id is passed as id + expect(data.imp[0].bidfloor).to.equal(parseFloat(bidRequests[0].params.kadfloor)); // kadfloor + expect(data.imp[0].tagid).to.equal('/15671365/DMDemo'); // tagid + expect(data.imp[0].banner.w).to.equal(300); // width + expect(data.imp[0].banner.h).to.equal(250); // height + expect(data.imp[0].ext.pmZoneId).to.equal(bidRequests[0].params.pmzoneid.split(',').slice(0, 50).map(id => id.trim()).join()); // pmzoneid + + // second request without USP/CCPA + let request2 = spec.buildRequests(bidRequests, {}); + let data2 = JSON.parse(request2.data); + expect(data2.regs).to.equal(undefined);// USP/CCPAs + }); + it('Request should have digitrust params', function() { window.DigiTrust = { getUser: function () { @@ -2444,5 +2481,77 @@ describe('PubMatic adapter', function () { expect(response[0].mediaType).to.equal('native'); }); }); + + describe('getUserSyncs', function() { + const syncurl = 'https://ads.pubmatic.com/AdServer/js/showad.js#PIX&kdntuid=1&p=5670'; + let sandbox; + beforeEach(function () { + sandbox = sinon.sandbox.create(); + }); + afterEach(function() { + sandbox.restore(); + }) + + it('execute only if iframeEnabled', function() { + expect(spec.getUserSyncs({ iframeEnabled: true }, {}, undefined, undefined)).to.deep.equal([{ + type: 'iframe', url: syncurl + }]); + expect(spec.getUserSyncs({ iframeEnabled: false }, {}, undefined, undefined)).to.equal(undefined); + }); + + it('CCPA/USP', function() { + expect(spec.getUserSyncs({ iframeEnabled: true }, {}, undefined, '1NYN')).to.deep.equal([{ + type: 'iframe', url: `${syncurl}&us_privacy=1NYN` + }]); + }); + + it('GDPR', function() { + expect(spec.getUserSyncs({ iframeEnabled: true }, {}, {gdprApplies: true, consentString: 'foo'}, undefined)).to.deep.equal([{ + type: 'iframe', url: `${syncurl}&gdpr=1&gdpr_consent=foo` + }]); + expect(spec.getUserSyncs({ iframeEnabled: true }, {}, {gdprApplies: false, consentString: 'foo'}, undefined)).to.deep.equal([{ + type: 'iframe', url: `${syncurl}&gdpr=0&gdpr_consent=foo` + }]); + expect(spec.getUserSyncs({ iframeEnabled: true }, {}, {gdprApplies: true, consentString: undefined}, undefined)).to.deep.equal([{ + type: 'iframe', url: `${syncurl}&gdpr=1&gdpr_consent=` + }]); + }); + + it('COPPA: true', function() { + sandbox.stub(config, 'getConfig').callsFake(key => { + const config = { + 'coppa': true + }; + return config[key]; + }); + expect(spec.getUserSyncs({ iframeEnabled: true }, {}, undefined, undefined)).to.deep.equal([{ + type: 'iframe', url: `${syncurl}&coppa=1` + }]); + }); + + it('COPPA: false', function() { + sandbox.stub(config, 'getConfig').callsFake(key => { + const config = { + 'coppa': false + }; + return config[key]; + }); + expect(spec.getUserSyncs({ iframeEnabled: true }, {}, undefined, undefined)).to.deep.equal([{ + type: 'iframe', url: `${syncurl}` + }]); + }); + + it('GDPR + COPPA:true + CCPA/USP', function() { + sandbox.stub(config, 'getConfig').callsFake(key => { + const config = { + 'coppa': true + }; + return config[key]; + }); + expect(spec.getUserSyncs({ iframeEnabled: true }, {}, {gdprApplies: true, consentString: 'foo'}, '1NYN')).to.deep.equal([{ + type: 'iframe', url: `${syncurl}&gdpr=1&gdpr_consent=foo&us_privacy=1NYN&coppa=1` + }]); + }); + }); }); }); From c037292303f255d9d181f0a07975c30f18a12f96 Mon Sep 17 00:00:00 2001 From: adxcgcom <31470944+adxcgcom@users.noreply.github.com> Date: Mon, 9 Dec 2019 15:19:32 +0000 Subject: [PATCH 03/41] Update adxcgBidAdapter.js - native fix (#4534) * Update adxcgBidAdapter.js - native fix * trigger CI * trigger CI * Code reformat and adding ending semicolons. No other changes Reformatted the code in separate commit before real changes * update adxcgBidAdapter_spec general cleanup - removed duplicated jsons added native size check added many url querystring http call parameter checks * trigger CI --- modules/adxcgBidAdapter.js | 10 +- test/spec/modules/adxcgBidAdapter_spec.js | 883 ++++++++++++---------- 2 files changed, 484 insertions(+), 409 deletions(-) diff --git a/modules/adxcgBidAdapter.js b/modules/adxcgBidAdapter.js index f9cdeda536ab..5e460217e8a1 100644 --- a/modules/adxcgBidAdapter.js +++ b/modules/adxcgBidAdapter.js @@ -12,7 +12,7 @@ import includes from 'core-js/library/fn/array/includes' * updated to pass aditional auction and impression level parameters. added pass for video targeting parameters * updated to fix native support for image width/height and icon 2019.03.17 * updated support for userid - pubcid,ttid 2019.05.28 - * updated to support prebid 3.0 -remove non https, move to banner.xx.sizes, remove utils.getTopWindowLocation,remove utils.getTopWindowUrl(),remove utils.getTopWindowReferrer() + * updated to support prebid 3.0 - remove non https, move to banner.xx.sizes, remove utils.getTopWindowLocation,remove utils.getTopWindowUrl(),remove utils.getTopWindowReferrer() */ const BIDDER_CODE = 'adxcg' @@ -131,6 +131,10 @@ export const spec = { sizes.push(utils.parseSizesInput(bid.mediaTypes.banner.sizes).join('|')) } + if (isNativeRequest(bid)) { + sizes.push('0x0') + } + let bidfloor = utils.getBidIdParameter('bidfloor', bid.params) || 0 bidfloors.push(bidfloor) // copy video params @@ -293,4 +297,8 @@ function isBannerRequest (bid) { return bid.mediaType === 'banner' || !!utils.deepAccess(bid, 'mediaTypes.banner') } +function isNativeRequest (bid) { + return bid.mediaType === 'native' || !!utils.deepAccess(bid, 'mediaTypes.native') +} + registerBidder(spec) diff --git a/test/spec/modules/adxcgBidAdapter_spec.js b/test/spec/modules/adxcgBidAdapter_spec.js index 8daad7a9f865..3e73479259c7 100644 --- a/test/spec/modules/adxcgBidAdapter_spec.js +++ b/test/spec/modules/adxcgBidAdapter_spec.js @@ -1,482 +1,549 @@ -import { expect } from 'chai' -import * as url from 'src/url' -import { spec } from 'modules/adxcgBidAdapter' +import {expect} from 'chai'; +import * as url from 'src/url'; +import {spec} from 'modules/adxcgBidAdapter'; +import {deepClone} from '../../../src/utils'; describe('AdxcgAdapter', function () { - describe('isBidRequestValid', function () { - let bidBanner = { - 'bidder': 'adxcg', - 'params': { - 'adzoneid': '1' - }, - 'adUnitCode': 'adunit-code', - 'mediaTypes': { - 'banner': { - 'sizes': [[300, 250], [640, 360], [1, 1]] - } - }, - 'bidId': '84ab500420319d', - 'bidderRequestId': '7101db09af0db2', - 'auctionId': '1d1a030790a475', - } - - let bidVideo = { - 'bidder': 'adxcg', - 'params': { - 'adzoneid': '1', - 'api': [2], - 'protocols': [1, 2], - 'mimes': ['video/mp4', 'video/x-flv'], - 'maxduration': 30 - }, - 'mediaTypes': { - 'video': { - 'context': 'instream', - 'playerSize': [[640, 480]] + let bidBanner = { + bidder: 'adxcg', + params: { + adzoneid: '1' + }, + adUnitCode: 'adunit-code', + mediaTypes: { + banner: { + sizes: [ + [300, 250], + [640, 360], + [1, 1] + ] + } + }, + bidId: '84ab500420319d', + bidderRequestId: '7101db09af0db2', + auctionId: '1d1a030790a475' + }; + + let bidVideo = { + bidder: 'adxcg', + params: { + adzoneid: '20', + video: { + api: [2], + protocols: [1, 2], + mimes: ['video/mp4'], + maxduration: 30 + } + }, + mediaTypes: { + video: { + context: 'instream', + playerSize: [[640, 480]] + } + }, + adUnitCode: 'adunit-code', + bidId: '84ab500420319d', + bidderRequestId: '7101db09af0db2', + auctionId: '1d1a030790a475' + }; + + let bidNative = { + bidder: 'adxcg', + params: { + adzoneid: '2379' + }, + mediaTypes: { + native: { + image: { + sendId: false, + required: true, + sizes: [80, 80] + }, + title: { + required: true, + len: 75 + }, + body: { + required: true, + len: 200 + }, + sponsoredBy: { + required: false, + len: 20 } - }, - 'adUnitCode': 'adunit-code', - 'bidId': '84ab500420319d', - 'bidderRequestId': '7101db09af0db2', - 'auctionId': '1d1a030790a475', - } + } + }, + adUnitCode: 'adunit-code', + bidId: '84ab500420319d', + bidderRequestId: '7101db09af0db2', + auctionId: '1d1a030790a475' + }; + + describe('isBidRequestValid', function () { + it('should return true when required params found bidNative', function () { + expect(spec.isBidRequestValid(bidNative)).to.equal(true); + }); - it('should return true when required params found', function () { - expect(spec.isBidRequestValid(bidBanner)).to.equal(true) - }) + it('should return true when required params found bidVideo', function () { + expect(spec.isBidRequestValid(bidVideo)).to.equal(true); + }); + + it('should return true when required params found bidBanner', function () { + expect(spec.isBidRequestValid(bidBanner)).to.equal(true); + }); it('should return true when required params not found', function () { - expect(spec.isBidRequestValid({})).to.be.false - }) + expect(spec.isBidRequestValid({})).to.be.false; + }); it('should return false when required params are not passed', function () { - let bid = Object.assign({}, bidBanner) - delete bid.params - bid.params = {} - expect(spec.isBidRequestValid(bid)).to.equal(false) - }) + let bid = Object.assign({}, bidBanner); + delete bid.params; + bid.params = {}; + expect(spec.isBidRequestValid(bid)).to.equal(false); + }); it('should return true when required video params not found', function () { - const simpleVideo = JSON.parse(JSON.stringify(bidVideo)) - simpleVideo.params.adzoneid = 123 - expect(spec.isBidRequestValid(simpleVideo)).to.be.false - simpleVideo.params.mimes = [1, 2, 3] - expect(spec.isBidRequestValid(simpleVideo)).to.be.false - simpleVideo.params.mimes = 'bad type' - expect(spec.isBidRequestValid(simpleVideo)).to.be.false - }) - }) + const simpleVideo = JSON.parse(JSON.stringify(bidVideo)); + simpleVideo.params.adzoneid = 123; + expect(spec.isBidRequestValid(simpleVideo)).to.be.false; + simpleVideo.params.mimes = [1, 2, 3]; + expect(spec.isBidRequestValid(simpleVideo)).to.be.false; + simpleVideo.params.mimes = 'bad type'; + expect(spec.isBidRequestValid(simpleVideo)).to.be.false; + }); + }); describe('request function http', function () { - let bid = { - 'bidder': 'adxcg', - 'params': { - 'adzoneid': '1' - }, - 'adUnitCode': 'adunit-code', - 'mediaTypes': { - 'banner': { - 'sizes': [[300, 250], [640, 360], [1, 1]] - } - }, - 'bidId': '84ab500420319d', - 'bidderRequestId': '7101db09af0db2', - 'auctionId': '1d1a030790a475', - } - - it('creates a valid adxcg request url', function () { - let request = spec.buildRequests([bid]) - expect(request).to.exist - expect(request.method).to.equal('GET') - let parsedRequestUrl = url.parse(request.url) - expect(parsedRequestUrl.hostname).to.equal('hbps.adxcg.net') - expect(parsedRequestUrl.pathname).to.equal('/get/adi') - - let query = parsedRequestUrl.search - expect(query.renderformat).to.equal('javascript') - expect(query.ver).to.equal('r20191128PB30') - expect(query.source).to.equal('pbjs10') - expect(query.pbjs).to.equal('$prebid.version$') - expect(query.adzoneid).to.equal('1') - expect(query.format).to.equal('300x250|640x360|1x1') - expect(query.jsonp).to.be.undefined - expect(query.prebidBidIds).to.equal('84ab500420319d') - }) - }) + it('creates a valid adxcg request url bidBanner', function () { + let request = spec.buildRequests([bidBanner]); + expect(request).to.exist; + expect(request.method).to.equal('GET'); + let parsedRequestUrl = url.parse(request.url); + expect(parsedRequestUrl.hostname).to.equal('hbps.adxcg.net'); + expect(parsedRequestUrl.pathname).to.equal('/get/adi'); + + let query = parsedRequestUrl.search; + expect(query.renderformat).to.equal('javascript'); + expect(query.ver).to.equal('r20191128PB30'); + expect(query.source).to.equal('pbjs10'); + expect(query.pbjs).to.equal('$prebid.version$'); + expect(query.adzoneid).to.equal('1'); + expect(query.format).to.equal('300x250|640x360|1x1'); + expect(query.jsonp).to.be.undefined; + expect(query.prebidBidIds).to.equal('84ab500420319d'); + expect(query.bidfloors).to.equal('0'); + + expect(query).to.have.property('secure'); + expect(query).to.have.property('uw'); + expect(query).to.have.property('uh'); + expect(query).to.have.property('dpr'); + expect(query).to.have.property('bt'); + expect(query).to.have.property('cookies'); + expect(query).to.have.property('tz'); + expect(query).to.have.property('dt'); + expect(query).to.have.property('iob'); + expect(query).to.have.property('rndid'); + expect(query).to.have.property('ref'); + expect(query).to.have.property('url'); + }); + + it('creates a valid adxcg request url bidVideo', function () { + let request = spec.buildRequests([bidVideo]); + expect(request).to.exist; + expect(request.method).to.equal('GET'); + let parsedRequestUrl = url.parse(request.url); + expect(parsedRequestUrl.hostname).to.equal('hbps.adxcg.net'); + expect(parsedRequestUrl.pathname).to.equal('/get/adi'); + + let query = parsedRequestUrl.search; + // general part + expect(query.renderformat).to.equal('javascript'); + expect(query.ver).to.equal('r20191128PB30'); + expect(query.source).to.equal('pbjs10'); + expect(query.pbjs).to.equal('$prebid.version$'); + expect(query.adzoneid).to.equal('20'); + expect(query.format).to.equal('640x480'); + expect(query.jsonp).to.be.undefined; + expect(query.prebidBidIds).to.equal('84ab500420319d'); + expect(query.bidfloors).to.equal('0'); + + expect(query).to.have.property('secure'); + expect(query).to.have.property('uw'); + expect(query).to.have.property('uh'); + expect(query).to.have.property('dpr'); + expect(query).to.have.property('bt'); + expect(query).to.have.property('cookies'); + expect(query).to.have.property('tz'); + expect(query).to.have.property('dt'); + expect(query).to.have.property('iob'); + expect(query).to.have.property('rndid'); + expect(query).to.have.property('ref'); + expect(query).to.have.property('url'); + + // video specific part + expect(query['video.maxduration.0']).to.equal('30'); + expect(query['video.mimes.0']).to.equal('video/mp4'); + expect(query['video.context.0']).to.equal('instream'); + }); + + it('creates a valid adxcg request url bidNative', function () { + let request = spec.buildRequests([bidNative]); + expect(request).to.exist; + expect(request.method).to.equal('GET'); + let parsedRequestUrl = url.parse(request.url); + expect(parsedRequestUrl.hostname).to.equal('hbps.adxcg.net'); + expect(parsedRequestUrl.pathname).to.equal('/get/adi'); + + let query = parsedRequestUrl.search; + expect(query.renderformat).to.equal('javascript'); + expect(query.ver).to.equal('r20191128PB30'); + expect(query.source).to.equal('pbjs10'); + expect(query.pbjs).to.equal('$prebid.version$'); + expect(query.adzoneid).to.equal('2379'); + expect(query.format).to.equal('0x0'); + expect(query.jsonp).to.be.undefined; + expect(query.prebidBidIds).to.equal('84ab500420319d'); + expect(query.bidfloors).to.equal('0'); + + expect(query).to.have.property('secure'); + expect(query).to.have.property('uw'); + expect(query).to.have.property('uh'); + expect(query).to.have.property('dpr'); + expect(query).to.have.property('bt'); + expect(query).to.have.property('cookies'); + expect(query).to.have.property('tz'); + expect(query).to.have.property('dt'); + expect(query).to.have.property('iob'); + expect(query).to.have.property('rndid'); + expect(query).to.have.property('ref'); + expect(query).to.have.property('url'); + }); + }); describe('gdpr compliance', function () { - let bid = { - 'bidder': 'adxcg', - 'params': { - 'adzoneid': '1' - }, - 'adUnitCode': 'adunit-code', - 'mediaTypes': { - 'banner': { - 'sizes': [[300, 250], [640, 360], [1, 1]] - } - }, - 'bidId': '84ab500420319d', - 'bidderRequestId': '7101db09af0db2', - 'auctionId': '1d1a030790a475', - } - it('should send GDPR Consent data if gdprApplies', function () { - let request = spec.buildRequests([bid], {gdprConsent: {gdprApplies: true, consentString: 'consentDataString'}}) - let parsedRequestUrl = url.parse(request.url) - let query = parsedRequestUrl.search + let request = spec.buildRequests([bidBanner], { + gdprConsent: { + gdprApplies: true, + consentString: 'consentDataString' + } + }); + let parsedRequestUrl = url.parse(request.url); + let query = parsedRequestUrl.search; - expect(query.gdpr).to.equal('1') - expect(query.gdpr_consent).to.equal('consentDataString') - }) + expect(query.gdpr).to.equal('1'); + expect(query.gdpr_consent).to.equal('consentDataString'); + }); it('should not send GDPR Consent data if gdprApplies is false or undefined', function () { - let request = spec.buildRequests([bid], { + let request = spec.buildRequests([bidBanner], { gdprConsent: { gdprApplies: false, consentString: 'consentDataString' } - }) - let parsedRequestUrl = url.parse(request.url) - let query = parsedRequestUrl.search + }); + let parsedRequestUrl = url.parse(request.url); + let query = parsedRequestUrl.search; - expect(query.gdpr).to.be.undefined - expect(query.gdpr_consent).to.be.undefined - }) - }) + expect(query.gdpr).to.be.undefined; + expect(query.gdpr_consent).to.be.undefined; + }); + }); describe('userid pubcid should be passed to querystring', function () { - let bid = [{ - 'bidder': 'adxcg', - 'params': { - 'adzoneid': '1' - }, - 'adUnitCode': 'adunit-code', - 'mediaTypes': { - 'banner': { - 'sizes': [[300, 250], [640, 360], [1, 1]] - } - }, - 'bidId': '84ab500420319d', - 'bidderRequestId': '7101db09af0db2', - 'auctionId': '1d1a030790a475', - }] - let bidderRequests = {}; - - bid[0].userId = {'pubcid': 'pubcidabcd'}; + let bid = deepClone([bidBanner]); + bid[0].userId = {pubcid: 'pubcidabcd'}; it('should send pubcid if available', function () { - let request = spec.buildRequests(bid, bidderRequests) - let parsedRequestUrl = url.parse(request.url) - let query = parsedRequestUrl.search - expect(query.pubcid).to.equal('pubcidabcd') - }) - }) + let request = spec.buildRequests(bid, bidderRequests); + let parsedRequestUrl = url.parse(request.url); + let query = parsedRequestUrl.search; + expect(query.pubcid).to.equal('pubcidabcd'); + }); + }); describe('userid tdid should be passed to querystring', function () { - let bid = [{ - 'bidder': 'adxcg', - 'params': { - 'adzoneid': '1' - }, - 'adUnitCode': 'adunit-code', - 'mediaTypes': { - 'banner': { - 'sizes': [[300, 250], [640, 360], [1, 1]] - } - }, - 'bidId': '84ab500420319d', - 'bidderRequestId': '7101db09af0db2', - 'auctionId': '1d1a030790a475', - }] - + let bid = deepClone([bidBanner]); let bidderRequests = {}; - bid[0].userId = {'tdid': 'tdidabcd'}; + bid[0].userId = {tdid: 'tdidabcd'}; it('should send pubcid if available', function () { - let request = spec.buildRequests(bid, bidderRequests) - let parsedRequestUrl = url.parse(request.url) - let query = parsedRequestUrl.search + let request = spec.buildRequests(bid, bidderRequests); + let parsedRequestUrl = url.parse(request.url); + let query = parsedRequestUrl.search; expect(query.tdid).to.equal('tdidabcd'); - }) - }) + }); + }); describe('userid id5id should be passed to querystring', function () { - let bid = [{ - 'bidder': 'adxcg', - 'params': { - 'adzoneid': '1' - }, - 'adUnitCode': 'adunit-code', - 'mediaTypes': { - 'banner': { - 'sizes': [[300, 250], [640, 360], [1, 1]] - } - }, - 'bidId': '84ab500420319d', - 'bidderRequestId': '7101db09af0db2', - 'auctionId': '1d1a030790a475', - }] - + let bid = deepClone([bidBanner]); let bidderRequests = {}; - bid[0].userId = {'id5id': 'id5idsample'}; + bid[0].userId = {id5id: 'id5idsample'}; it('should send pubcid if available', function () { - let request = spec.buildRequests(bid, bidderRequests) - let parsedRequestUrl = url.parse(request.url) - let query = parsedRequestUrl.search + let request = spec.buildRequests(bid, bidderRequests); + let parsedRequestUrl = url.parse(request.url); + let query = parsedRequestUrl.search; expect(query.id5id).to.equal('id5idsample'); - }) - }) + }); + }); describe('userid idl_env should be passed to querystring', function () { - let bid = [{ - 'bidder': 'adxcg', - 'params': { - 'adzoneid': '1' - }, - 'adUnitCode': 'adunit-code', - 'mediaTypes': { - 'banner': { - 'sizes': [[300, 250], [640, 360], [1, 1]] - } - }, - 'bidId': '84ab500420319d', - 'bidderRequestId': '7101db09af0db2', - 'auctionId': '1d1a030790a475', - }] - + let bid = deepClone([bidBanner]); let bidderRequests = {}; - bid[0].userId = {'idl_env': 'idl_envsample'}; + bid[0].userId = {idl_env: 'idl_envsample'}; it('should send pubcid if available', function () { - let request = spec.buildRequests(bid, bidderRequests) - let parsedRequestUrl = url.parse(request.url) - let query = parsedRequestUrl.search + let request = spec.buildRequests(bid, bidderRequests); + let parsedRequestUrl = url.parse(request.url); + let query = parsedRequestUrl.search; expect(query.idl_env).to.equal('idl_envsample'); - }) - }) + }); + }); describe('response handler', function () { let BIDDER_REQUEST = { - 'bidder': 'adxcg', - 'params': { - 'adzoneid': '1' + bidder: 'adxcg', + params: { + adzoneid: '1' }, - 'adUnitCode': 'adunit-code', - 'mediaTypes': { - 'banner': { - 'sizes': [[300, 250], [640, 360], [1, 1]] + adUnitCode: 'adunit-code', + mediaTypes: { + banner: { + sizes: [ + [300, 250], + [640, 360], + [1, 1] + ] } }, - 'bidId': '84ab500420319d', - 'bidderRequestId': '7101db09af0db2', - 'auctionId': '1d1a030790a475', - } - - let BANNER_RESPONSE = - { - body: [{ - 'bidId': '84ab500420319d', - 'bidderCode': 'adxcg', - 'width': 300, - 'height': 250, - 'creativeId': '42', - 'cpm': 0.45, - 'currency': 'USD', - 'netRevenue': true, - 'ad': '' - }], - header: {'someheader': 'fakedata'} - } - - let BANNER_RESPONSE_WITHDEALID = - { - body: [{ - 'bidId': '84ab500420319d', - 'bidderCode': 'adxcg', - 'width': 300, - 'height': 250, - 'deal_id': '7722', - 'creativeId': '42', - 'cpm': 0.45, - 'currency': 'USD', - 'netRevenue': true, - 'ad': '' - }], - header: {'someheader': 'fakedata'} - } - - let VIDEO_RESPONSE = - { - body: [{ - 'bidId': '84ab500420319d', - 'bidderCode': 'adxcg', - 'width': 640, - 'height': 360, - 'creativeId': '42', - 'cpm': 0.45, - 'currency': 'USD', - 'netRevenue': true, - 'vastUrl': 'vastContentUrl' - }], - header: {'someheader': 'fakedata'} - } - - let NATIVE_RESPONSE = - { - body: [{ - 'bidId': '84ab500420319d', - 'bidderCode': 'adxcg', - 'width': 0, - 'height': 0, - 'creativeId': '42', - 'cpm': 0.45, - 'currency': 'USD', - 'netRevenue': true, - 'nativeResponse': { - 'assets': [{ - 'id': 1, - 'required': 0, - 'title': { - 'text': 'titleContent' - } - }, { - 'id': 2, - 'required': 0, - 'img': { - 'url': 'imageContent', - 'w': 600, - 'h': 600 - } - }, { - 'id': 3, - 'required': 0, - 'data': { - 'label': 'DESC', - 'value': 'descriptionContent' - } - }, { - 'id': 0, - 'required': 0, - 'data': { - 'label': 'SPONSORED', - 'value': 'sponsoredByContent' - } - }, { - 'id': 5, - 'required': 0, - 'icon': { - 'url': 'iconContent', - 'w': 400, - 'h': 400 + bidId: '84ab500420319d', + bidderRequestId: '7101db09af0db2', + auctionId: '1d1a030790a475' + }; + + let BANNER_RESPONSE = { + body: [ + { + bidId: '84ab500420319d', + bidderCode: 'adxcg', + width: 300, + height: 250, + creativeId: '42', + cpm: 0.45, + currency: 'USD', + netRevenue: true, + ad: '' + } + ], + header: {someheader: 'fakedata'} + }; + + let BANNER_RESPONSE_WITHDEALID = { + body: [ + { + bidId: '84ab500420319d', + bidderCode: 'adxcg', + width: 300, + height: 250, + deal_id: '7722', + creativeId: '42', + cpm: 0.45, + currency: 'USD', + netRevenue: true, + ad: '' + } + ], + header: {someheader: 'fakedata'} + }; + + let VIDEO_RESPONSE = { + body: [ + { + bidId: '84ab500420319d', + bidderCode: 'adxcg', + width: 640, + height: 360, + creativeId: '42', + cpm: 0.45, + currency: 'USD', + netRevenue: true, + vastUrl: 'vastContentUrl' + } + ], + header: {someheader: 'fakedata'} + }; + + let NATIVE_RESPONSE = { + body: [ + { + bidId: '84ab500420319d', + bidderCode: 'adxcg', + width: 0, + height: 0, + creativeId: '42', + cpm: 0.45, + currency: 'USD', + netRevenue: true, + nativeResponse: { + assets: [ + { + id: 1, + required: 0, + title: { + text: 'titleContent' + } + }, + { + id: 2, + required: 0, + img: { + url: 'imageContent', + w: 600, + h: 600 + } + }, + { + id: 3, + required: 0, + data: { + label: 'DESC', + value: 'descriptionContent' + } + }, + { + id: 0, + required: 0, + data: { + label: 'SPONSORED', + value: 'sponsoredByContent' + } + }, + { + id: 5, + required: 0, + icon: { + url: 'iconContent', + w: 400, + h: 400 + } } - }], - 'link': { - 'url': 'linkContent' + ], + link: { + url: 'linkContent' }, - 'imptrackers': ['impressionTracker1', 'impressionTracker2'] + imptrackers: ['impressionTracker1', 'impressionTracker2'] } - }], - header: {'someheader': 'fakedata'} - } + } + ], + header: {someheader: 'fakedata'} + }; it('handles regular responses', function () { - let result = spec.interpretResponse(BANNER_RESPONSE, BIDDER_REQUEST) - - expect(result).to.have.lengthOf(1) - - expect(result[0]).to.exist - expect(result[0].width).to.equal(300) - expect(result[0].height).to.equal(250) - expect(result[0].creativeId).to.equal(42) - expect(result[0].cpm).to.equal(0.45) - expect(result[0].ad).to.equal('') - expect(result[0].currency).to.equal('USD') - expect(result[0].netRevenue).to.equal(true) - expect(result[0].ttl).to.equal(300) - expect(result[0].dealId).to.not.exist - }) + let result = spec.interpretResponse(BANNER_RESPONSE, BIDDER_REQUEST); + + expect(result).to.have.lengthOf(1); + + expect(result[0]).to.exist; + expect(result[0].width).to.equal(300); + expect(result[0].height).to.equal(250); + expect(result[0].creativeId).to.equal(42); + expect(result[0].cpm).to.equal(0.45); + expect(result[0].ad).to.equal(''); + expect(result[0].currency).to.equal('USD'); + expect(result[0].netRevenue).to.equal(true); + expect(result[0].ttl).to.equal(300); + expect(result[0].dealId).to.not.exist; + }); it('handles regular responses with dealid', function () { - let result = spec.interpretResponse(BANNER_RESPONSE_WITHDEALID, BIDDER_REQUEST) - - expect(result).to.have.lengthOf(1) - - expect(result[0].width).to.equal(300) - expect(result[0].height).to.equal(250) - expect(result[0].creativeId).to.equal(42) - expect(result[0].cpm).to.equal(0.45) - expect(result[0].ad).to.equal('') - expect(result[0].currency).to.equal('USD') - expect(result[0].netRevenue).to.equal(true) - expect(result[0].ttl).to.equal(300) - }) + let result = spec.interpretResponse( + BANNER_RESPONSE_WITHDEALID, + BIDDER_REQUEST + ); + + expect(result).to.have.lengthOf(1); + + expect(result[0].width).to.equal(300); + expect(result[0].height).to.equal(250); + expect(result[0].creativeId).to.equal(42); + expect(result[0].cpm).to.equal(0.45); + expect(result[0].ad).to.equal(''); + expect(result[0].currency).to.equal('USD'); + expect(result[0].netRevenue).to.equal(true); + expect(result[0].ttl).to.equal(300); + }); it('handles video responses', function () { - let result = spec.interpretResponse(VIDEO_RESPONSE, BIDDER_REQUEST) - expect(result).to.have.lengthOf(1) - - expect(result[0].width).to.equal(640) - expect(result[0].height).to.equal(360) - expect(result[0].mediaType).to.equal('video') - expect(result[0].creativeId).to.equal(42) - expect(result[0].cpm).to.equal(0.45) - expect(result[0].vastUrl).to.equal('vastContentUrl') - expect(result[0].currency).to.equal('USD') - expect(result[0].netRevenue).to.equal(true) - expect(result[0].ttl).to.equal(300) - }) + let result = spec.interpretResponse(VIDEO_RESPONSE, BIDDER_REQUEST); + expect(result).to.have.lengthOf(1); + + expect(result[0].width).to.equal(640); + expect(result[0].height).to.equal(360); + expect(result[0].mediaType).to.equal('video'); + expect(result[0].creativeId).to.equal(42); + expect(result[0].cpm).to.equal(0.45); + expect(result[0].vastUrl).to.equal('vastContentUrl'); + expect(result[0].currency).to.equal('USD'); + expect(result[0].netRevenue).to.equal(true); + expect(result[0].ttl).to.equal(300); + }); it('handles native responses', function () { - let result = spec.interpretResponse(NATIVE_RESPONSE, BIDDER_REQUEST) - - expect(result[0].width).to.equal(0) - expect(result[0].height).to.equal(0) - expect(result[0].mediaType).to.equal('native') - expect(result[0].creativeId).to.equal(42) - expect(result[0].cpm).to.equal(0.45) - expect(result[0].currency).to.equal('USD') - expect(result[0].netRevenue).to.equal(true) - expect(result[0].ttl).to.equal(300) - - expect(result[0].native.clickUrl).to.equal('linkContent') - expect(result[0].native.impressionTrackers).to.deep.equal(['impressionTracker1', 'impressionTracker2']) - expect(result[0].native.title).to.equal('titleContent') - - expect(result[0].native.image.url).to.equal('imageContent') - expect(result[0].native.image.height).to.equal(600) - expect(result[0].native.image.width).to.equal(600) - - expect(result[0].native.icon.url).to.equal('iconContent') - expect(result[0].native.icon.height).to.equal(400) - expect(result[0].native.icon.width).to.equal(400) - - expect(result[0].native.body).to.equal('descriptionContent') - expect(result[0].native.sponsoredBy).to.equal('sponsoredByContent') - }) + let result = spec.interpretResponse(NATIVE_RESPONSE, BIDDER_REQUEST); + + expect(result[0].width).to.equal(0); + expect(result[0].height).to.equal(0); + expect(result[0].mediaType).to.equal('native'); + expect(result[0].creativeId).to.equal(42); + expect(result[0].cpm).to.equal(0.45); + expect(result[0].currency).to.equal('USD'); + expect(result[0].netRevenue).to.equal(true); + expect(result[0].ttl).to.equal(300); + + expect(result[0].native.clickUrl).to.equal('linkContent'); + expect(result[0].native.impressionTrackers).to.deep.equal([ + 'impressionTracker1', + 'impressionTracker2' + ]); + expect(result[0].native.title).to.equal('titleContent'); + + expect(result[0].native.image.url).to.equal('imageContent'); + expect(result[0].native.image.height).to.equal(600); + expect(result[0].native.image.width).to.equal(600); + + expect(result[0].native.icon.url).to.equal('iconContent'); + expect(result[0].native.icon.height).to.equal(400); + expect(result[0].native.icon.width).to.equal(400); + + expect(result[0].native.body).to.equal('descriptionContent'); + expect(result[0].native.sponsoredBy).to.equal('sponsoredByContent'); + }); it('handles nobid responses', function () { - let response = [] - let bidderRequest = BIDDER_REQUEST + let response = []; + let bidderRequest = BIDDER_REQUEST; - let result = spec.interpretResponse(response, bidderRequest) - expect(result.length).to.equal(0) - }) - }) + let result = spec.interpretResponse(response, bidderRequest); + expect(result.length).to.equal(0); + }); + }); describe('getUserSyncs', function () { let syncoptionsIframe = { - 'iframeEnabled': 'true' - } + iframeEnabled: 'true' + }; it('should return iframe sync option', function () { - expect(spec.getUserSyncs(syncoptionsIframe)[0].type).to.equal('iframe') - expect(spec.getUserSyncs(syncoptionsIframe)[0].url).to.equal('https://cdn.adxcg.net/pb-sync.html') - }) - }) -}) + expect(spec.getUserSyncs(syncoptionsIframe)[0].type).to.equal('iframe'); + expect(spec.getUserSyncs(syncoptionsIframe)[0].url).to.equal( + 'https://cdn.adxcg.net/pb-sync.html' + ); + }); + }); +}); From d1adb8460ea9a3a9cec79f150a4ef405ad2da43d Mon Sep 17 00:00:00 2001 From: adxcgcom <31470944+adxcgcom@users.noreply.github.com> Date: Mon, 9 Dec 2019 15:20:10 +0000 Subject: [PATCH 04/41] Update adxcgBidAdapter.js - native fix (#4534) * Update adxcgBidAdapter.js - native fix * trigger CI * trigger CI * Code reformat and adding ending semicolons. No other changes Reformatted the code in separate commit before real changes * update adxcgBidAdapter_spec general cleanup - removed duplicated jsons added native size check added many url querystring http call parameter checks * trigger CI From 1a30dea588781a25ad6a12b3de9faa7728ac1f2e Mon Sep 17 00:00:00 2001 From: PWyrembak Date: Mon, 9 Dec 2019 18:28:00 +0300 Subject: [PATCH 05/41] Added US Privacy support in TrustX Bid Adapter (#4529) * Add trustx adapter and tests for it * update integration example * Update trustx adapter * Post-review fixes of Trustx adapter * Code improvement for trustx adapter: changed default price type from gross to net * Update TrustX adapter to support the 1.0 version * Make requested changes for TrustX adapter * Updated markdown file for TrustX adapter * Fix TrustX adapter and spec file * Update TrustX adapter: r parameter was added to ad request as cache buster * Add support of gdpr to Trustx Bid Adapter * Add wtimeout to ad request params for TrustX Bid Adapter * TrustX Bid Adapter: remove last ampersand in the ad request * Update TrustX Bid Adapter to support identical uids in parameters * Update TrustX Bid Adapter to ignore bids that sizes do not match the size of the request * Update TrustX Bid Adapter to support instream and outstream video * Added wrapperType and wrapperVersion parameters in ad request for TrustX Bid Adapter * Update TrustX Bid Adapter to use refererInfo instead depricated function utils.getTopWindowUrl * HOTFIX for referrer encodind in TrustX Bid Adapter * Fix test for TrustX Bid Adapter * TrustX Bid Adapter: added keywords passing support * TrustX Bid Adapter: added us_privacy parameter in bid request * TrustX Bid Adapter: fix us_privacy parameter in bid request --- modules/trustxBidAdapter.js | 3 +++ test/spec/modules/trustxBidAdapter_spec.js | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/modules/trustxBidAdapter.js b/modules/trustxBidAdapter.js index 00c86dec0d34..94d541d1fe2c 100644 --- a/modules/trustxBidAdapter.js +++ b/modules/trustxBidAdapter.js @@ -121,6 +121,9 @@ export const spec = { (typeof bidderRequest.gdprConsent.gdprApplies === 'boolean') ? Number(bidderRequest.gdprConsent.gdprApplies) : 1; } + if (bidderRequest.uspConsent) { + payload.us_privacy = bidderRequest.uspConsent; + } } return { diff --git a/test/spec/modules/trustxBidAdapter_spec.js b/test/spec/modules/trustxBidAdapter_spec.js index 4256012ba0bb..aee6311cb857 100644 --- a/test/spec/modules/trustxBidAdapter_spec.js +++ b/test/spec/modules/trustxBidAdapter_spec.js @@ -168,6 +168,14 @@ describe('TrustXAdapter', function () { expect(payload).to.have.property('gdpr_applies', '1'); }); + it('if usPrivacy is present payload must have us_privacy param', function () { + const bidderRequestWithUSP = Object.assign({uspConsent: '1YNN'}, bidderRequest); + const request = spec.buildRequests(bidRequests, bidderRequestWithUSP); + expect(request.data).to.be.an('string'); + const payload = parseRequest(request.data); + expect(payload).to.have.property('us_privacy', '1YNN'); + }); + it('should convert keyword params to proper form and attaches to request', function () { const bidRequestWithKeywords = [].concat(bidRequests); bidRequestWithKeywords[1] = Object.assign({}, From d45523c30c56aaf6ec9a30551a92311e49dd0572 Mon Sep 17 00:00:00 2001 From: Mike Groh Date: Mon, 9 Dec 2019 15:08:24 -0500 Subject: [PATCH 06/41] Trion interactive query param additions (#4522) * Adding files associated with the trion adapter update to the newest prebid version(1.0). * Updating pull request with safer checks for user sync and general clean up/consistency of tests. * removing a call to bidder code for pull request review. also removing the test that requires it * there were some changes to the bid factory after our initial release that we didn't account for. Changing adapter to account for response body and required params. * Revert "there were some changes to the bid factory after our initial release that we didn't account for. Changing adapter to account for response body and required params." This reverts commit 324d15785fb61c92db9c0a37f1001f47721e3a25. * there were some changes to the bid factory after our initial release that we didn't account for. Changing adapter to account for response body and required params. * adding safety checks to Trion adapter * Sending up to trion endpoint if there is bot traffic or the browser tab is not visible. * sending the wrong param in the test. * Trion test cleanup. returning document and window states to their original form after tests. * Trion test cleanup. using before and after to alter window and document objects in tests. --- modules/trionBidAdapter.js | 6 +++ test/spec/modules/trionBidAdapter_spec.js | 55 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/modules/trionBidAdapter.js b/modules/trionBidAdapter.js index 97f82f57b852..3595b709a51d 100644 --- a/modules/trionBidAdapter.js +++ b/modules/trionBidAdapter.js @@ -84,6 +84,9 @@ function buildTrionUrlParams(bid) { var re = utils.getBidIdParameter('re', bid.params); var url = utils.getTopWindowUrl(); var sizes = utils.parseSizesInput(bid.sizes).join(','); + var isAutomated = (navigator && navigator.webdriver) ? 1 : 0; + var isHidden = (document.hidden) ? 1 : 0; + var visibilityState = encodeURIComponent(document.visibilityState); var intT = window.TR_INT_T && window.TR_INT_T != -1 ? window.TR_INT_T : null; if (!intT) { @@ -108,6 +111,9 @@ function buildTrionUrlParams(bid) { if (intT) { trionUrl = utils.tryAppendQueryString(trionUrl, 'int_t', encodeURIComponent(intT)); } + trionUrl = utils.tryAppendQueryString(trionUrl, 'tr_wd', isAutomated); + trionUrl = utils.tryAppendQueryString(trionUrl, 'tr_hd', isHidden); + trionUrl = utils.tryAppendQueryString(trionUrl, 'tr_vs', visibilityState); // remove the trailing "&" if (trionUrl.lastIndexOf('&') === trionUrl.length - 1) { diff --git a/test/spec/modules/trionBidAdapter_spec.js b/test/spec/modules/trionBidAdapter_spec.js index 805ae70a3396..63c2b71a31a7 100644 --- a/test/spec/modules/trionBidAdapter_spec.js +++ b/test/spec/modules/trionBidAdapter_spec.js @@ -119,6 +119,61 @@ describe('Trion adapter tests', function () { expect(bidUrlParams).to.include(utils.getTopWindowUrl()); delete params.re; }); + + describe('webdriver', function () { + let originalWD; + + beforeEach(function () { + originalWD = window.navigator.webdriver; + window.navigator['__defineGetter__']('webdriver', function () { + return 1; + }); + }); + + afterEach(function () { + window.navigator['__defineGetter__']('webdriver', function () { + return originalWD; + }); + }); + + it('should send the correct state when there is non human traffic', function () { + let bidRequests = spec.buildRequests(TRION_BID_REQUEST); + let bidUrlParams = bidRequests[0].data; + expect(bidUrlParams).to.include('tr_wd=1'); + }); + }); + + describe('visibility', function () { + let originalHD; + let originalVS; + + beforeEach(function () { + originalHD = document.hidden; + originalVS = document.visibilityState; + document['__defineGetter__']('hidden', function () { + return 1; + }); + document['__defineGetter__']('visibilityState', function () { + return 'hidden'; + }); + }); + + afterEach(function () { + document['__defineGetter__']('hidden', function () { + return originalHD; + }); + document['__defineGetter__']('visibilityState', function () { + return originalVS; + }); + }); + + it('should send the correct states when the document is not visible', function () { + let bidRequests = spec.buildRequests(TRION_BID_REQUEST); + let bidUrlParams = bidRequests[0].data; + expect(bidUrlParams).to.include('tr_hd=1'); + expect(bidUrlParams).to.include('tr_vs=hidden'); + }); + }); }); describe('interpretResponse', function () { From 3c853dcb97d086ef2784a323891c8003243b4fc1 Mon Sep 17 00:00:00 2001 From: Vadim Mazzherin Date: Tue, 10 Dec 2019 03:22:03 +0600 Subject: [PATCH 07/41] ShowHeroes Adapter - naming convention issue (#4525) * add ShowHeroes Adapter * ShowHeroes adapter - expanded outstream support * Revert "ShowHeroes adapter - expanded outstream support" This reverts commit bfcdb913b52012b5afbf95a84956b906518a4b51. * ShowHeroes adapter - expanded outstream support * ShowHeroes adapter - fixes (#4222) * ShowHeroes adapter - banner and outstream fixes (#4222) * ShowHeroes adapter - description and outstream changes (#4222) * ShowHeroes adapter - increase test coverage and small fix * ShowHeroes Adapter - naming convention issue --- modules/{shBidAdapter.js => showheroes-bsBidAdapter.js} | 0 modules/{shBidAdapter.md => showheroes-bsBidAdapter.md} | 0 .../{shBidAdapter_spec.js => showheroes-bsBidAdapter_spec.js} | 2 +- 3 files changed, 1 insertion(+), 1 deletion(-) rename modules/{shBidAdapter.js => showheroes-bsBidAdapter.js} (100%) rename modules/{shBidAdapter.md => showheroes-bsBidAdapter.md} (100%) rename test/spec/modules/{shBidAdapter_spec.js => showheroes-bsBidAdapter_spec.js} (99%) diff --git a/modules/shBidAdapter.js b/modules/showheroes-bsBidAdapter.js similarity index 100% rename from modules/shBidAdapter.js rename to modules/showheroes-bsBidAdapter.js diff --git a/modules/shBidAdapter.md b/modules/showheroes-bsBidAdapter.md similarity index 100% rename from modules/shBidAdapter.md rename to modules/showheroes-bsBidAdapter.md diff --git a/test/spec/modules/shBidAdapter_spec.js b/test/spec/modules/showheroes-bsBidAdapter_spec.js similarity index 99% rename from test/spec/modules/shBidAdapter_spec.js rename to test/spec/modules/showheroes-bsBidAdapter_spec.js index 525642da7d65..124f98600d54 100644 --- a/test/spec/modules/shBidAdapter_spec.js +++ b/test/spec/modules/showheroes-bsBidAdapter_spec.js @@ -1,5 +1,5 @@ import {expect} from 'chai' -import {spec} from 'modules/shBidAdapter' +import {spec} from 'modules/showheroes-bsBidAdapter' import {newBidder} from 'src/adapters/bidderFactory' import {VIDEO, BANNER} from 'src/mediaTypes' From 4eb1e446500949fba5cdf2c3a64e6762f6898e31 Mon Sep 17 00:00:00 2001 From: Denis Logachov Date: Mon, 9 Dec 2019 23:23:32 +0200 Subject: [PATCH 08/41] Adkernel: tmax support (#4548) --- modules/adkernelBidAdapter.js | 29 ++++++-------------- test/spec/modules/adkernelBidAdapter_spec.js | 9 +++++- 2 files changed, 17 insertions(+), 21 deletions(-) diff --git a/modules/adkernelBidAdapter.js b/modules/adkernelBidAdapter.js index a8cd4fecb41e..29c234528142 100644 --- a/modules/adkernelBidAdapter.js +++ b/modules/adkernelBidAdapter.js @@ -36,11 +36,11 @@ export const spec = { }, buildRequests: function(bidRequests, bidderRequest) { let impDispatch = dispatchImps(bidRequests, bidderRequest.refererInfo); - const {gdprConsent, auctionId} = bidderRequest; + const {gdprConsent, auctionId, refererInfo, timeout} = bidderRequest; const requests = []; Object.keys(impDispatch).forEach(host => { Object.keys(impDispatch[host]).forEach(zoneId => { - const request = buildRtbRequest(impDispatch[host][zoneId], auctionId, gdprConsent, bidderRequest.refererInfo); + const request = buildRtbRequest(impDispatch[host][zoneId], auctionId, gdprConsent, refererInfo, timeout); requests.push({ method: 'POST', url: `https://${host}/hb?zone=${zoneId}&v=${VERSION}`, @@ -107,8 +107,7 @@ function dispatchImps(bidRequests, refererInfo) { return bidRequests.map(bidRequest => buildImp(bidRequest, secure)) .reduce((acc, curr, index) => { let bidRequest = bidRequests[index]; - let zoneId = bidRequest.params.zoneId; - let host = bidRequest.params.host; + let {zoneId, host} = bidRequest.params; acc[host] = acc[host] || {}; acc[host][zoneId] = acc[host][zoneId] || []; acc[host][zoneId].push(curr); @@ -126,14 +125,14 @@ function buildImp(bidRequest, secure) { }; if (utils.deepAccess(bidRequest, `mediaTypes.banner`)) { - let sizes = canonicalizeSizesArray(bidRequest.mediaTypes.banner.sizes); + let sizes = utils.getAdUnitSizes(bidRequest); imp.banner = { format: sizes.map(wh => utils.parseGPTSingleSizeArrayToRtbSize(wh)), topframe: 0 }; } else if (utils.deepAccess(bidRequest, 'mediaTypes.video')) { - let size = canonicalizeSizesArray(bidRequest.mediaTypes.video.playerSize)[0]; - imp.video = utils.parseGPTSingleSizeArrayToRtbSize(size); + let sizes = bidRequest.mediaTypes.video.playerSize || []; + imp.video = utils.parseGPTSingleSizeArrayToRtbSize(sizes[0]) || {}; if (bidRequest.params.video) { Object.keys(bidRequest.params.video) .filter(key => includes(VIDEO_TARGETING, key)) @@ -146,27 +145,16 @@ function buildImp(bidRequest, secure) { return imp; } -/** - * Convert input array of sizes to canonical form Array[Array[Number]] - * @param sizes - * @return Array[Array[Number]] - */ -function canonicalizeSizesArray(sizes) { - if (sizes.length === 2 && !utils.isArray(sizes[0])) { - return [sizes]; - } - return sizes; -} - /** * Builds complete rtb request * @param imps collection of impressions * @param auctionId * @param gdprConsent * @param refInfo + * @param timeout * @return Object complete rtb request */ -function buildRtbRequest(imps, auctionId, gdprConsent, refInfo) { +function buildRtbRequest(imps, auctionId, gdprConsent, refInfo, timeout) { let req = { 'id': auctionId, 'imp': imps, @@ -178,6 +166,7 @@ function buildRtbRequest(imps, auctionId, gdprConsent, refInfo) { 'js': 1, 'language': getLanguage() }, + 'tmax': parseInt(timeout), 'ext': { 'adk_usersync': 1 } diff --git a/test/spec/modules/adkernelBidAdapter_spec.js b/test/spec/modules/adkernelBidAdapter_spec.js index c41c56043646..5b3d76ef0713 100644 --- a/test/spec/modules/adkernelBidAdapter_spec.js +++ b/test/spec/modules/adkernelBidAdapter_spec.js @@ -161,9 +161,10 @@ describe('Adkernel adapter', function () { }; function buildBidderRequest(url = 'https://example.com/index.html', params = {}) { - return Object.assign({}, params, {refererInfo: {referer: url, reachedTop: true}}) + return Object.assign({}, params, {refererInfo: {referer: url, reachedTop: true}, timeout: 3000}); } const DEFAULT_BIDDER_REQUEST = buildBidderRequest(); + function buildRequest(bidRequests, bidderRequest = DEFAULT_BIDDER_REQUEST, dnt = true) { let dntmock = sinon.stub(utils, 'getDNT').callsFake(() => dnt); let pbRequests = spec.buildRequests(bidRequests, bidderRequest); @@ -266,6 +267,12 @@ describe('Adkernel adapter', function () { let [_, bidRequests] = buildRequest([bid1_zone1], DEFAULT_BIDDER_REQUEST, false); expect(bidRequests[0].device).to.not.have.property('dnt'); }); + + it('should forward default bidder timeout', function() { + let [_, bidRequests] = buildRequest([bid1_zone1], DEFAULT_BIDDER_REQUEST); + let bidRequest = bidRequests[0]; + expect(bidRequests[0]).to.have.property('tmax', 3000); + }); }); describe('video request building', function () { From b640d0bf40cab09846d6946ad1cdb1af704420e7 Mon Sep 17 00:00:00 2001 From: jsnellbaker <31102355+jsnellbaker@users.noreply.github.com> Date: Mon, 9 Dec 2019 16:24:41 -0500 Subject: [PATCH 09/41] move uspDataHandler out of gdprDataHandler (#4562) * move uspDataHandler out of gdprDataHandler * add missing semi-colon --- src/adapterManager.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/adapterManager.js b/src/adapterManager.js index 99e2e31e9e18..4f5f63534a4b 100644 --- a/src/adapterManager.js +++ b/src/adapterManager.js @@ -271,6 +271,11 @@ adapterManager.makeBidRequests = function(adUnits, auctionStart, auctionId, cbTi if (gdprDataHandler.getConsentData()) { bidRequests.forEach(bidRequest => { bidRequest['gdprConsent'] = gdprDataHandler.getConsentData(); + }); + } + + if (uspDataHandler.getConsentData()) { + bidRequests.forEach(bidRequest => { bidRequest['uspConsent'] = uspDataHandler.getConsentData(); }); } From 42d856beee4319100270238dd8a2b7538d6ac4ca Mon Sep 17 00:00:00 2001 From: Robert Ray Martinez III Date: Mon, 9 Dec 2019 14:26:13 -0800 Subject: [PATCH 10/41] Rubicon bid adapter: fix netRev (#4552) * fix netRev * adding comments and more tests --- modules/rubiconBidAdapter.js | 4 +- test/spec/modules/rubiconBidAdapter_spec.js | 116 +++++++++++++++++++- 2 files changed, 116 insertions(+), 4 deletions(-) diff --git a/modules/rubiconBidAdapter.js b/modules/rubiconBidAdapter.js index 075eabc208e1..f42ed0be5b69 100644 --- a/modules/rubiconBidAdapter.js +++ b/modules/rubiconBidAdapter.js @@ -559,7 +559,7 @@ export const spec = { cpm: bid.price || 0, bidderCode: seatbid.seat, ttl: 300, - netRevenue: config.getConfig('rubicon.netRevenue') || true, + netRevenue: config.getConfig('rubicon.netRevenue') !== false, // If anything other than false, netRev is true width: bid.w || utils.deepAccess(bidRequest, 'mediaTypes.video.w') || utils.deepAccess(bidRequest, 'params.video.playerWidth'), height: bid.h || utils.deepAccess(bidRequest, 'mediaTypes.video.h') || utils.deepAccess(bidRequest, 'params.video.playerHeight'), }; @@ -639,7 +639,7 @@ export const spec = { cpm: ad.cpm || 0, dealId: ad.deal, ttl: 300, // 5 minutes - netRevenue: config.getConfig('rubicon.netRevenue') || false, + netRevenue: config.getConfig('rubicon.netRevenue') !== false, // If anything other than false, netRev is true rubicon: { advertiserId: ad.advertiser, networkId: ad.network }, diff --git a/test/spec/modules/rubiconBidAdapter_spec.js b/test/spec/modules/rubiconBidAdapter_spec.js index c0ed4245cbf0..c69415846520 100644 --- a/test/spec/modules/rubiconBidAdapter_spec.js +++ b/test/spec/modules/rubiconBidAdapter_spec.js @@ -1760,7 +1760,7 @@ describe('the rubicon adapter', function () { expect(bids[0].height).to.equal(50); expect(bids[0].cpm).to.equal(0.911); expect(bids[0].ttl).to.equal(300); - expect(bids[0].netRevenue).to.equal(false); + expect(bids[0].netRevenue).to.equal(true); expect(bids[0].rubicon.advertiserId).to.equal(7); expect(bids[0].rubicon.networkId).to.equal(8); expect(bids[0].creativeId).to.equal('crid-9'); @@ -1775,7 +1775,7 @@ describe('the rubicon adapter', function () { expect(bids[1].height).to.equal(250); expect(bids[1].cpm).to.equal(0.811); expect(bids[1].ttl).to.equal(300); - expect(bids[1].netRevenue).to.equal(false); + expect(bids[1].netRevenue).to.equal(true); expect(bids[1].rubicon.advertiserId).to.equal(7); expect(bids[1].rubicon.networkId).to.equal(8); expect(bids[1].creativeId).to.equal('crid-9'); @@ -1787,6 +1787,118 @@ describe('the rubicon adapter', function () { expect(bids[1].rubiconTargeting.rpfl_14062).to.equal('15_tier_all_test'); }); + it('should pass netRevenue correctly if set in setConfig', function () { + let response = { + 'status': 'ok', + 'account_id': 14062, + 'site_id': 70608, + 'zone_id': 530022, + 'size_id': 15, + 'alt_size_ids': [ + 43 + ], + 'tracking': '', + 'inventory': {}, + 'ads': [ + { + 'status': 'ok', + 'impression_id': '153dc240-8229-4604-b8f5-256933b9374c', + 'size_id': '15', + 'ad_id': '6', + 'advertiser': 7, + 'network': 8, + 'creative_id': 'crid-9', + 'type': 'script', + 'script': 'alert(\'foo\')', + 'campaign_id': 10, + 'cpm': 0.811, + 'targeting': [ + { + 'key': 'rpfl_14062', + 'values': [ + '15_tier_all_test' + ] + } + ] + }, + { + 'status': 'ok', + 'impression_id': '153dc240-8229-4604-b8f5-256933b9374d', + 'size_id': '43', + 'ad_id': '7', + 'advertiser': 7, + 'network': 8, + 'creative_id': 'crid-9', + 'type': 'script', + 'script': 'alert(\'foo\')', + 'campaign_id': 10, + 'cpm': 0.911, + 'targeting': [ + { + 'key': 'rpfl_14062', + 'values': [ + '43_tier_all_test' + ] + } + ] + } + ] + }; + + // Set to false => false + config.setConfig({ + rubicon: { + netRevenue: false + } + }); + let bids = spec.interpretResponse({body: response}, { + bidRequest: bidderRequest.bids[0] + }); + expect(bids).to.be.lengthOf(2); + expect(bids[0].netRevenue).to.equal(false); + expect(bids[1].netRevenue).to.equal(false); + + // Set to true => true + config.setConfig({ + rubicon: { + netRevenue: true + } + }); + bids = spec.interpretResponse({body: response}, { + bidRequest: bidderRequest.bids[0] + }); + expect(bids).to.be.lengthOf(2); + expect(bids[0].netRevenue).to.equal(true); + expect(bids[1].netRevenue).to.equal(true); + + // Set to undefined => true + config.setConfig({ + rubicon: { + netRevenue: undefined + } + }); + bids = spec.interpretResponse({body: response}, { + bidRequest: bidderRequest.bids[0] + }); + expect(bids).to.be.lengthOf(2); + expect(bids[0].netRevenue).to.equal(true); + expect(bids[1].netRevenue).to.equal(true); + + // Set to string => true + config.setConfig({ + rubicon: { + netRevenue: 'someString' + } + }); + bids = spec.interpretResponse({body: response}, { + bidRequest: bidderRequest.bids[0] + }); + expect(bids).to.be.lengthOf(2); + expect(bids[0].netRevenue).to.equal(true); + expect(bids[1].netRevenue).to.equal(true); + + config.resetConfig(); + }); it('should use "network-advertiser" if no creative_id', function () { let response = { 'status': 'ok', From 1a1dd2f56a5098f0ad68154de04c53a6020dea28 Mon Sep 17 00:00:00 2001 From: Rich Audience Date: Tue, 10 Dec 2019 15:26:32 +0100 Subject: [PATCH 11/41] RichAudience: Support userIDs + Prebid 3.0 (#4504) * Support userIDs + Prebid 3.0 * Fix bug in richAudienceBidAddapter_spec.js * Fix bug pubCommonId * Fix bug RichaudienceAdapter * Fix UserID5 * Fix bug ID5 change Source for Value * Fix bug richaudienceAdapter && Add userSync pixelEnabled * Fix bug richaudienceAdapter --- modules/richaudienceBidAdapter.js | 112 ++++-- .../modules/richaudienceBidAdapter_spec.js | 353 ++++++++++++++++-- 2 files changed, 404 insertions(+), 61 deletions(-) mode change 100644 => 100755 modules/richaudienceBidAdapter.js diff --git a/modules/richaudienceBidAdapter.js b/modules/richaudienceBidAdapter.js old mode 100644 new mode 100755 index bd47e481a765..2a4fa03c7d62 --- a/modules/richaudienceBidAdapter.js +++ b/modules/richaudienceBidAdapter.js @@ -4,6 +4,7 @@ import {BANNER, VIDEO} from '../src/mediaTypes'; import * as utils from '../src/utils'; const BIDDER_CODE = 'richaudience'; +let REFERER = ''; export const spec = { code: BIDDER_CODE, @@ -39,22 +40,22 @@ export const spec = { bidder: bid.bidder, bidderRequestId: bid.bidderRequestId, tagId: bid.adUnitCode, - sizes: bid.sizes.map(size => ({ - w: size[0], - h: size[1], - })), + sizes: raiGetSizes(bid), referer: (typeof bidderRequest.refererInfo.referer != 'undefined' ? encodeURIComponent(bidderRequest.refererInfo.referer) : null), numIframes: (typeof bidderRequest.refererInfo.numIframes != 'undefined' ? bidderRequest.refererInfo.numIframes : null), transactionId: bid.transactionId, timeout: config.getConfig('bidderTimeout'), + user: raiSetEids(bid) }; + REFERER = (typeof bidderRequest.refererInfo.referer != 'undefined' ? encodeURIComponent(bidderRequest.refererInfo.referer) : null) + + payload.gdpr_consent = ''; + payload.gdpr = null; + if (bidderRequest && bidderRequest.gdprConsent) { payload.gdpr_consent = bidderRequest.gdprConsent.consentString; - payload.gdpr = bidderRequest.gdprConsent.gdprApplies; // we're handling the undefined case server side - } else { - payload.gdpr_consent = ''; - payload.gdpr = null; + payload.gdpr = bidderRequest.gdprConsent.gdprApplies; } var payloadString = JSON.stringify(payload); @@ -76,34 +77,29 @@ export const spec = { */ interpretResponse: function (serverResponse, bidRequest) { const bidResponses = []; - + // try catch var response = serverResponse.body; + if (response) { + var bidResponse = { + requestId: JSON.parse(bidRequest.data).bidId, + cpm: response.cpm, + width: response.width, + height: response.height, + creativeId: response.creative_id, + mediaType: response.media_type, + netRevenue: response.netRevenue, + currency: response.currency, + ttl: response.ttl, + dealId: response.dealId, + }; - try { - if (response) { - var bidResponse = { - requestId: JSON.parse(bidRequest.data).bidId, - cpm: response.cpm, - width: response.width, - height: response.height, - creativeId: response.creative_id, - mediaType: response.media_type, - netRevenue: response.netRevenue, - currency: response.currency, - ttl: response.ttl, - dealId: response.dealId, - }; - - if (response.media_type === 'video') { - bidResponse.vastXml = response.vastXML; - } else { - bidResponse.ad = response.adm - } - - bidResponses.push(bidResponse); + if (response.media_type === 'video') { + bidResponse.vastXml = response.vastXML; + } else { + bidResponse.ad = response.adm } - } catch (error) { - utils.logError('Error while parsing Rich Audience response', error); + + bidResponses.push(bidResponse); } return bidResponses }, @@ -121,20 +117,60 @@ export const spec = { var rand = Math.floor(Math.random() * 9999999999); var syncUrl = ''; - if (gdprConsent && typeof gdprConsent.consentString === 'string') { - syncUrl = 'https://sync.richaudience.com/dcf3528a0b8aa83634892d50e91c306e/?ord=' + rand + '&pubconsent=' + gdprConsent.consentString + '&euconsent=' + gdprConsent.consentString; - } else { - syncUrl = 'https://sync.richaudience.com/dcf3528a0b8aa83634892d50e91c306e/?ord=' + rand; - } + gdprConsent && typeof gdprConsent.consentString === 'string' ? syncUrl = 'https://sync.richaudience.com/dcf3528a0b8aa83634892d50e91c306e/?ord=' + rand + '&pubconsent=' + gdprConsent.consentString + '&euconsent=' + gdprConsent.consentString : syncUrl = 'https://sync.richaudience.com/dcf3528a0b8aa83634892d50e91c306e/?ord=' + rand; if (syncOptions.iframeEnabled) { syncs.push({ type: 'iframe', url: syncUrl }); + } else if (syncOptions.pixelEnabled && REFERER != null) { + syncs.push({ + type: 'image', + url: `https://sync.richaudience.com/bf7c142f4339da0278e83698a02b0854/?euconsent=${gdprConsent.consentString}&referrer=${REFERER}` + }); } return syncs }, }; registerBidder(spec); + +function raiGetSizes(bid) { + let raiNewSizes; + if (bid.mediaTypes && bid.mediaTypes.banner && bid.mediaTypes.banner.sizes) { + raiNewSizes = bid.mediaTypes.banner.sizes + } else { + raiNewSizes = bid.sizes + } + if (raiNewSizes != null) { + return raiNewSizes.map(size => ({ + w: size[0], + h: size[1] + })); + } +} + +function raiSetEids(bid) { + let eids = []; + + if (bid && bid.userId) { + raiSetUserId(bid, eids, 'id5-sync.com', utils.deepAccess(bid, `userId.id5id`)); + raiSetUserId(bid, eids, 'pubcommon', utils.deepAccess(bid, `userId.pubcid`)); + raiSetUserId(bid, eids, 'criteo.com', utils.deepAccess(bid, `userId.criteoId`)); + raiSetUserId(bid, eids, 'liveramp.com', utils.deepAccess(bid, `userId.idl_env`)); + raiSetUserId(bid, eids, 'liveintent.com', utils.deepAccess(bid, `userId.lipb.lipbid`)); + raiSetUserId(bid, eids, 'adserver.org', utils.deepAccess(bid, `userId.tdid`)); + } + + return eids; +} + +function raiSetUserId(bid, eids, source, value) { + if (utils.isStr(value)) { + eids.push({ + userId: value, + source: source + }); + } +} diff --git a/test/spec/modules/richaudienceBidAdapter_spec.js b/test/spec/modules/richaudienceBidAdapter_spec.js index 16d67ce7ceb4..6c7030676c7e 100644 --- a/test/spec/modules/richaudienceBidAdapter_spec.js +++ b/test/spec/modules/richaudienceBidAdapter_spec.js @@ -25,7 +25,30 @@ describe('Richaudience adapter tests', function () { auctionId: '0cb3144c-d084-4686-b0d6-f5dbe917c563', bidRequestsCount: 1, bidderRequestId: '1858b7382993ca', - transactionId: '29df2112-348b-4961-8863-1b33684d95e6' + transactionId: '29df2112-348b-4961-8863-1b33684d95e6', + user: {} + }]; + + var DEFAULT_PARAMS_NEW_SIZES = [{ + adUnitCode: 'test-div', + bidId: '2c7c8e9c900244', + mediaTypes: { + banner: { + sizes: [ + [300, 250], [300, 600], [728, 90], [970, 250]] + } + }, + bidder: 'richaudience', + params: { + bidfloor: 0.5, + pid: 'ADb1f40rmi', + supplyType: 'site' + }, + auctionId: '0cb3144c-d084-4686-b0d6-f5dbe917c563', + bidRequestsCount: 1, + bidderRequestId: '1858b7382993ca', + transactionId: '29df2112-348b-4961-8863-1b33684d95e6', + user: {} }]; var DEFAULT_PARAMS_APP = [{ @@ -101,6 +124,17 @@ describe('Richaudience adapter tests', function () { } }; + var DEFAULT_PARAMS_GDPR = { + gdprConsent: { + consentString: 'BOZcQl_ObPFjWAeABAESCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NohBgA', + gdprApplies: true + }, + refererInfo: { + referer: 'http://domain.com', + numIframes: 0 + } + } + it('Verify build request', function () { config.setConfig({ 'currency': { @@ -108,7 +142,40 @@ describe('Richaudience adapter tests', function () { } }); + const request = spec.buildRequests(DEFAULT_PARAMS, DEFAULT_PARAMS_GDPR); + + expect(request[0]).to.have.property('method').and.to.equal('POST'); + const requestContent = JSON.parse(request[0].data); + expect(requestContent).to.have.property('sizes'); + expect(requestContent.sizes[0]).to.have.property('w').and.to.equal(300); + expect(requestContent.sizes[0]).to.have.property('h').and.to.equal(250); + expect(requestContent.sizes[1]).to.have.property('w').and.to.equal(300); + expect(requestContent.sizes[1]).to.have.property('h').and.to.equal(600); + expect(requestContent.sizes[2]).to.have.property('w').and.to.equal(728); + expect(requestContent.sizes[2]).to.have.property('h').and.to.equal(90); + expect(requestContent.sizes[3]).to.have.property('w').and.to.equal(970); + expect(requestContent.sizes[3]).to.have.property('h').and.to.equal(250); + }); + + it('Referer undefined', function() { + config.setConfig({ + 'currency': {'adServerCurrency': 'USD'} + }) + const request = spec.buildRequests(DEFAULT_PARAMS, { + gdprConsent: { + consentString: 'BOZcQl_ObPFjWAeABAESCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NohBgA', + gdprApplies: true + }, + refererInfo: {} + }) + const requestContent = JSON.parse(request[0].data); + expect(requestContent).to.have.property('referer').and.to.equal(null); + expect(requestContent).to.have.property('referer').and.to.equal(null); + }) + + it('Verify build request to prebid 3.0', function() { + const request = spec.buildRequests(DEFAULT_PARAMS_NEW_SIZES, { gdprConsent: { consentString: 'BOZcQl_ObPFjWAeABAESCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NohBgA', gdprApplies: true @@ -131,14 +198,18 @@ describe('Richaudience adapter tests', function () { expect(requestContent).to.have.property('bidderRequestId').and.to.equal('1858b7382993ca'); expect(requestContent).to.have.property('tagId').and.to.equal('test-div'); expect(requestContent).to.have.property('referer').and.to.equal('http%3A%2F%2Fdomain.com'); - expect(requestContent).to.have.property('sizes'); expect(requestContent.sizes[0]).to.have.property('w').and.to.equal(300); expect(requestContent.sizes[0]).to.have.property('h').and.to.equal(250); expect(requestContent.sizes[1]).to.have.property('w').and.to.equal(300); expect(requestContent.sizes[1]).to.have.property('h').and.to.equal(600); + expect(requestContent.sizes[2]).to.have.property('w').and.to.equal(728); + expect(requestContent.sizes[2]).to.have.property('h').and.to.equal(90); + expect(requestContent.sizes[3]).to.have.property('w').and.to.equal(970); + expect(requestContent.sizes[3]).to.have.property('h').and.to.equal(250); expect(requestContent).to.have.property('transactionId').and.to.equal('29df2112-348b-4961-8863-1b33684d95e6'); expect(requestContent).to.have.property('timeout').and.to.equal(3000); - }); + expect(requestContent).to.have.property('numIframes').and.to.equal(0); + }) describe('gdpr test', function () { it('Verify build request with GDPR', function () { @@ -153,31 +224,15 @@ describe('Richaudience adapter tests', function () { } }); - const request = spec.buildRequests(DEFAULT_PARAMS_WO_OPTIONAL, { - gdprConsent: { - consentString: 'BOZcQl_ObPFjWAeABAESCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NohBgA', - gdprApplies: true - }, - refererInfo: { - referer: 'http://domain.com', - numIframes: 0 - } - }); + const request = spec.buildRequests(DEFAULT_PARAMS_WO_OPTIONAL, DEFAULT_PARAMS_GDPR); const requestContent = JSON.parse(request[0].data); expect(requestContent).to.have.property('gdpr_consent').and.to.equal('BOZcQl_ObPFjWAeABAESCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NohBgA'); }); it('Verify adding ifa when supplyType equal to app', function () { - const request = spec.buildRequests(DEFAULT_PARAMS_APP, { - gdprConsent: { - consentString: 'BOZcQl_ObPFjWAeABAESCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NohBgA', - gdprApplies: true - }, - refererInfo: { - referer: 'http://domain.com', - numIframes: 0 - } - }); + const request = spec.buildRequests(DEFAULT_PARAMS_APP, DEFAULT_PARAMS_GDPR); + const requestContent = JSON.parse(request[0].data); + expect(requestContent).to.have.property('gdpr_consent').and.to.equal('BOZcQl_ObPFjWAeABAESCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NohBgA'); }); it('Verify build request with GDPR without gdprApplies', function () { @@ -206,6 +261,224 @@ describe('Richaudience adapter tests', function () { }); }); + describe('UID test', function () { + pbjs.setConfig({ + consentManagement: { + cmpApi: 'iab', + timeout: 5000, + allowAuctionWithoutConsent: true + } + }); + it('Verify build id5', function () { + DEFAULT_PARAMS_WO_OPTIONAL[0].userId = {}; + DEFAULT_PARAMS_WO_OPTIONAL[0].userId.id5id = 'id5-user-id'; + + var request = spec.buildRequests(DEFAULT_PARAMS_WO_OPTIONAL, DEFAULT_PARAMS_GDPR); + var requestContent = JSON.parse(request[0].data); + + expect(requestContent.user).to.deep.equal([{ + 'userId': 'id5-user-id', + 'source': 'id5-sync.com' + }]); + + var request; + DEFAULT_PARAMS_WO_OPTIONAL[0].userId = {}; + DEFAULT_PARAMS_WO_OPTIONAL[0].userId.id5id = 1; + request = spec.buildRequests(DEFAULT_PARAMS_WO_OPTIONAL, DEFAULT_PARAMS_GDPR); + var requestContent = JSON.parse(request[0].data); + + expect(requestContent.user.eids).to.equal(undefined); + + DEFAULT_PARAMS_WO_OPTIONAL[0].userId.id5id = []; + request = spec.buildRequests(DEFAULT_PARAMS_WO_OPTIONAL, DEFAULT_PARAMS_GDPR); + requestContent = JSON.parse(request[0].data); + expect(requestContent.user.eids).to.equal(undefined); + + DEFAULT_PARAMS_WO_OPTIONAL[0].userId.id5id = null; + request = spec.buildRequests(DEFAULT_PARAMS_WO_OPTIONAL, DEFAULT_PARAMS_GDPR); + requestContent = JSON.parse(request[0].data); + expect(requestContent.user.eids).to.equal(undefined); + + DEFAULT_PARAMS_WO_OPTIONAL[0].userId.id5id = {}; + request = spec.buildRequests(DEFAULT_PARAMS_WO_OPTIONAL, DEFAULT_PARAMS_GDPR); + requestContent = JSON.parse(request[0].data); + expect(requestContent.user.eids).to.equal(undefined); + }); + + it('Verify build pubCommonId', function () { + DEFAULT_PARAMS_WO_OPTIONAL[0].userId = {}; + DEFAULT_PARAMS_WO_OPTIONAL[0].userId.pubcid = 'pub_common_user_id'; + + var request = spec.buildRequests(DEFAULT_PARAMS_WO_OPTIONAL, DEFAULT_PARAMS_GDPR); + var requestContent = JSON.parse(request[0].data); + + expect(requestContent.user).to.deep.equal([{ + 'userId': 'pub_common_user_id', + 'source': 'pubcommon' + }]); + + var request; + DEFAULT_PARAMS_WO_OPTIONAL[0].userId = {}; + DEFAULT_PARAMS_WO_OPTIONAL[0].userId.pubcid = 1; + request = spec.buildRequests(DEFAULT_PARAMS_WO_OPTIONAL, DEFAULT_PARAMS_GDPR); + var requestContent = JSON.parse(request[0].data); + expect(requestContent.user.eids).to.equal(undefined); + + DEFAULT_PARAMS_WO_OPTIONAL[0].userId.pubcid = []; + request = spec.buildRequests(DEFAULT_PARAMS_WO_OPTIONAL, DEFAULT_PARAMS_GDPR); + requestContent = JSON.parse(request[0].data); + expect(requestContent.user.eids).to.equal(undefined); + + DEFAULT_PARAMS_WO_OPTIONAL[0].userId.pubcid = null; + request = spec.buildRequests(DEFAULT_PARAMS_WO_OPTIONAL, DEFAULT_PARAMS_GDPR); + requestContent = JSON.parse(request[0].data); + expect(requestContent.user.eids).to.equal(undefined); + + DEFAULT_PARAMS_WO_OPTIONAL[0].userId.pubcid = {}; + request = spec.buildRequests(DEFAULT_PARAMS_WO_OPTIONAL, DEFAULT_PARAMS_GDPR); + requestContent = JSON.parse(request[0].data); + expect(requestContent.user.eids).to.equal(undefined); + }); + + it('Verify build criteoId', function () { + DEFAULT_PARAMS_WO_OPTIONAL[0].userId = {}; + DEFAULT_PARAMS_WO_OPTIONAL[0].userId.criteoId = 'criteo-user-id'; + + var request = spec.buildRequests(DEFAULT_PARAMS_WO_OPTIONAL, DEFAULT_PARAMS_GDPR); + var requestContent = JSON.parse(request[0].data); + + expect(requestContent.user).to.deep.equal([{ + 'userId': 'criteo-user-id', + 'source': 'criteo.com' + }]); + + var request; + DEFAULT_PARAMS_WO_OPTIONAL[0].userId = {}; + DEFAULT_PARAMS_WO_OPTIONAL[0].userId.criteoId = 1; + request = spec.buildRequests(DEFAULT_PARAMS_WO_OPTIONAL, DEFAULT_PARAMS_GDPR); + var requestContent = JSON.parse(request[0].data); + expect(requestContent.user.eids).to.equal(undefined); + + DEFAULT_PARAMS_WO_OPTIONAL[0].userId.criteoId = []; + request = spec.buildRequests(DEFAULT_PARAMS_WO_OPTIONAL, DEFAULT_PARAMS_GDPR); + requestContent = JSON.parse(request[0].data); + expect(requestContent.user.eids).to.equal(undefined); + + DEFAULT_PARAMS_WO_OPTIONAL[0].userId.criteoId = null; + request = spec.buildRequests(DEFAULT_PARAMS_WO_OPTIONAL, DEFAULT_PARAMS_GDPR); + requestContent = JSON.parse(request[0].data); + expect(requestContent.user.eids).to.equal(undefined); + + DEFAULT_PARAMS_WO_OPTIONAL[0].userId.criteoId = {}; + request = spec.buildRequests(DEFAULT_PARAMS_WO_OPTIONAL, DEFAULT_PARAMS_GDPR); + requestContent = JSON.parse(request[0].data); + expect(requestContent.user.eids).to.equal(undefined); + }); + + it('Verify build identityLink', function () { + DEFAULT_PARAMS_WO_OPTIONAL[0].userId = {}; + DEFAULT_PARAMS_WO_OPTIONAL[0].userId.idl_env = 'identity-link-user-id'; + + var request = spec.buildRequests(DEFAULT_PARAMS_WO_OPTIONAL, DEFAULT_PARAMS_GDPR); + var requestContent = JSON.parse(request[0].data); + + expect(requestContent.user).to.deep.equal([{ + 'userId': 'identity-link-user-id', + 'source': 'liveramp.com' + }]); + + var request; + DEFAULT_PARAMS_WO_OPTIONAL[0].userId = {}; + DEFAULT_PARAMS_WO_OPTIONAL[0].userId.idl_env = 1; + request = spec.buildRequests(DEFAULT_PARAMS_WO_OPTIONAL, DEFAULT_PARAMS_GDPR); + var requestContent = JSON.parse(request[0].data); + expect(requestContent.user.eids).to.equal(undefined); + + DEFAULT_PARAMS_WO_OPTIONAL[0].userId.criteoId = []; + request = spec.buildRequests(DEFAULT_PARAMS_WO_OPTIONAL, DEFAULT_PARAMS_GDPR); + requestContent = JSON.parse(request[0].data); + expect(requestContent.user.eids).to.equal(undefined); + + DEFAULT_PARAMS_WO_OPTIONAL[0].userId.idl_env = null; + request = spec.buildRequests(DEFAULT_PARAMS_WO_OPTIONAL, DEFAULT_PARAMS_GDPR); + requestContent = JSON.parse(request[0].data); + expect(requestContent.user.eids).to.equal(undefined); + + DEFAULT_PARAMS_WO_OPTIONAL[0].userId.idl_env = {}; + request = spec.buildRequests(DEFAULT_PARAMS_WO_OPTIONAL, DEFAULT_PARAMS_GDPR); + requestContent = JSON.parse(request[0].data); + expect(requestContent.user.eids).to.equal(undefined); + }); + it('Verify build liveIntentId', function () { + DEFAULT_PARAMS_WO_OPTIONAL[0].userId = {}; + DEFAULT_PARAMS_WO_OPTIONAL[0].userId.idl_env = 'identity-link-user-id'; + + var request = spec.buildRequests(DEFAULT_PARAMS_WO_OPTIONAL, DEFAULT_PARAMS_GDPR); + var requestContent = JSON.parse(request[0].data) + + expect(requestContent.user).to.deep.equal([{ + 'userId': 'identity-link-user-id', + 'source': 'liveramp.com' + }]); + + var request; + DEFAULT_PARAMS_WO_OPTIONAL[0].userId = {}; + DEFAULT_PARAMS_WO_OPTIONAL[0].userId.idl_env = 1; + request = spec.buildRequests(DEFAULT_PARAMS_WO_OPTIONAL, DEFAULT_PARAMS_GDPR); + var requestContent = JSON.parse(request[0].data); + expect(requestContent.user.eids).to.equal(undefined); + + DEFAULT_PARAMS_WO_OPTIONAL[0].userId.criteoId = []; + request = spec.buildRequests(DEFAULT_PARAMS_WO_OPTIONAL, DEFAULT_PARAMS_GDPR); + requestContent = JSON.parse(request[0].data); + expect(requestContent.user.eids).to.equal(undefined); + + DEFAULT_PARAMS_WO_OPTIONAL[0].userId.idl_env = null; + request = spec.buildRequests(DEFAULT_PARAMS_WO_OPTIONAL, DEFAULT_PARAMS_GDPR); + requestContent = JSON.parse(request[0].data); + expect(requestContent.user.eids).to.equal(undefined); + + DEFAULT_PARAMS_WO_OPTIONAL[0].userId.idl_env = {}; + request = spec.buildRequests(DEFAULT_PARAMS_WO_OPTIONAL, DEFAULT_PARAMS_GDPR); + requestContent = JSON.parse(request[0].data); + expect(requestContent.user.eids).to.equal(undefined); + }); + it('Verify build TradeDesk', function () { + DEFAULT_PARAMS_WO_OPTIONAL[0].userId = {}; + DEFAULT_PARAMS_WO_OPTIONAL[0].userId.tdid = 'tdid-user-id'; + + var request = spec.buildRequests(DEFAULT_PARAMS_WO_OPTIONAL, DEFAULT_PARAMS_GDPR); + var requestContent = JSON.parse(request[0].data) + + expect(requestContent.user).to.deep.equal([{ + 'userId': 'tdid-user-id', + 'source': 'adserver.org' + }]); + + request; + DEFAULT_PARAMS_WO_OPTIONAL[0].userId = {}; + DEFAULT_PARAMS_WO_OPTIONAL[0].userId.idl_env = 1; + request = spec.buildRequests(DEFAULT_PARAMS_WO_OPTIONAL, DEFAULT_PARAMS_GDPR); + requestContent = JSON.parse(request[0].data); + expect(requestContent.user.eids).to.equal(undefined); + + DEFAULT_PARAMS_WO_OPTIONAL[0].userId.criteoId = []; + request = spec.buildRequests(DEFAULT_PARAMS_WO_OPTIONAL, DEFAULT_PARAMS_GDPR); + requestContent = JSON.parse(request[0].data); + expect(requestContent.user.eids).to.equal(undefined); + + DEFAULT_PARAMS_WO_OPTIONAL[0].userId.idl_env = null; + request = spec.buildRequests(DEFAULT_PARAMS_WO_OPTIONAL, DEFAULT_PARAMS_GDPR); + requestContent = JSON.parse(request[0].data); + expect(requestContent.user.eids).to.equal(undefined); + + DEFAULT_PARAMS_WO_OPTIONAL[0].userId.idl_env = {}; + request = spec.buildRequests(DEFAULT_PARAMS_WO_OPTIONAL, DEFAULT_PARAMS_GDPR); + requestContent = JSON.parse(request[0].data); + expect(requestContent.user.eids).to.equal(undefined); + }); + }); + it('Verify interprete response', function () { const request = spec.buildRequests(DEFAULT_PARAMS, { gdprConsent: { @@ -343,5 +616,39 @@ describe('Richaudience adapter tests', function () { iframeEnabled: true }, [], {consentString: '', gdprApplies: false}); expect(syncs).to.have.lengthOf(1); + + syncs = spec.getUserSyncs({ + iframeEnabled: false + }, [], {consentString: '', gdprApplies: true}); + expect(syncs).to.have.lengthOf(0); + + pbjs.setConfig({ + consentManagement: { + cmpApi: 'iab', + timeout: 5000, + allowAuctionWithoutConsent: true, + pixelEnabled: true + } + }); + + syncs = spec.getUserSyncs({ + pixelEnabled: true + }, [], { + consentString: 'BOZcQl_ObPFjWAeABAESCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NohBgA', + referer: 'http://domain.com', + gdprApplies: true + }) + expect(syncs).to.have.lengthOf(1); + expect(syncs[0].type).to.equal('image'); + + syncs = spec.getUserSyncs({ + pixelEnabled: true + }, [], { + consentString: '', + referer: 'http://domain.com', + gdprApplies: true + }) + expect(syncs).to.have.lengthOf(1); + expect(syncs[0].type).to.equal('image'); }); }); From 2a5cfaa6c7e1274090ec72d649442dc14aa6bf29 Mon Sep 17 00:00:00 2001 From: Bill Newman Date: Tue, 10 Dec 2019 16:56:54 +0200 Subject: [PATCH 12/41] CCPA and Schain support (#4537) * add video&native traffic colossus ssp * Native obj validation * Native obj validation #2 * Added size field in requests * fixed test * fix merge conflicts * move to 3.0 * move to 3.0 * fix IE11 new URL issue * fix IE11 new URL issue * fix IE11 new URL issue * https for 3.0 * add https test * add ccp and schain features * fix test * sync with upstream, fix conflicts * Update colossussspBidAdapter.js remove commented code * Update colossussspBidAdapter.js lint fix --- modules/colossussspBidAdapter.js | 9 ++++ .../modules/colossussspBidAdapter_spec.js | 41 +++++++++++++++++-- 2 files changed, 46 insertions(+), 4 deletions(-) diff --git a/modules/colossussspBidAdapter.js b/modules/colossussspBidAdapter.js index 9f02f5057c14..adcd5df9fb62 100644 --- a/modules/colossussspBidAdapter.js +++ b/modules/colossussspBidAdapter.js @@ -63,6 +63,12 @@ export const spec = { 'placements': placements }; + if (bidderRequest) { + if (bidderRequest.uspConsent) { + request.ccpa = bidderRequest.uspConsent; + } + } + for (let i = 0; i < validBidRequests.length; i++) { let bid = validBidRequests[i]; let traff = bid.params.traffic || BANNER @@ -72,6 +78,9 @@ export const spec = { sizes: bid.mediaTypes[traff].sizes, traffic: traff }; + if (bid.schain) { + placement.schain = bid.schain; + } placements.push(placement); } return { diff --git a/test/spec/modules/colossussspBidAdapter_spec.js b/test/spec/modules/colossussspBidAdapter_spec.js index f50422206107..9ed2dbe6e6b6 100644 --- a/test/spec/modules/colossussspBidAdapter_spec.js +++ b/test/spec/modules/colossussspBidAdapter_spec.js @@ -16,8 +16,36 @@ describe('ColossussspAdapter', function () { sizes: [[300, 250]] } }, - transactionId: '3bb2f6da-87a6-4029-aeb0-bfe951372e62' + transactionId: '3bb2f6da-87a6-4029-aeb0-bfe951372e62', + schain: { + ver: '1.0', + complete: 1, + nodes: [ + { + asi: 'example.com', + sid: '0', + hp: 1, + rid: 'bidrequestid', + // name: 'alladsallthetime', + domain: 'example.com' + } + ] + } }; + let bidderRequest = { + bidderCode: 'colossus', + auctionId: 'fffffff-ffff-ffff-ffff-ffffffffffff', + bidderRequestId: 'ffffffffffffff', + start: 1472239426002, + auctionStart: 1472239426000, + timeout: 5000, + uspConsent: '1YN-', + refererInfo: { + referer: 'http://www.example.com', + reachedTop: true, + }, + bids: [bid] + } describe('isBidRequestValid', function () { it('Should return true when placement_id can be cast to a number', function () { @@ -30,7 +58,7 @@ describe('ColossussspAdapter', function () { }); describe('buildRequests', function () { - let serverRequest = spec.buildRequests([bid]); + let serverRequest = spec.buildRequests([bid], bidderRequest); it('Creates a ServerRequest object with method, URL and data', function () { expect(serverRequest).to.exist; expect(serverRequest.method).to.exist; @@ -43,10 +71,14 @@ describe('ColossussspAdapter', function () { it('Returns valid URL', function () { expect(serverRequest.url).to.equal('https://colossusssp.com/?c=o&m=multi'); }); + it('Should contain ccpa', function() { + expect(serverRequest.data.ccpa).to.be.an('string') + }) + it('Returns valid data if array of bids is valid', function () { let data = serverRequest.data; expect(data).to.be.an('object'); - expect(data).to.have.all.keys('deviceWidth', 'deviceHeight', 'language', 'secure', 'host', 'page', 'placements'); + expect(data).to.have.all.keys('deviceWidth', 'deviceHeight', 'language', 'secure', 'host', 'page', 'placements', 'ccpa'); expect(data.deviceWidth).to.be.a('number'); expect(data.deviceHeight).to.be.a('number'); expect(data.language).to.be.a('string'); @@ -56,7 +88,8 @@ describe('ColossussspAdapter', function () { let placements = data['placements']; for (let i = 0; i < placements.length; i++) { let placement = placements[i]; - expect(placement).to.have.all.keys('placementId', 'bidId', 'traffic', 'sizes'); + expect(placement).to.have.all.keys('placementId', 'bidId', 'traffic', 'sizes', 'schain'); + expect(placement.schain).to.be.an('object') expect(placement.placementId).to.be.a('number'); expect(placement.bidId).to.be.a('string'); expect(placement.traffic).to.be.a('string'); From 847b35357596cac7b55f8777f1b1e4eb6b22eda3 Mon Sep 17 00:00:00 2001 From: r-schweitzer <50628828+r-schweitzer@users.noreply.github.com> Date: Tue, 10 Dec 2019 10:25:28 -0500 Subject: [PATCH 13/41] added check in register syncs to not sync aliased bidders (#4435) --- src/adapters/bidderFactory.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/adapters/bidderFactory.js b/src/adapters/bidderFactory.js index 18408e78d179..602d9e53b03b 100644 --- a/src/adapters/bidderFactory.js +++ b/src/adapters/bidderFactory.js @@ -331,7 +331,7 @@ export function newBidder(spec) { }); function registerSyncs(responses, gdprConsent, uspConsent) { - if (spec.getUserSyncs) { + if (spec.getUserSyncs && !adapterManager.aliasRegistry[spec.code]) { let filterConfig = config.getConfig('userSync.filterSettings'); let syncs = spec.getUserSyncs({ iframeEnabled: !!(config.getConfig('userSync.iframeEnabled') || (filterConfig && (filterConfig.iframe || filterConfig.all))), From 99a1822e966b1d9750dd78a73d1aa288e27efddc Mon Sep 17 00:00:00 2001 From: susyt Date: Tue, 10 Dec 2019 07:47:09 -0800 Subject: [PATCH 14/41] GumGum: adds inScreenPubID param (#4490) * adds schain param * adds pubId param depending on inScreen val type * sets pubId param if inScreenPubID is present * update test * fixed test description --- modules/gumgumBidAdapter.js | 4 ++++ test/spec/modules/gumgumBidAdapter_spec.js | 11 +++++++++++ 2 files changed, 15 insertions(+) diff --git a/modules/gumgumBidAdapter.js b/modules/gumgumBidAdapter.js index df6ca1971ee0..2325e1bc4483 100644 --- a/modules/gumgumBidAdapter.js +++ b/modules/gumgumBidAdapter.js @@ -176,6 +176,10 @@ function buildRequests (validBidRequests, bidderRequest) { if (params.bidfloor) { data.fp = params.bidfloor; } + if (params.inScreenPubID) { + data.pubId = params.inScreenPubID; + data.pi = 2; + } if (params.inScreen) { data.t = params.inScreen; data.pi = 2; diff --git a/test/spec/modules/gumgumBidAdapter_spec.js b/test/spec/modules/gumgumBidAdapter_spec.js index 97897a11ed3b..cbd71cc82f06 100644 --- a/test/spec/modules/gumgumBidAdapter_spec.js +++ b/test/spec/modules/gumgumBidAdapter_spec.js @@ -118,6 +118,17 @@ describe('gumgumAdapter', function () { expect(bidRequest.data).to.include.any.keys('t'); expect(bidRequest.data).to.include.any.keys('fp'); }); + it('should send pubId if inScreenPubID param is specified', function () { + const request = Object.assign({}, bidRequests[0]); + delete request.params; + request.params = { + 'inScreenPubID': 123 + }; + const bidRequest = spec.buildRequests([request])[0]; + expect(bidRequest.data).to.include.any.keys('pubId'); + expect(bidRequest.data.pubId).to.equal(request.params.inScreenPubID); + expect(bidRequest.data).to.not.include.any.keys('t'); + }); it('should correctly set the request paramters depending on params field', function () { const request = Object.assign({}, bidRequests[0]); delete request.params; From 5b57f48a19c659eba50e0948b5f41138bb630047 Mon Sep 17 00:00:00 2001 From: Paul Yang Date: Tue, 10 Dec 2019 07:54:30 -0800 Subject: [PATCH 15/41] Use 'pubcid.org' as the source for pubcid in extended IDs (#4561) --- modules/prebidServerBidAdapter/index.js | 6 +++--- test/spec/modules/prebidServerBidAdapter_spec.js | 16 ++++++++-------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/modules/prebidServerBidAdapter/index.js b/modules/prebidServerBidAdapter/index.js index 3f0150aca41e..b7f3f082ccec 100644 --- a/modules/prebidServerBidAdapter/index.js +++ b/modules/prebidServerBidAdapter/index.js @@ -646,7 +646,7 @@ const OPEN_RTB_PROTOCOL = { }); if (!imps.length) { - utils.logError('Request to Prebid Server rejected due to invalid media type(s) in adUnit.') + utils.logError('Request to Prebid Server rejected due to invalid media type(s) in adUnit.'); return; } const request = { @@ -721,7 +721,7 @@ const OPEN_RTB_PROTOCOL = { if (bidUserId.pubcid) { request.user.ext.eids.push({ - source: 'pubcommon', + source: 'pubcid.org', uids: [{ id: bidUserId.pubcid, }] @@ -955,7 +955,7 @@ const isOpenRtb = () => { const endpoint = (_s2sConfig && _s2sConfig.endpoint) || ''; return ~endpoint.indexOf(OPEN_RTB_PATH); -} +}; /* * Returns the required protocol adapter to communicate with the configured diff --git a/test/spec/modules/prebidServerBidAdapter_spec.js b/test/spec/modules/prebidServerBidAdapter_spec.js index cdb674509cbe..c198502d4b3c 100644 --- a/test/spec/modules/prebidServerBidAdapter_spec.js +++ b/test/spec/modules/prebidServerBidAdapter_spec.js @@ -580,7 +580,7 @@ describe('S2S Adapter', function () { it('should not add outstrean without renderer', function () { let ortb2Config = utils.deepClone(CONFIG); - ortb2Config.endpoint = 'https://prebid.adnxs.com/pbs/v1/openrtb2/auction' + ortb2Config.endpoint = 'https://prebid.adnxs.com/pbs/v1/openrtb2/auction'; config.setConfig({ s2sConfig: ortb2Config }); adapter.callBids(OUTSTREAM_VIDEO_REQUEST, BID_REQUESTS, addBidResponse, done, ajax); @@ -611,7 +611,7 @@ describe('S2S Adapter', function () { it('adds gdpr consent information to ortb2 request depending on presence of module', function () { let ortb2Config = utils.deepClone(CONFIG); - ortb2Config.endpoint = 'https://prebid.adnxs.com/pbs/v1/openrtb2/auction' + ortb2Config.endpoint = 'https://prebid.adnxs.com/pbs/v1/openrtb2/auction'; let consentConfig = { consentManagement: { cmpApi: 'iab' }, s2sConfig: ortb2Config }; config.setConfig(consentConfig); @@ -710,7 +710,7 @@ describe('S2S Adapter', function () { it('is added to ortb2 request when in bidRequest', function () { let ortb2Config = utils.deepClone(CONFIG); - ortb2Config.endpoint = 'https://prebid.adnxs.com/pbs/v1/openrtb2/auction' + ortb2Config.endpoint = 'https://prebid.adnxs.com/pbs/v1/openrtb2/auction'; config.setConfig({ s2sConfig: ortb2Config }); let uspBidRequest = utils.deepClone(BID_REQUESTS); @@ -755,7 +755,7 @@ describe('S2S Adapter', function () { it('is added to ortb2 request when in bidRequest', function () { let ortb2Config = utils.deepClone(CONFIG); - ortb2Config.endpoint = 'https://prebid.adnxs.com/pbs/v1/openrtb2/auction' + ortb2Config.endpoint = 'https://prebid.adnxs.com/pbs/v1/openrtb2/auction'; config.setConfig({ s2sConfig: ortb2Config }); let consentBidRequest = utils.deepClone(BID_REQUESTS); @@ -984,7 +984,7 @@ describe('S2S Adapter', function () { const _config = { s2sConfig: s2sConfig, - } + }; config.setConfig(_config); adapter.callBids(REQUEST, BID_REQUESTS, addBidResponse, done, ajax); @@ -1200,8 +1200,8 @@ describe('S2S Adapter', function () { expect(requestBid.user.ext.eids.filter(eid => eid.source === 'adserver.org')[0].uids[0].id).is.equal('abc123'); expect(requestBid.user.ext.eids.filter(eid => eid.source === 'criteo.com')).is.not.empty; expect(requestBid.user.ext.eids.filter(eid => eid.source === 'criteo.com')[0].uids[0].id).is.equal('44VmRDeUE3ZGJ5MzRkRVJHU3BIUlJ6TlFPQUFU'); - expect(requestBid.user.ext.eids.filter(eid => eid.source === 'pubcommon')).is.not.empty; - expect(requestBid.user.ext.eids.filter(eid => eid.source === 'pubcommon')[0].uids[0].id).is.equal('1234'); + expect(requestBid.user.ext.eids.filter(eid => eid.source === 'pubcid.org')).is.not.empty; + expect(requestBid.user.ext.eids.filter(eid => eid.source === 'pubcid.org')[0].uids[0].id).is.equal('1234'); expect(requestBid.user.ext.eids.filter(eid => eid.source === 'parrable.com')).is.not.empty; expect(requestBid.user.ext.eids.filter(eid => eid.source === 'parrable.com')[0].uids[0].id).is.equal('01.1563917337.test-eid'); expect(requestBid.user.ext.eids.filter(eid => eid.source === 'liveintent.com')).is.not.empty; @@ -1768,7 +1768,7 @@ describe('S2S Adapter', function () { const _config = { s2sConfig: s2sConfig, - } + }; config.setConfig(_config); config.setConfig({ s2sConfig: CONFIG }); From df35628acc0dc42fab81a7e7c900788ad4e39749 Mon Sep 17 00:00:00 2001 From: Alex Khmelnitsky Date: Tue, 10 Dec 2019 18:03:42 +0200 Subject: [PATCH 16/41] added additional ad unit counters (#4448) --- src/adUnits.js | 72 ++++++++++++++++++++++++++++++---- src/adapterManager.js | 5 ++- src/prebid.js | 4 +- test/spec/unit/adUnits_spec.js | 48 +++++++++++++++++------ 4 files changed, 108 insertions(+), 21 deletions(-) diff --git a/src/adUnits.js b/src/adUnits.js index bbdc82b60736..aa88cf6eac5f 100644 --- a/src/adUnits.js +++ b/src/adUnits.js @@ -2,15 +2,47 @@ import { deepAccess } from './utils'; let adUnits = {}; +function ensureAdUnit(adunit, bidderCode) { + let adUnit = adUnits[adunit] = adUnits[adunit] || { bidders: {} }; + if (bidderCode) { + return adUnit.bidders[bidderCode] = adUnit.bidders[bidderCode] || {} + } + return adUnit; +} + +function incrementAdUnitCount(adunit, counter, bidderCode) { + let adUnit = ensureAdUnit(adunit, bidderCode); + adUnit[counter] = (adUnit[counter] || 0) + 1; + return adUnit[counter]; +} + /** * Increments and returns current Adunit counter * @param {string} adunit id * @returns {number} current adunit count */ -function incrementCounter(adunit) { - adUnits[adunit] = adUnits[adunit] || {}; - adUnits[adunit].counter = (deepAccess(adUnits, `${adunit}.counter`) + 1) || 1; - return adUnits[adunit].counter; +function incrementRequestsCounter(adunit) { + return incrementAdUnitCount(adunit, 'requestsCounter'); +} + +/** + * Increments and returns current Adunit requests counter for a bidder + * @param {string} adunit id + * @param {string} bidderCode code + * @returns {number} current adunit bidder requests count + */ +function incrementBidderRequestsCounter(adunit, bidderCode) { + return incrementAdUnitCount(adunit, 'requestsCounter', bidderCode); +} + +/** + * Increments and returns current Adunit wins counter for a bidder + * @param {string} adunit id + * @param {string} bidderCode code + * @returns {number} current adunit bidder requests count + */ +function incrementBidderWinsCounter(adunit, bidderCode) { + return incrementAdUnitCount(adunit, 'winsCounter', bidderCode); } /** @@ -18,8 +50,28 @@ function incrementCounter(adunit) { * @param {string} adunit id * @returns {number} current adunit count */ -function getCounter(adunit) { - return deepAccess(adUnits, `${adunit}.counter`) || 0; +function getRequestsCounter(adunit) { + return deepAccess(adUnits, `${adunit}.requestsCounter`) || 0; +} + +/** + * Returns current Adunit requests counter for a specific bidder code + * @param {string} adunit id + * @param {string} bidder code + * @returns {number} current adunit bidder requests count + */ +function getBidderRequestsCounter(adunit, bidder) { + return deepAccess(adUnits, `${adunit}.bidders.${bidder}.requestsCounter`) || 0; +} + +/** + * Returns current Adunit requests counter for a specific bidder code + * @param {string} adunit id + * @param {string} bidder code + * @returns {number} current adunit bidder requests count + */ +function getBidderWinsCounter(adunit, bidder) { + return deepAccess(adUnits, `${adunit}.bidders.${bidder}.winsCounter`) || 0; } /** @@ -27,8 +79,12 @@ function getCounter(adunit) { * @module adunitCounter */ let adunitCounter = { - incrementCounter, - getCounter + incrementRequestsCounter, + incrementBidderRequestsCounter, + incrementBidderWinsCounter, + getRequestsCounter, + getBidderRequestsCounter, + getBidderWinsCounter } export { adunitCounter }; diff --git a/src/adapterManager.js b/src/adapterManager.js index 4f5f63534a4b..f4b63a4d58b1 100644 --- a/src/adapterManager.js +++ b/src/adapterManager.js @@ -100,7 +100,9 @@ function getBids({bidderCode, auctionId, bidderRequestId, adUnits, labels, src}) bidderRequestId, auctionId, src, - bidRequestsCount: adunitCounter.getCounter(adUnit.code), + bidRequestsCount: adunitCounter.getRequestsCounter(adUnit.code), + bidderRequestsCount: adunitCounter.getBidderRequestsCounter(adUnit.code, bid.bidder), + bidderWinsCount: adunitCounter.getBidderWinsCounter(adUnit.code, bid.bidder), })); } return bids; @@ -518,6 +520,7 @@ adapterManager.callTimedOutBidders = function(adUnits, timedOutBidders, cbTimeou adapterManager.callBidWonBidder = function(bidder, bid, adUnits) { // Adding user configured params to bidWon event data bid.params = utils.getUserConfiguredParams(adUnits, bid.adUnitCode, bid.bidder); + adunitCounter.incrementBidderWinsCounter(bid.adUnitCode, bid.bidder); tryCallBidderMethod(bidder, 'onBidWon', bid); }; diff --git a/src/prebid.js b/src/prebid.js index 44649d7d444c..20d93372837d 100644 --- a/src/prebid.js +++ b/src/prebid.js @@ -456,9 +456,11 @@ $$PREBID_GLOBAL$$.requestBids = hook('async', function ({ bidsBackHandler, timeo // drop the bidder from the ad unit if it's not compatible utils.logWarn(utils.unsupportedBidderMessage(adUnit, bidder)); adUnit.bids = adUnit.bids.filter(bid => bid.bidder !== bidder); + } else { + adunitCounter.incrementBidderRequestsCounter(adUnit.code, bidder); } }); - adunitCounter.incrementCounter(adUnit.code); + adunitCounter.incrementRequestsCounter(adUnit.code); }); if (!adUnits || adUnits.length === 0) { diff --git a/test/spec/unit/adUnits_spec.js b/test/spec/unit/adUnits_spec.js index ff77315ba4ad..fb666feb9b8b 100644 --- a/test/spec/unit/adUnits_spec.js +++ b/test/spec/unit/adUnits_spec.js @@ -4,20 +4,46 @@ import { adunitCounter } from 'src/adUnits'; describe('Adunit Counter', function () { const ADUNIT_ID_1 = 'test1'; const ADUNIT_ID_2 = 'test2'; + const BIDDER_ID_1 = 'bidder1'; + const BIDDER_ID_2 = 'bidder2'; - it('increments and checks counter of adunit 1', function () { - adunitCounter.incrementCounter(ADUNIT_ID_1); - expect(adunitCounter.getCounter(ADUNIT_ID_1)).to.be.equal(1); + it('increments and checks requests counter of adunit 1', function () { + adunitCounter.incrementRequestsCounter(ADUNIT_ID_1); + expect(adunitCounter.getRequestsCounter(ADUNIT_ID_1)).to.be.equal(1); }); - it('checks counter of adunit 2', function () { - expect(adunitCounter.getCounter(ADUNIT_ID_2)).to.be.equal(0); + it('checks requests counter of adunit 2', function () { + expect(adunitCounter.getRequestsCounter(ADUNIT_ID_2)).to.be.equal(0); }); - it('increments and checks counter of adunit 1', function () { - adunitCounter.incrementCounter(ADUNIT_ID_1); - expect(adunitCounter.getCounter(ADUNIT_ID_1)).to.be.equal(2); + it('increments and checks requests counter of adunit 1', function () { + adunitCounter.incrementRequestsCounter(ADUNIT_ID_1); + expect(adunitCounter.getRequestsCounter(ADUNIT_ID_1)).to.be.equal(2); }); - it('increments and checks counter of adunit 2', function () { - adunitCounter.incrementCounter(ADUNIT_ID_2); - expect(adunitCounter.getCounter(ADUNIT_ID_2)).to.be.equal(1); + it('increments and checks requests counter of adunit 2', function () { + adunitCounter.incrementRequestsCounter(ADUNIT_ID_2); + expect(adunitCounter.getRequestsCounter(ADUNIT_ID_2)).to.be.equal(1); + }); + it('increments and checks requests counter of adunit 1 for bidder 1', function () { + adunitCounter.incrementBidderRequestsCounter(ADUNIT_ID_1, BIDDER_ID_1); + expect(adunitCounter.getBidderRequestsCounter(ADUNIT_ID_1, BIDDER_ID_1)).to.be.equal(1); + }); + it('increments and checks requests counter of adunit 1 for bidder 2', function () { + adunitCounter.incrementBidderRequestsCounter(ADUNIT_ID_1, BIDDER_ID_2); + expect(adunitCounter.getBidderRequestsCounter(ADUNIT_ID_1, BIDDER_ID_2)).to.be.equal(1); + }); + it('increments and checks requests counter of adunit 1 for bidder 1', function () { + adunitCounter.incrementBidderRequestsCounter(ADUNIT_ID_1, BIDDER_ID_1); + expect(adunitCounter.getBidderRequestsCounter(ADUNIT_ID_1, BIDDER_ID_1)).to.be.equal(2); + }); + it('increments and checks wins counter of adunit 1 for bidder 1', function () { + adunitCounter.incrementBidderWinsCounter(ADUNIT_ID_1, BIDDER_ID_1); + expect(adunitCounter.getBidderWinsCounter(ADUNIT_ID_1, BIDDER_ID_1)).to.be.equal(1); + }); + it('increments and checks wins counter of adunit 2 for bidder 1', function () { + adunitCounter.incrementBidderWinsCounter(ADUNIT_ID_2, BIDDER_ID_1); + expect(adunitCounter.getBidderWinsCounter(ADUNIT_ID_2, BIDDER_ID_1)).to.be.equal(1); + }); + it('increments and checks wins counter of adunit 1 for bidder 2', function () { + adunitCounter.incrementBidderWinsCounter(ADUNIT_ID_1, BIDDER_ID_2); + expect(adunitCounter.getBidderWinsCounter(ADUNIT_ID_1, BIDDER_ID_2)).to.be.equal(1); }); }); From a7c5b803fe509e428a3321f85fc1d1a9803da02c Mon Sep 17 00:00:00 2001 From: hdwmsconfig Date: Tue, 10 Dec 2019 15:35:38 -0300 Subject: [PATCH 17/41] Add viewability to e-planning bid adapter (#4471) * add viewability e-planning bid adapter * change viewability and spaces name * fix in viewability * fix in viewability --- modules/eplanningBidAdapter.js | 263 ++++++++++++- test/spec/modules/eplanningBidAdapter_spec.js | 371 +++++++++++++++++- 2 files changed, 609 insertions(+), 25 deletions(-) diff --git a/modules/eplanningBidAdapter.js b/modules/eplanningBidAdapter.js index 01a956d1bd85..d9e145544836 100644 --- a/modules/eplanningBidAdapter.js +++ b/modules/eplanningBidAdapter.js @@ -11,9 +11,12 @@ const NET_REVENUE = true; const TTL = 120; const NULL_SIZE = '1x1'; const FILE = 'file'; +const STORAGE_RENDER_PREFIX = 'pbsr_'; +const STORAGE_VIEW_PREFIX = 'pbvi_'; export const spec = { code: BIDDER_CODE, + isBidRequestValid: function(bid) { return Boolean(bid.params.ci) || Boolean(bid.params.t); }, @@ -26,21 +29,26 @@ export const spec = { let params; const urlConfig = getUrlConfig(bidRequests); const pcrs = getCharset(); - + const spaces = getSpaces(bidRequests); if (urlConfig.t) { url = urlConfig.isv + '/layers/t_pbjs_2.json'; params = {}; } else { url = '//' + (urlConfig.sv || DEFAULT_SV) + '/hb/1/' + urlConfig.ci + '/' + dfpClientId + '/' + (utils.getTopWindowLocation().hostname || FILE) + '/' + sec; const referrerUrl = utils.getTopWindowReferrer(); - const spacesString = getSpacesString(bidRequests); + + if (utils.hasLocalStorage()) { + registerViewabilityAllBids(bidRequests); + } + params = { rnd: rnd, - e: spacesString, + e: spaces.str, ur: utils.getTopWindowUrl() || FILE, r: 'pbjs', pbv: '$prebid.version$', - ncb: '1' + ncb: '1', + vs: spaces.vs }; if (pcrs) { @@ -56,7 +64,7 @@ export const spec = { method: method, url: url, data: params, - adUnitToBidId: getBidIdMap(bidRequests), + adUnitToBidId: spaces.map, }; }, interpretResponse: function(serverResponse, request) { @@ -111,9 +119,6 @@ export const spec = { }, } -function cleanName(name) { - return name.replace(/_|\.|-|\//g, '').replace(/\)\(|\(|\)|:/g, '_').replace(/^_+|_+$/g, ''); -} function getUrlConfig(bidRequests) { if (isTestRequest(bidRequests)) { return getTestConfig(bidRequests.filter(br => br.params.t)); @@ -135,9 +140,12 @@ function getUrlConfig(bidRequests) { return config; } function isTestRequest(bidRequests) { - let isTest = false; - bidRequests.forEach(bid => isTest = bid.params.t); - return isTest; + for (let i = 0; i < bidRequests.length; i++) { + if (bidRequests[i].params.t) { + return true; + } + } + return false; } function getTestConfig(bidRequests) { let isv; @@ -147,14 +155,55 @@ function getTestConfig(bidRequests) { isv: '//' + (isv || DEFAULT_ISV) }; } -function getSpacesString(bids) { - const spacesString = bids.map(bid => - cleanName(bid.adUnitCode) + ':' + (bid.sizes && bid.sizes.length ? utils.parseSizesInput(bid.sizes).join(',') : NULL_SIZE) - ).join('+'); - return spacesString; +function getSize(bid, first) { + return bid.sizes && bid.sizes.length ? utils.parseSizesInput(first ? bid.sizes[0] : bid.sizes).join(',') : NULL_SIZE; +} + +function getSpacesStruct(bids) { + let e = {}; + bids.forEach(bid => { + let size = getSize(bid, true); + e[size] = e[size] ? e[size] : []; + e[size].push(bid); + }); + + return e; +} + +function getSpaces(bidRequests) { + let spacesStruct = getSpacesStruct(bidRequests); + let es = {str: '', vs: '', map: {}}; + es.str = Object.keys(spacesStruct).map(size => spacesStruct[size].map((bid, i) => { + es.vs += getVs(bid); + let name = getSize(bid, true) + '_' + i; + es.map[name] = bid.bidId; + return name + ':' + getSize(bid); + }).join('+')).join('+'); + return es; +} + +function getVs(bid) { + let s; + let vs = ''; + if (utils.hasLocalStorage()) { + s = getViewabilityData(bid); + vs += s.render >= 4 ? s.ratio.toString(16) : 'F'; + } else { + vs += 'F'; + } + return vs; } +function getViewabilityData(bid) { + let r = utils.getDataFromLocalStorage(STORAGE_RENDER_PREFIX + bid.adUnitCode) || 0; + let v = utils.getDataFromLocalStorage(STORAGE_VIEW_PREFIX + bid.adUnitCode) || 0; + let ratio = r > 0 ? (v / r) : 0; + return { + render: r, + ratio: window.parseInt(ratio * 10, 10) + }; +} function getCharset() { try { return window.top.document.charset || window.top.document.characterSet; @@ -163,10 +212,184 @@ function getCharset() { } } -function getBidIdMap(bidRequests) { - let map = {}; - bidRequests.forEach(bid => map[cleanName(bid.adUnitCode)] = bid.bidId); - return map; +function waitForElementsPresent(elements) { + const observer = new MutationObserver(function (mutationList, observer) { + if (mutationList && Array.isArray(mutationList)) { + mutationList.forEach(mr => { + if (mr && mr.addedNodes && Array.isArray(mr.addedNodes)) { + mr.addedNodes.forEach(ad => { + let index = elements.indexOf(ad.id); + if (index >= 0) { + registerViewability(ad); + elements.splice(index, 1); + if (!elements.length) { + observer.disconnect(); + } + } + }); + } + }); + } + }); + const config = {childList: true, subtree: true, characterData: true, attributes: true, attributeOldValue: true}; + observer.observe(document.body, config); +} + +function registerViewability(div) { + visibilityHandler({ + name: div.id, + div: div + }); +} + +function registerViewabilityAllBids(bids) { + let elementsNotPresent = []; + bids.forEach(bid => { + let div = document.getElementById(bid.adUnitCode); + if (div) { + registerViewability(div); + } else { + elementsNotPresent.push(bid.adUnitCode); + } + }); + if (elementsNotPresent.length) { + waitForElementsPresent(elementsNotPresent); + } } +function getViewabilityTracker() { + let TIME_PARTITIONS = 5; + let VIEWABILITY_TIME = 1000; + let VIEWABILITY_MIN_RATIO = 0.5; + let publicApi; + let context; + + function segmentIsOutsideTheVisibleRange(visibleRangeEnd, p1, p2) { + return p1 > visibleRangeEnd || p2 < 0; + } + + function segmentBeginsBeforeTheVisibleRange(p1) { + return p1 < 0; + } + + function segmentEndsAfterTheVisibleRange(visibleRangeEnd, p2) { + return p2 < visibleRangeEnd; + } + + function axialVisibilityRatio(visibleRangeEnd, p1, p2) { + let visibilityRatio = 0; + if (!segmentIsOutsideTheVisibleRange(visibleRangeEnd, p1, p2)) { + if (segmentBeginsBeforeTheVisibleRange(p1)) { + visibilityRatio = p2 / (p2 - p1); + } else { + visibilityRatio = segmentEndsAfterTheVisibleRange(visibleRangeEnd, p2) ? 1 : (visibleRangeEnd - p1) / (p2 - p1); + } + } + return visibilityRatio; + } + + function isNotHiddenByNonFriendlyIframe() { + return (window === window.top) || window.frameElement; + } + + function defineContext(e) { + context = e && window.document.body.contains(e) ? window : (window.top.document.body.contains(e) ? top : undefined); + return context; + } + + function getContext(e) { + return context; + } + + function verticalVisibilityRatio(position) { + return axialVisibilityRatio(getContext().innerHeight, position.top, position.bottom); + } + + function horizontalVisibilityRatio(position) { + return axialVisibilityRatio(getContext().innerWidth, position.left, position.right); + } + + function itIsNotHiddenByBannerAreaPosition(e) { + let position = e.getBoundingClientRect(); + return (verticalVisibilityRatio(position) * horizontalVisibilityRatio(position)) > VIEWABILITY_MIN_RATIO; + } + + function itIsNotHiddenByDisplayStyleCascade(e) { + return e.offsetHeight > 0 && e.offsetWidth > 0; + } + + function itIsNotHiddenByOpacityStyleCascade(e) { + let s = e.style; + let p = e.parentNode; + return !(s && parseFloat(s.opacity) === 0) && (!p || itIsNotHiddenByOpacityStyleCascade(p)); + } + + function itIsNotHiddenByVisibilityStyleCascade(e) { + return getContext().getComputedStyle(e).visibility !== 'hidden'; + } + + function itIsNotHiddenByTabFocus() { + return getContext().top.document.hasFocus(); + } + + function isDefined(e) { + return (e !== null) && (typeof e !== 'undefined'); + } + + function itIsNotHiddenByOrphanBranch() { + return isDefined(getContext()); + } + + function isContextInAnIframe() { + return isDefined(getContext().frameElement); + } + + function processIntervalVisibilityStatus(elapsedVisibleIntervals, element, callback) { + let visibleIntervals = isVisible(element) ? (elapsedVisibleIntervals + 1) : 0; + if (visibleIntervals === TIME_PARTITIONS) { + callback(); + } else { + setTimeout(processIntervalVisibilityStatus.bind(this, visibleIntervals, element, callback), VIEWABILITY_TIME / TIME_PARTITIONS); + } + } + + function isVisible(element) { + defineContext(element); + return isNotHiddenByNonFriendlyIframe() && + itIsNotHiddenByOrphanBranch() && + itIsNotHiddenByTabFocus() && + itIsNotHiddenByDisplayStyleCascade(element) && + itIsNotHiddenByVisibilityStyleCascade(element) && + itIsNotHiddenByOpacityStyleCascade(element) && + itIsNotHiddenByBannerAreaPosition(element) && + (!isContextInAnIframe() || isVisible(getContext().frameElement)); + } + + publicApi = { + isVisible: isVisible, + onView: processIntervalVisibilityStatus.bind(this, 0) + }; + + return publicApi; +}; + +function visibilityHandler(obj) { + if (obj.div) { + registerAuction(STORAGE_RENDER_PREFIX + obj.name); + getViewabilityTracker().onView(obj.div, registerAuction.bind(undefined, STORAGE_VIEW_PREFIX + obj.name)); + } +} + +function registerAuction(storageID) { + let value; + try { + value = utils.getDataFromLocalStorage(storageID); + value = value ? window.parseInt(value, 10) + 1 : 1; + utils.setDataInLocalStorage(storageID, value); + } catch (exc) { + return false; + } + + return true; +} registerBidder(spec); diff --git a/test/spec/modules/eplanningBidAdapter_spec.js b/test/spec/modules/eplanningBidAdapter_spec.js index 93290229ce3b..3152c43c6ffc 100644 --- a/test/spec/modules/eplanningBidAdapter_spec.js +++ b/test/spec/modules/eplanningBidAdapter_spec.js @@ -8,10 +8,14 @@ describe('E-Planning Adapter', function () { const CI = '12345'; const ADUNIT_CODE = 'adunit-co:de'; const ADUNIT_CODE2 = 'adunit-code-dos'; - const CLEAN_ADUNIT_CODE2 = 'adunitcodedos'; - const CLEAN_ADUNIT_CODE = 'adunitco_de'; + const ADUNIT_CODE_VIEW = 'adunit-code-view'; + const ADUNIT_CODE_VIEW2 = 'adunit-code-view2'; + const ADUNIT_CODE_VIEW3 = 'adunit-code-view3'; + const CLEAN_ADUNIT_CODE2 = '300x250_1'; + const CLEAN_ADUNIT_CODE = '300x250_0'; const BID_ID = '123456789'; const BID_ID2 = '987654321'; + const BID_ID3 = '998877665'; const CPM = 1.3; const W = '300'; const H = '250'; @@ -37,6 +41,33 @@ describe('E-Planning Adapter', function () { 'adUnitCode': ADUNIT_CODE2, 'sizes': [[300, 250], [300, 600]], }; + const validBidView = { + 'bidder': 'eplanning', + 'bidId': BID_ID, + 'params': { + 'ci': CI, + }, + 'adUnitCode': ADUNIT_CODE_VIEW, + 'sizes': [[300, 250], [300, 600]], + }; + const validBidView2 = { + 'bidder': 'eplanning', + 'bidId': BID_ID2, + 'params': { + 'ci': CI, + }, + 'adUnitCode': ADUNIT_CODE_VIEW2, + 'sizes': [[300, 250], [300, 600]], + }; + const validBidView3 = { + 'bidder': 'eplanning', + 'bidId': BID_ID3, + 'params': { + 'ci': CI, + }, + 'adUnitCode': ADUNIT_CODE_VIEW3, + 'sizes': [[300, 250], [300, 600]], + }; const testBid = { 'bidder': 'eplanning', 'params': { @@ -212,7 +243,7 @@ describe('E-Planning Adapter', function () { it('should return e parameter with value according to the adunit sizes', function () { const e = spec.buildRequests(bidRequests).data.e; - expect(e).to.equal(CLEAN_ADUNIT_CODE + ':300x250,300x600'); + expect(e).to.equal('300x250_0:300x250,300x600'); }); it('should return correct e parameter with more than one adunit', function () { @@ -229,7 +260,7 @@ describe('E-Planning Adapter', function () { bidRequests.push(anotherBid); const e = spec.buildRequests(bidRequests).data.e; - expect(e).to.equal(CLEAN_ADUNIT_CODE + ':300x250,300x600+' + CLEAN_NEW_CODE + ':100x100'); + expect(e).to.equal('300x250_0:300x250,300x600+100x100_0:100x100'); }); it('should return correct e parameter when the adunit has no size', function () { @@ -242,7 +273,7 @@ describe('E-Planning Adapter', function () { }; const e = spec.buildRequests([noSizeBid]).data.e; - expect(e).to.equal(CLEAN_ADUNIT_CODE + ':1x1'); + expect(e).to.equal('1x1_0:1x1'); }); it('should return ur parameter with current window url', function () { @@ -360,4 +391,334 @@ describe('E-Planning Adapter', function () { expect(responses[1].requestId).to.equal(BID_ID2); }); }); + describe('viewability', function() { + let storageIdRender = 'pbsr_' + validBidView.adUnitCode; + let storageIdView = 'pbvi_' + validBidView.adUnitCode; + let bidRequests = [validBidView]; + let bidRequestMultiple = [validBidView, validBidView2, validBidView3]; + let getLocalStorageSpy; + let setDataInLocalStorageSpy; + let hasLocalStorageStub; + let clock; + let element; + let getBoundingClientRectStub; + let sandbox = sinon.sandbox.create(); + let focusStub; + function createElement(id) { + element = document.createElement('div'); + element.id = id || ADUNIT_CODE_VIEW; + element.style.width = '50px'; + element.style.height = '50px'; + if (frameElement) { + frameElement.style.width = '100px'; + frameElement.style.height = '100px'; + } + element.style.background = 'black'; + document.body.appendChild(element); + } + function createElementVisible(id) { + createElement(id); + sandbox.stub(element, 'getBoundingClientRect').returns({ + x: 0, + y: 0, + width: 50, + height: 50, + top: 0, + right: 50, + bottom: 50, + left: 0, + }); + } + function createElementOutOfView(id) { + createElement(id); + sandbox.stub(element, 'getBoundingClientRect').returns({ + x: 100, + y: 100, + width: 250, + height: 250, + top: 100, + right: 350, + bottom: 350, + left: 100, + }); + } + + function createPartiallyVisibleElement(id) { + createElement(id); + sandbox.stub(element, 'getBoundingClientRect').returns({ + x: 0, + y: 0, + width: 50, + height: 150, + top: 0, + right: 50, + bottom: 150, + left: 0, + }); + } + function createPartiallyInvisibleElement(id) { + createElement(id); + sandbox.stub(element, 'getBoundingClientRect').returns({ + x: 0, + y: 0, + width: 150, + height: 150, + top: 0, + right: 150, + bottom: 150, + left: 0, + }); + } + function createElementOutOfRange(id) { + createElement(id); + sandbox.stub(element, 'getBoundingClientRect').returns({ + x: 200, + y: 200, + width: 350, + height: 350, + top: 200, + right: 350, + bottom: 350, + left: 200, + }); + } + beforeEach(function () { + getLocalStorageSpy = sandbox.spy(utils, 'getDataFromLocalStorage'); + setDataInLocalStorageSpy = sandbox.spy(utils, 'setDataInLocalStorage'); + + hasLocalStorageStub = sandbox.stub(utils, 'hasLocalStorage'); + hasLocalStorageStub.returns(true); + + clock = sandbox.useFakeTimers(); + + focusStub = sandbox.stub(window.top.document, 'hasFocus'); + focusStub.returns(true); + }); + afterEach(function () { + sandbox.restore(); + if (document.getElementById(ADUNIT_CODE_VIEW)) { + document.body.removeChild(element); + } + window.top.localStorage.removeItem(storageIdRender); + window.top.localStorage.removeItem(storageIdView); + }); + + it('should create the url correctly without LocalStorage', function() { + createElementVisible(); + hasLocalStorageStub.returns(false); + const response = spec.buildRequests(bidRequests); + + expect(response.url).to.equal('//ads.us.e-planning.net/hb/1/' + CI + '/1/localhost/ROS'); + expect(response.data.vs).to.equal('F'); + + sinon.assert.notCalled(getLocalStorageSpy); + sinon.assert.notCalled(setDataInLocalStorageSpy); + }); + + it('should create the url correctly with LocalStorage', function() { + createElementVisible(); + const response = spec.buildRequests(bidRequests); + expect(response.url).to.equal('//ads.us.e-planning.net/hb/1/' + CI + '/1/localhost/ROS'); + + expect(response.data.vs).to.equal('F'); + + sinon.assert.called(getLocalStorageSpy); + sinon.assert.called(setDataInLocalStorageSpy); + sinon.assert.calledWith(getLocalStorageSpy, storageIdRender); + sinon.assert.calledWith(setDataInLocalStorageSpy, storageIdRender); + + expect(utils.getDataFromLocalStorage(storageIdRender)).to.equal('1'); + }); + + context('when element is fully in view', function() { + let respuesta; + beforeEach(function () { + createElementVisible(); + }); + it('when you have a render', function() { + respuesta = spec.buildRequests(bidRequests); + clock.tick(1005); + + expect(respuesta.data.vs).to.equal('F'); + + expect(utils.getDataFromLocalStorage(storageIdRender)).to.equal('1'); + expect(utils.getDataFromLocalStorage(storageIdView)).to.equal('1'); + }); + it('when you have more than four render', function() { + utils.setDataInLocalStorage(storageIdRender, 4); + respuesta = spec.buildRequests(bidRequests); + clock.tick(1005); + + expect(respuesta.data.vs).to.equal('0'); + + expect(utils.getDataFromLocalStorage(storageIdRender)).to.equal('5'); + expect(utils.getDataFromLocalStorage(storageIdView)).to.equal('1'); + }); + it('when you have more than four render and already record visibility', function() { + utils.setDataInLocalStorage(storageIdRender, 4); + utils.setDataInLocalStorage(storageIdView, 4); + respuesta = spec.buildRequests(bidRequests); + clock.tick(1005); + + expect(respuesta.data.vs).to.equal('a'); + + expect(utils.getDataFromLocalStorage(storageIdRender)).to.equal('5'); + expect(utils.getDataFromLocalStorage(storageIdView)).to.equal('5'); + }); + }); + + context('when element is out of view', function() { + let respuesta; + beforeEach(function () { + createElementOutOfView(); + }); + + it('when you have a render', function() { + respuesta = spec.buildRequests(bidRequests); + clock.tick(1005); + expect(respuesta.data.vs).to.equal('F'); + + expect(utils.getDataFromLocalStorage(storageIdRender)).to.equal('1'); + expect(utils.getDataFromLocalStorage(storageIdView)).to.equal(null); + }); + it('when you have more than four render', function() { + utils.setDataInLocalStorage(storageIdRender, 4); + respuesta = spec.buildRequests(bidRequests); + clock.tick(1005); + expect(respuesta.data.vs).to.equal('0'); + + expect(utils.getDataFromLocalStorage(storageIdRender)).to.equal('5'); + expect(utils.getDataFromLocalStorage(storageIdView)).to.equal(null); + }); + }); + + context('when element is partially in view', function() { + let respuesta; + it('should register visibility with more than 50%', function() { + createPartiallyVisibleElement(); + respuesta = spec.buildRequests(bidRequests); + clock.tick(1005); + + expect(utils.getDataFromLocalStorage(storageIdRender)).to.equal('1'); + expect(utils.getDataFromLocalStorage(storageIdView)).to.equal('1'); + }); + it('you should not register visibility with less than 50%', function() { + createPartiallyInvisibleElement(); + respuesta = spec.buildRequests(bidRequests); + clock.tick(1005); + + expect(utils.getDataFromLocalStorage(storageIdRender)).to.equal('1'); + expect(utils.getDataFromLocalStorage(storageIdView)).to.equal(null); + }); + }); + context('when width or height of the element is zero', function() { + beforeEach(function () { + createElementVisible(); + }); + it('if the width is zero but the height is within the range', function() { + element.style.width = '0px'; + spec.buildRequests(bidRequests) + clock.tick(1005); + + expect(utils.getDataFromLocalStorage(storageIdRender)).to.equal('1'); + expect(utils.getDataFromLocalStorage(storageIdView)).to.equal(null); + }); + it('if the height is zero but the width is within the range', function() { + element.style.height = '0px'; + spec.buildRequests(bidRequests) + clock.tick(1005); + + expect(utils.getDataFromLocalStorage(storageIdRender)).to.equal('1'); + expect(utils.getDataFromLocalStorage(storageIdView)).to.equal(null); + }); + it('if both are zero', function() { + element.style.height = '0px'; + element.style.width = '0px'; + spec.buildRequests(bidRequests) + clock.tick(1005); + + expect(utils.getDataFromLocalStorage(storageIdRender)).to.equal('1'); + expect(utils.getDataFromLocalStorage(storageIdView)).to.equal(null); + }); + }); + context('when tab is inactive', function() { + it('I should not register if it is not in focus', function() { + createElementVisible(); + focusStub.returns(false); + spec.buildRequests(bidRequests); + clock.tick(1005); + expect(utils.getDataFromLocalStorage(storageIdRender)).to.equal('1'); + expect(utils.getDataFromLocalStorage(storageIdView)).to.equal(null); + }); + }); + context('segmentBeginsBeforeTheVisibleRange', function() { + it('segmentBeginsBeforeTheVisibleRange', function() { + createElementOutOfRange(); + spec.buildRequests(bidRequests); + clock.tick(1005); + expect(utils.getDataFromLocalStorage(storageIdRender)).to.equal('1'); + expect(utils.getDataFromLocalStorage(storageIdView)).to.equal(null); + }); + }); + context('when there are multiple adunit', function() { + let respuesta; + beforeEach(function () { + [ADUNIT_CODE_VIEW, ADUNIT_CODE_VIEW2, ADUNIT_CODE_VIEW3].forEach(ac => { + utils.setDataInLocalStorage('pbsr_' + ac, 5); + utils.setDataInLocalStorage('pbvi_' + ac, 5); + }); + }); + afterEach(function () { + [ADUNIT_CODE_VIEW, ADUNIT_CODE_VIEW2, ADUNIT_CODE_VIEW3].forEach(ac => { + if (document.getElementById(ac)) { + document.body.removeChild(document.getElementById(ac)); + } + window.top.localStorage.removeItem(ac); + window.top.localStorage.removeItem(ac); + }); + }); + it('all visibles', function() { + createElementVisible(ADUNIT_CODE_VIEW); + createElementVisible(ADUNIT_CODE_VIEW2); + createElementVisible(ADUNIT_CODE_VIEW3); + + respuesta = spec.buildRequests(bidRequestMultiple); + clock.tick(1005); + [ADUNIT_CODE_VIEW, ADUNIT_CODE_VIEW2, ADUNIT_CODE_VIEW3].forEach(ac => { + expect(utils.getDataFromLocalStorage('pbsr_' + ac)).to.equal('6'); + expect(utils.getDataFromLocalStorage('pbvi_' + ac)).to.equal('6'); + }); + expect('aaa').to.equal(respuesta.data.vs); + }); + it('none visible', function() { + createElementOutOfView(ADUNIT_CODE_VIEW); + createElementOutOfView(ADUNIT_CODE_VIEW2); + createElementOutOfView(ADUNIT_CODE_VIEW3); + + respuesta = spec.buildRequests(bidRequestMultiple); + clock.tick(1005); + [ADUNIT_CODE_VIEW, ADUNIT_CODE_VIEW2, ADUNIT_CODE_VIEW3].forEach(ac => { + expect(utils.getDataFromLocalStorage('pbsr_' + ac)).to.equal('6'); + expect(utils.getDataFromLocalStorage('pbvi_' + ac)).to.equal('5'); + }); + + expect('aaa').to.equal(respuesta.data.vs); + }); + it('some visible and others not visible', function() { + createElementVisible(ADUNIT_CODE_VIEW); + createElementOutOfView(ADUNIT_CODE_VIEW2); + createElementOutOfView(ADUNIT_CODE_VIEW3); + + respuesta = spec.buildRequests(bidRequestMultiple); + clock.tick(1005); + expect(utils.getDataFromLocalStorage('pbsr_' + ADUNIT_CODE_VIEW)).to.equal('6'); + expect(utils.getDataFromLocalStorage('pbvi_' + ADUNIT_CODE_VIEW)).to.equal('6'); + [ADUNIT_CODE_VIEW2, ADUNIT_CODE_VIEW3].forEach(ac => { + expect(utils.getDataFromLocalStorage('pbsr_' + ac)).to.equal('6'); + expect(utils.getDataFromLocalStorage('pbvi_' + ac)).to.equal('5'); + }); + expect('aaa').to.equal(respuesta.data.vs); + }); + }); + }); }); From 5047aff546fde16919704d3b56e9cdb4e7428749 Mon Sep 17 00:00:00 2001 From: Tomas Kovtun Date: Tue, 10 Dec 2019 20:44:17 +0200 Subject: [PATCH 18/41] adformBidAdapter. Outstream renderer condition (#4523) * Must not apply a renderer if media type is not 'video' https://github.com/prebid/Prebid.js/pull/4363#discussion_r352583927 * The change fixes 2 incorrect behaviours. 1. Sizes were taken from the bid object shallowly. Now, with the help of utils.getAdUnitSizes the adapter supports sizes from the bid object and from mediaType. Latter has the priority. 2. A dimension pair can be written in both ways, [width, height] and [[width, height]]. Previously, only nested arrays would work correctly. * ensure renderer is not applied to banners --- modules/adformBidAdapter.js | 4 ++-- test/spec/modules/adformBidAdapter_spec.js | 11 ++++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/modules/adformBidAdapter.js b/modules/adformBidAdapter.js index 0ac083e7e7c7..d344908c6384 100644 --- a/modules/adformBidAdapter.js +++ b/modules/adformBidAdapter.js @@ -98,7 +98,7 @@ export const spec = { response = responses[i]; type = response.response === 'banner' ? BANNER : VIDEO; bid = bids[i]; - if (VALID_RESPONSES[response.response] && (verifySize(response, bid.sizes) || type === VIDEO)) { + if (VALID_RESPONSES[response.response] && (verifySize(response, utils.getAdUnitSizes(bid)) || type === VIDEO)) { bidObject = { requestId: bid.bidId, cpm: response.win_bid, @@ -117,7 +117,7 @@ export const spec = { mediaType: type }; - if (!bid.renderer && utils.deepAccess(bid, 'mediaTypes.video.context') === 'outstream') { + if (!bid.renderer && type === VIDEO && utils.deepAccess(bid, 'mediaTypes.video.context') === 'outstream') { bidObject.renderer = Renderer.install({id: bid.bidId, url: OUTSTREAM_RENDERER_URL}); bidObject.renderer.setRender(renderer); } diff --git a/test/spec/modules/adformBidAdapter_spec.js b/test/spec/modules/adformBidAdapter_spec.js index 17eef06c603b..80f89614c5e0 100644 --- a/test/spec/modules/adformBidAdapter_spec.js +++ b/test/spec/modules/adformBidAdapter_spec.js @@ -258,11 +258,12 @@ describe('Adform adapter', function () { }; }); - it('should set a renderer for an outstream context', function () { - serverResponse.body = [serverResponse.body[3]]; - bidRequest.bids = [bidRequest.bids[6]]; + it('should set a renderer only for an outstream context', function () { + serverResponse.body = [serverResponse.body[3], serverResponse.body[2]]; + bidRequest.bids = [bidRequest.bids[6], bidRequest.bids[6]]; let result = spec.interpretResponse(serverResponse, bidRequest); assert.ok(result[0].renderer); + assert.equal(result[1].renderer, undefined); }); describe('verifySizes', function () { @@ -314,9 +315,9 @@ describe('Adform adapter', function () { beforeEach(function () { config.setConfig({ currency: {} }); - let sizes = [[250, 300], [300, 250], [300, 600]]; + let sizes = [[250, 300], [300, 250], [300, 600], [600, 300]]; let placementCode = ['div-01', 'div-02', 'div-03', 'div-04', 'div-05']; - let mediaTypes = [{video: {context: 'outstream'}}]; + let mediaTypes = [{video: {context: 'outstream'}, banner: {sizes: sizes[3]}}]; let params = [{ mid: 1, url: 'some// there' }, {adxDomain: null, mid: 2, someVar: 'someValue', pt: 'gross'}, { adxDomain: null, mid: 3, pdom: 'home' }, {mid: 5, pt: 'net'}, {mid: 6, pt: 'gross'}]; bids = [ { From 6de34748efac9a2b37ea71d4ebcb4a5d4eed7cd5 Mon Sep 17 00:00:00 2001 From: sourabhg Date: Wed, 11 Dec 2019 00:24:30 +0530 Subject: [PATCH 19/41] feat(displaymanager): added displaymanager and version with user object (#4546) * feat(displaymanager): added displaymanager and version with user object * feat(custom params): wrapped custom params in deepintent object --- modules/deepintentBidAdapter.js | 44 +++++++++++++++---- .../spec/modules/deepintentBidAdapter_spec.js | 27 +++++++++--- 2 files changed, 56 insertions(+), 15 deletions(-) diff --git a/modules/deepintentBidAdapter.js b/modules/deepintentBidAdapter.js index 27aa4e2c8a6b..39866086cfa7 100644 --- a/modules/deepintentBidAdapter.js +++ b/modules/deepintentBidAdapter.js @@ -4,7 +4,7 @@ import * as utils from '../src/utils'; const BIDDER_CODE = 'deepintent'; const BIDDER_ENDPOINT = 'https://prebid.deepintent.com/prebid'; const USER_SYNC_URL = 'https://beacon.deepintent.com/usersync.html'; - +const DI_M_V = '1.0.0'; export const spec = { code: BIDDER_CODE, supportedMediaTypes: [BANNER], @@ -29,18 +29,15 @@ export const spec = { return responses; }, buildRequests: function (validBidRequests, bidderRequest) { + var user = validBidRequests.map(bid => buildUser(bid)); + clean(user); const openRtbBidRequest = { id: utils.generateUUID(), at: 1, imp: validBidRequests.map(bid => buildImpression(bid)), site: buildSite(bidderRequest), device: buildDevice(), - source: { - fd: 0, - ext: { - type: 2 - } - } + user: user && user.length == 1 ? user[0] : {} }; return { @@ -65,6 +62,13 @@ export const spec = { } }; +function clean(obj) { + for (let propName in obj) { + if (obj[propName] === null || obj[propName] === undefined) { + delete obj[propName]; + } + } +} function formatResponse(bid) { return { @@ -87,9 +91,33 @@ function buildImpression(bid) { tagid: bid.params.tagId || '', secure: window.location.protocol === 'https' ? 1 : 0, banner: buildBanner(bid), - ext: bid.params.custom ? bid.params.custom : {} + displaymanager: 'di_prebid', + displaymanagerver: DI_M_V, + ext: buildCustomParams(bid) }; } +function buildCustomParams(bid) { + if (bid.params && bid.params.custom) { + return { + deepintent: bid.params.custom + + } + } else { + return {} + } +} +function buildUser(bid) { + if (bid && bid.params && bid.params.user) { + return { + id: bid.params.user.id && typeof bid.params.user.id == 'string' ? bid.params.user.id : undefined, + buyeruid: bid.params.user.buyeruid && typeof bid.params.user.buyeruid == 'string' ? bid.params.user.buyeruid : undefined, + yob: bid.params.user.yob && typeof bid.params.user.yob == 'number' ? bid.params.user.yob : null, + gender: bid.params.user.gender && typeof bid.params.user.gender == 'string' ? bid.params.user.gender : undefined, + keywords: bid.params.user.keywords && typeof bid.params.user.keywords == 'string' ? bid.params.user.keywords : undefined, + customdata: bid.params.user.customdata && typeof bid.params.user.customdata == 'string' ? bid.params.user.customdata : undefined + } + } +} function buildBanner(bid) { if (utils.deepAccess(bid, 'mediaTypes.banner')) { diff --git a/test/spec/modules/deepintentBidAdapter_spec.js b/test/spec/modules/deepintentBidAdapter_spec.js index 353a815eb8c1..f4adad7faf21 100644 --- a/test/spec/modules/deepintentBidAdapter_spec.js +++ b/test/spec/modules/deepintentBidAdapter_spec.js @@ -19,9 +19,14 @@ describe('Deepintent adapter', function () { tagId: '100013', w: 728, h: 90, + user: { + id: 'di_testuid', + buyeruid: 'di_testbuyeruid', + yob: 2002, + gender: 'F' + }, custom: { - user_gender: 'female', - user_max_age: 25 + 'position': 'right-box' } } } @@ -122,14 +127,22 @@ describe('Deepintent adapter', function () { let bRequest = spec.buildRequests(request); let data = JSON.parse(bRequest.data); expect(data.imp[0].ext).to.be.a('object'); - expect(data.imp[0].ext.user_gender).to.equal('female'); - expect(data.imp[0].ext.user_max_age).to.equal(25); + expect(data.imp[0].ext.deepintent.position).to.equal('right-box'); }); - it('bid request check: source params', function () { + it('bid request check: displaymanager check', function() { let bRequest = spec.buildRequests(request); let data = JSON.parse(bRequest.data); - expect(data.source.fd).to.equal(0); - expect(data.source.ext.type).to.equal(2); + expect(data.imp[0].displaymanager).to.equal('di_prebid'); + expect(data.imp[0].displaymanagerver).to.equal('1.0.0'); + }); + it('bid request check: user object check', function () { + let bRequest = spec.buildRequests(request); + let data = JSON.parse(bRequest.data); + expect(data.user).to.be.a('object'); + expect(data.user.id).to.equal('di_testuid'); + expect(data.user.buyeruid).to.equal('di_testbuyeruid'); + expect(data.user.yob).to.equal(2002); + expect(data.user.gender).to.equal('F'); }) }); describe('user sync check', function () { From 5926b49eb77f8fc00ff8dc704b50c9c12c1d0af5 Mon Sep 17 00:00:00 2001 From: "Isaac A. Dettman" Date: Tue, 10 Dec 2019 14:47:58 -0800 Subject: [PATCH 20/41] Fix for Outstream and MediaTypePriceGranularity (#4544) * Add microadBidAdapter * Remove unnecessary encodeURIComponent from microadBidAdapter * Submit Advangelists Prebid Adapter * Submit Advangelists Prebid Adapter 1.1 * Correct procudtion endpoint for prebid * analytics update with wrapper name * reverted error merge * update changed default value of netRevenue to true * fix video mediaTypes granularity for instream and outstream * refactor inline code to geMediaTypeGranularity method since its used in two location * fix missing import for INSTREAM * added test and small code change to optimize conditionals * add test * refactor with added test * added more tests, small fixes * remove redundant comment * updates to tests * tiny update to comment * updated tests * updated with fixes test updates --- src/auction.js | 55 +++++++++++++++++----- src/config.js | 16 +++++++ test/spec/auctionmanager_spec.js | 81 +++++++++++++++++++++++++++++++- test/spec/config_spec.js | 17 +++++-- 4 files changed, 152 insertions(+), 17 deletions(-) diff --git a/src/auction.js b/src/auction.js index 9b6951c6b7a6..fe1b70085e92 100644 --- a/src/auction.js +++ b/src/auction.js @@ -27,8 +27,17 @@ */ /** - * @typedef {Object} BidRequest - * //TODO add all properties + * @typedef {Object} BidderRequest + * + * @property {string} bidderCode - adUnit bidder + * @property {number} auctionId - random UUID + * @property {string} bidderRequestId - random string, unique key set on all bidRequest.bids[] + * @property {Array.} bids + * @property {number} auctionStart - Date.now() at auction start + * @property {number} timeout - callback timeout + * @property {refererInfo} refererInfo - referer info object + * @property {string} [tid] - random UUID (used for s2s) + * @property {string} [src] - s2s or client (used for s2s) */ /** @@ -48,7 +57,7 @@ * @property {function(): void} callBids - sends requests to all adapters for bids */ -import { flatten, timestamp, adUnitsFilter, deepAccess, getBidRequest, getValue } from './utils'; +import {flatten, timestamp, adUnitsFilter, deepAccess, getBidRequest, getValue} from './utils'; import { parse as parseURL } from './url'; import { getPriceBucketString } from './cpmBucketManager'; import { getNativeTargeting } from './native'; @@ -59,6 +68,7 @@ import { userSync } from './userSync'; import { hook } from './hook'; import find from 'core-js/library/fn/array/find'; import { OUTSTREAM } from './video'; +import { VIDEO } from './mediaTypes'; const { syncUsers } = userSync; const utils = require('./utils'); @@ -85,7 +95,11 @@ const queuedCalls = []; * * @param {Object} requestConfig * @param {AdUnit} requestConfig.adUnits - * @param {AdUnitCode} requestConfig.adUnitCode + * @param {AdUnitCode} requestConfig.adUnitCodes + * @param {function():void} requestConfig.callback + * @param {number} requestConfig.cbTimeout + * @param {Array.} requestConfig.labels + * @param {string} requestConfig.auctionId * * @returns {Auction} auction instance */ @@ -490,8 +504,7 @@ function getPreparedBidForAuction({adUnitCode, bid, bidderRequest, auctionId}) { } // Use the config value 'mediaTypeGranularity' if it has been defined for mediaType, else use 'customPriceBucket' - const mediaTypeGranularity = config.getConfig(`mediaTypePriceGranularity.${bid.mediaType}`); - + const mediaTypeGranularity = getMediaTypeGranularity(bid.mediaType, bidReq, config.getConfig('mediaTypePriceGranularity')); const priceStringsObj = getPriceBucketString( bidObject.cpm, (typeof mediaTypeGranularity === 'object') ? mediaTypeGranularity : config.getConfig('customPriceBucket'), @@ -518,14 +531,33 @@ function setupBidTargeting(bidObject, bidderRequest) { bidObject.adserverTargeting = Object.assign(bidObject.adserverTargeting || {}, keyValues); } +/** + * @param {MediaType} mediaType + * @param {Bid} [bidReq] + * @param {MediaTypePriceGranularity} [mediaTypePriceGranularity] + * @returns {(Object|string|undefined)} + */ +export function getMediaTypeGranularity(mediaType, bidReq, mediaTypePriceGranularity) { + if (mediaType && mediaTypePriceGranularity) { + if (mediaType === VIDEO) { + const context = deepAccess(bidReq, `mediaTypes.${VIDEO}.context`, 'instream'); + if (mediaTypePriceGranularity[`${VIDEO}-${context}`]) { + return mediaTypePriceGranularity[`${VIDEO}-${context}`]; + } + } + return mediaTypePriceGranularity[mediaType]; + } +} + /** * This function returns the price granularity defined. It can be either publisher defined or default value * @param {string} mediaType + * @param {BidRequest} bidReq * @returns {string} granularity */ -export const getPriceGranularity = (mediaType) => { +export const getPriceGranularity = (mediaType, bidReq) => { // Use the config value 'mediaTypeGranularity' if it has been set for mediaType, else use 'priceGranularity' - const mediaTypeGranularity = config.getConfig(`mediaTypePriceGranularity.${mediaType}`); + const mediaTypeGranularity = getMediaTypeGranularity(mediaType, bidReq, config.getConfig('mediaTypePriceGranularity')); const granularity = (typeof mediaType === 'string' && mediaTypeGranularity) ? ((typeof mediaTypeGranularity === 'string') ? mediaTypeGranularity : 'custom') : config.getConfig('priceGranularity'); return granularity; } @@ -556,9 +588,10 @@ export const getPriceByGranularity = (granularity) => { /** * @param {string} mediaType * @param {string} bidderCode + * @param {BidRequest} bidReq * @returns {*} */ -export function getStandardBidderSettings(mediaType, bidderCode) { +export function getStandardBidderSettings(mediaType, bidderCode, bidReq) { // factory for key value objs function createKeyVal(key, value) { return { @@ -573,7 +606,7 @@ export function getStandardBidderSettings(mediaType, bidderCode) { }; } const TARGETING_KEYS = CONSTANTS.TARGETING_KEYS; - const granularity = getPriceGranularity(mediaType); + const granularity = getPriceGranularity(mediaType, bidReq); let bidderSettings = $$PREBID_GLOBAL$$.bidderSettings; if (!bidderSettings[CONSTANTS.JSON_MAPPING.BD_SETTING_STANDARD]) { @@ -627,7 +660,7 @@ export function getKeyValueTargetingPairs(bidderCode, custBidObj, bidReq) { // 1) set the keys from "standard" setting or from prebid defaults if (bidderSettings) { // initialize default if not set - const standardSettings = getStandardBidderSettings(custBidObj.mediaType, bidderCode); + const standardSettings = getStandardBidderSettings(custBidObj.mediaType, bidderCode, bidReq); setKeys(keyValues, standardSettings, custBidObj); // 2) set keys from specific bidder setting override if they exist diff --git a/src/config.js b/src/config.js index 38697c363b36..19a582e86d57 100644 --- a/src/config.js +++ b/src/config.js @@ -1,6 +1,17 @@ /* * Module for getting and setting Prebid configuration. */ + +/** + * @typedef {Object} MediaTypePriceGranularity + * + * @property {(string|Object)} [banner] + * @property {(string|Object)} [native] + * @property {(string|Object)} [video] + * @property {(string|Object)} [video-instream] + * @property {(string|Object)} [video-outstream] + */ + import { isValidPriceConfig } from './cpmBucketManager'; import find from 'core-js/library/fn/array/find'; import includes from 'core-js/library/fn/array/includes'; @@ -106,7 +117,12 @@ export function newConfig() { return this._customPriceBucket; }, + /** + * mediaTypePriceGranularity + * @type {MediaTypePriceGranularity} + */ _mediaTypePriceGranularity: {}, + get mediaTypePriceGranularity() { return this._mediaTypePriceGranularity; }, diff --git a/test/spec/auctionmanager_spec.js b/test/spec/auctionmanager_spec.js index 577b1bec3330..970bc61cc61c 100644 --- a/test/spec/auctionmanager_spec.js +++ b/test/spec/auctionmanager_spec.js @@ -1,6 +1,6 @@ import { getKeyValueTargetingPairs, auctionCallbacks, AUCTION_COMPLETED } from 'src/auction'; import CONSTANTS from 'src/constants.json'; -import { adjustBids } from 'src/auction'; +import { adjustBids, getMediaTypeGranularity } from 'src/auction'; import * as auctionModule from 'src/auction'; import { registerBidder } from 'src/adapters/bidderFactory'; import { createBid } from 'src/bidfactory'; @@ -25,6 +25,10 @@ const BIDDER_CODE1 = 'sampleBidder1'; const ADUNIT_CODE = 'adUnit-code'; const ADUNIT_CODE1 = 'adUnit-code-1'; +/** + * @param {Object} [opts] + * @returns {Bid} + */ function mockBid(opts) { let bidderCode = opts && opts.bidderCode; @@ -43,6 +47,11 @@ function mockBid(opts) { }; } +/** + * @param {Bid} bid + * @param {Object} [opts] + * @returns {BidRequest} + */ function mockBidRequest(bid, opts) { if (!bid) { throw new Error('bid required'); @@ -976,6 +985,76 @@ describe('auctionmanager.js', function () { }); }); + describe('getMediaTypeGranularity', function () { + it('video', function () { + let bidReq = { + 'mediaTypes': { video: {id: '1'} } + }; + + // mediaType is video and video.context is undefined + expect(getMediaTypeGranularity('video', bidReq, { + banner: 'low', + video: 'medium' + })).to.equal('medium'); + + expect(getMediaTypeGranularity('video', {}, { + banner: 'low', + video: 'medium' + })).to.equal('medium'); + `` + expect(getMediaTypeGranularity('video', undefined, { + banner: 'low', + video: 'medium' + })).to.equal('medium'); + + // also when mediaTypes.video is undefined + bidReq = { + 'mediaTypes': { banner: {} } + }; + expect(getMediaTypeGranularity('video', bidReq, { + banner: 'low', + video: 'medium' + })).to.equal('medium'); + + // also when mediaTypes is undefined + expect(getMediaTypeGranularity('video', {}, { + banner: 'low', + video: 'medium' + })).to.equal('medium'); + }); + + it('video-outstream', function () { + let bidReq = { 'mediaTypes': { video: { context: 'outstream' } } }; + + expect(getMediaTypeGranularity('video', bidReq, { + 'banner': 'low', 'video': 'medium', 'video-outstream': 'high' + })).to.equal('high'); + }); + + it('video-instream', function () { + let bidReq = { 'mediaTypes': { video: { context: 'instream' } } }; + + expect(getMediaTypeGranularity('video', bidReq, { + banner: 'low', video: 'medium', 'video-instream': 'high' + })).to.equal('high'); + + // fall back to video if video-instream not found + expect(getMediaTypeGranularity('video', bidReq, { + banner: 'low', video: 'medium' + })).to.equal('medium'); + + expect(getMediaTypeGranularity('video', {mediaTypes: {banner: {}}}, { + banner: 'low', video: 'medium' + })).to.equal('medium'); + }); + + it('native', function () { + expect(getMediaTypeGranularity('native', {mediaTypes: {native: {}}}, { + banner: 'low', video: 'medium', native: 'high' + })).to.equal('high'); + }); + }); + describe('auctionCallbacks', function() { let bids = TEST_BIDS; let bidRequests; diff --git a/test/spec/config_spec.js b/test/spec/config_spec.js index c0f4f6bab891..8166b0f6d425 100644 --- a/test/spec/config_spec.js +++ b/test/spec/config_spec.js @@ -137,7 +137,7 @@ describe('config API', function () { }); it('set mediaTypePriceGranularity', function () { - const customPriceGranularity = { + const customPriceGranularityVideo = { 'buckets': [{ 'min': 0, 'max': 3, @@ -145,18 +145,25 @@ describe('config API', function () { 'cap': true }] }; + const customPriceGranularityInstream = utils.deepClone(customPriceGranularityVideo); + const customPriceGranularityOutstream = utils.deepClone(customPriceGranularityVideo); + setConfig({ 'mediaTypePriceGranularity': { 'banner': 'medium', - 'video': customPriceGranularity, - 'native': 'medium' + 'video': customPriceGranularityVideo, + 'video-instream': customPriceGranularityInstream, + 'video-outstream': customPriceGranularityOutstream, + 'native': 'high' } }); const configResult = getConfig('mediaTypePriceGranularity'); expect(configResult.banner).to.be.equal('medium'); - expect(configResult.video).to.be.equal(customPriceGranularity); - expect(configResult.native).to.be.equal('medium'); + expect(configResult.video).to.be.equal(customPriceGranularityVideo); + expect(configResult['video-instream']).to.be.equal(customPriceGranularityInstream); + expect(configResult['video-outstream']).to.be.equal(customPriceGranularityOutstream); + expect(configResult.native).to.be.equal('high'); }); it('sets priceGranularity and customPriceBucket', function () { From ca5cdcf0c7bdbb00f8b75a0a4c93ab03cdfaaf5e Mon Sep 17 00:00:00 2001 From: Harshad Mane Date: Tue, 10 Dec 2019 16:52:10 -0800 Subject: [PATCH 21/41] PubMatic to use source value 'pubcid.org' for pubcommonId (#4570) * added support for pubcommon, digitrust, id5id * added support for IdentityLink * changed the source for id5 * added unit test cases * changed source param for identityLink * changed source for pubcommonId to pubcid.org --- modules/pubmaticBidAdapter.js | 2 +- test/spec/modules/pubmaticBidAdapter_spec.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/pubmaticBidAdapter.js b/modules/pubmaticBidAdapter.js index 4281c4a449e3..358fd7bcf3a8 100644 --- a/modules/pubmaticBidAdapter.js +++ b/modules/pubmaticBidAdapter.js @@ -641,7 +641,7 @@ function _handleEids(payload, validBidRequests) { _handleTTDId(eids, validBidRequests); const bidRequest = validBidRequests[0]; if (bidRequest && bidRequest.userId) { - _addExternalUserId(eids, utils.deepAccess(bidRequest, `userId.pubcid`), 'pubcommon', 1); + _addExternalUserId(eids, utils.deepAccess(bidRequest, `userId.pubcid`), 'pubcid.org', 1); _addExternalUserId(eids, utils.deepAccess(bidRequest, `userId.digitrustid.data.id`), 'digitru.st', 1); _addExternalUserId(eids, utils.deepAccess(bidRequest, `userId.id5id`), 'id5-sync.com', 1); _addExternalUserId(eids, utils.deepAccess(bidRequest, `userId.criteoId`), 'criteo.com', 1);// replacing criteoRtus diff --git a/test/spec/modules/pubmaticBidAdapter_spec.js b/test/spec/modules/pubmaticBidAdapter_spec.js index 764897b596b2..f0c97cd72f3a 100644 --- a/test/spec/modules/pubmaticBidAdapter_spec.js +++ b/test/spec/modules/pubmaticBidAdapter_spec.js @@ -1561,7 +1561,7 @@ describe('PubMatic adapter', function () { let request = spec.buildRequests(bidRequests, {}); let data = JSON.parse(request.data); expect(data.user.eids).to.deep.equal([{ - 'source': 'pubcommon', + 'source': 'pubcid.org', 'uids': [{ 'id': 'pub_common_user_id', 'atype': 1 From 21dcd5aff5529ab966ebf337f9c818d8692e5208 Mon Sep 17 00:00:00 2001 From: Paul Yang Date: Tue, 10 Dec 2019 17:46:23 -0800 Subject: [PATCH 22/41] Conversant adapter CCPA support (#4569) --- modules/conversantBidAdapter.js | 22 +++++----- .../spec/modules/conversantBidAdapter_spec.js | 40 +++++++++++++++++-- 2 files changed, 48 insertions(+), 14 deletions(-) diff --git a/modules/conversantBidAdapter.js b/modules/conversantBidAdapter.js index 3ffc54bbe804..bb11b1f87cb6 100644 --- a/modules/conversantBidAdapter.js +++ b/modules/conversantBidAdapter.js @@ -122,16 +122,18 @@ export const spec = { let userExt = {}; - // Add GDPR flag and consent string - if (bidderRequest && bidderRequest.gdprConsent) { - userExt.consent = bidderRequest.gdprConsent.consentString; - - if (typeof bidderRequest.gdprConsent.gdprApplies === 'boolean') { - payload.regs = { - ext: { - gdpr: (bidderRequest.gdprConsent.gdprApplies ? 1 : 0) - } - }; + if (bidderRequest) { + // Add GDPR flag and consent string + if (bidderRequest.gdprConsent) { + userExt.consent = bidderRequest.gdprConsent.consentString; + + if (typeof bidderRequest.gdprConsent.gdprApplies === 'boolean') { + utils.deepSetValue(payload, 'regs.ext.gdpr', bidderRequest.gdprConsent.gdprApplies ? 1 : 0); + } + } + + if (bidderRequest.uspConsent) { + utils.deepSetValue(payload, 'regs.ext.us_privacy', bidderRequest.uspConsent); } } diff --git a/test/spec/modules/conversantBidAdapter_spec.js b/test/spec/modules/conversantBidAdapter_spec.js index ca6890ceedb0..67dd721a059c 100644 --- a/test/spec/modules/conversantBidAdapter_spec.js +++ b/test/spec/modules/conversantBidAdapter_spec.js @@ -404,31 +404,63 @@ describe('Conversant adapter tests', function() { it('Verify GDPR bid request', function() { // add gdpr info - const bidRequest = { + const bidderRequest = { gdprConsent: { consentString: 'BOJObISOJObISAABAAENAA4AAAAAoAAA', gdprApplies: true } }; - const payload = spec.buildRequests(bidRequests, bidRequest).data; + const payload = spec.buildRequests(bidRequests, bidderRequest).data; expect(payload).to.have.deep.nested.property('user.ext.consent', 'BOJObISOJObISAABAAENAA4AAAAAoAAA'); expect(payload).to.have.deep.nested.property('regs.ext.gdpr', 1); }); it('Verify GDPR bid request without gdprApplies', function() { // add gdpr info - const bidRequest = { + const bidderRequest = { gdprConsent: { consentString: '' } }; - const payload = spec.buildRequests(bidRequests, bidRequest).data; + const payload = spec.buildRequests(bidRequests, bidderRequest).data; expect(payload).to.have.deep.nested.property('user.ext.consent', ''); expect(payload).to.not.have.deep.nested.property('regs.ext.gdpr'); }); + describe('CCPA', function() { + it('should have us_privacy', function() { + const bidderRequest = { + uspConsent: '1NYN' + }; + + const payload = spec.buildRequests(bidRequests, bidderRequest).data; + expect(payload).to.have.deep.nested.property('regs.ext.us_privacy', '1NYN'); + expect(payload).to.not.have.deep.nested.property('regs.ext.gdpr'); + }); + + it('should have no us_privacy', function() { + const payload = spec.buildRequests(bidRequests, {}).data; + expect(payload).to.not.have.deep.nested.property('regs.ext.us_privacy'); + }); + + it('should have both gdpr and us_privacy', function() { + const bidderRequest = { + gdprConsent: { + consentString: 'BOJObISOJObISAABAAENAA4AAAAAoAAA', + gdprApplies: true + }, + uspConsent: '1NYN' + }; + + const payload = spec.buildRequests(bidRequests, bidderRequest).data; + expect(payload).to.have.deep.nested.property('user.ext.consent', 'BOJObISOJObISAABAAENAA4AAAAAoAAA'); + expect(payload).to.have.deep.nested.property('regs.ext.gdpr', 1); + expect(payload).to.have.deep.nested.property('regs.ext.us_privacy', '1NYN'); + }); + }); + describe('Extended ID', function() { it('Verify unifiedid and liveramp', function() { // clone bidRequests From 7c0c732805b0a43e8ef0559386f2d93ac9c00817 Mon Sep 17 00:00:00 2001 From: Anand Venkatraman Date: Tue, 10 Dec 2019 21:26:39 -0500 Subject: [PATCH 23/41] PulsePoint: CCPA and new UserId partner integration (#4565) * ET-1691: Pulsepoint Analytics adapter for Prebid. (#1) * ET-1691: Adding pulsepoint analytics and tests for pulsepoint adapter * ET-1691: Adding pulsepoint analytics and tests for pulsepoint adapter * ET-1691: cleanup * ET-1691: minor * ET-1691: revert package.json change * Adding bidRequest to bidFactory.createBid method as per https://github.com/prebid/Prebid.js/issues/509 * ET-1765: Adding support for additional params in PulsePoint adapter (#2) * ET-1850: Fixing https://github.com/prebid/Prebid.js/issues/866 * Minor fix * Adding mandatory parameters to Bid * PulsePoint: CCPA and new user id partner integration * Review comment --- modules/pulsepointBidAdapter.js | 53 +++++++++++++--- .../spec/modules/pulsepointBidAdapter_spec.js | 62 +++++++++++++++++-- 2 files changed, 100 insertions(+), 15 deletions(-) diff --git a/modules/pulsepointBidAdapter.js b/modules/pulsepointBidAdapter.js index c3fd1fa5eaf1..b898618673e0 100644 --- a/modules/pulsepointBidAdapter.js +++ b/modules/pulsepointBidAdapter.js @@ -397,9 +397,31 @@ function user(bidRequest, bidderRequest) { if (bidRequest.userId) { ext.eids = []; addExternalUserId(ext.eids, bidRequest.userId.pubcid, 'pubcommon'); - addExternalUserId(ext.eids, bidRequest.userId.tdid, 'ttdid'); - addExternalUserId(ext.eids, utils.deepAccess(bidRequest.userId.digitrustid, 'data.id'), 'digitrust'); - addExternalUserId(ext.eids, bidRequest.userId.id5id, 'id5id'); + addExternalUserId(ext.eids, bidRequest.userId.britepoolid, 'britepool.com'); + addExternalUserId(ext.eids, bidRequest.userId.criteoId, 'criteo'); + addExternalUserId(ext.eids, bidRequest.userId.idl_env, 'identityLink'); + addExternalUserId(ext.eids, bidRequest.userId.id5id, 'id5-sync.com'); + addExternalUserId(ext.eids, bidRequest.userId.parrableid, 'parrable.com'); + // liveintent + if (bidRequest.userId.lipb && bidRequest.userId.lipb.lipbid) { + addExternalUserId(ext.eids, bidRequest.userId.lipb.lipbid, 'liveintent.com'); + } + // TTD + addExternalUserId(ext.eids, bidRequest.userId.tdid, 'adserver.org', { + rtiPartner: 'TDID' + }); + // digitrust + const digitrustResponse = bidRequest.userId.digitrustid; + if (digitrustResponse && digitrustResponse.data) { + var digitrust = {}; + if (digitrustResponse.data.id) { + digitrust.id = digitrustResponse.data.id; + } + if (digitrustResponse.data.keyv) { + digitrust.keyv = digitrustResponse.data.keyv; + } + ext.digitrust = digitrust; + } } } return { ext }; @@ -408,13 +430,15 @@ function user(bidRequest, bidderRequest) { /** * Produces external userid object in ortb 3.0 model. */ -function addExternalUserId(eids, value, source) { - if (value) { +function addExternalUserId(eids, id, source, uidExt) { + if (id) { + var uid = { id }; + if (uidExt) { + uid.ext = uidExt; + } eids.push({ source, - uids: [{ - id: value - }] + uids: [ uid ] }); } } @@ -423,8 +447,17 @@ function addExternalUserId(eids, value, source) { * Produces the regulations ortb object */ function regs(bidderRequest) { - if (bidderRequest && bidderRequest.gdprConsent) { - return { ext: { gdpr: bidderRequest.gdprConsent.gdprApplies ? 1 : 0 } }; + if (bidderRequest.gdprConsent || bidderRequest.uspConsent) { + var ext = {}; + // GDPR applies attribute (actual consent value is in user object) + if (bidderRequest.gdprConsent) { + ext.gdpr = bidderRequest.gdprConsent.gdprApplies ? 1 : 0; + } + // CCPA + if (bidderRequest.uspConsent) { + ext.us_privacy = bidderRequest.uspConsent; + } + return { ext }; } return null; } diff --git a/test/spec/modules/pulsepointBidAdapter_spec.js b/test/spec/modules/pulsepointBidAdapter_spec.js index b62b799c8a01..6ab05a0a0010 100644 --- a/test/spec/modules/pulsepointBidAdapter_spec.js +++ b/test/spec/modules/pulsepointBidAdapter_spec.js @@ -431,6 +431,20 @@ describe('PulsePoint Adapter Tests', function () { expect(ortbRequest.regs.ext.gdpr).to.equal(1); }); + it('Verify CCPA', function () { + const bidderRequestUSPrivacy = { + uspConsent: '1YYY' + }; + const request = spec.buildRequests(slotConfigs, Object.assign({}, bidderRequest, bidderRequestUSPrivacy)); + expect(request.url).to.equal('https://bid.contextweb.com/header/ortb?src=prebid'); + expect(request.method).to.equal('POST'); + const ortbRequest = request.data; + // regs object + expect(ortbRequest.regs).to.not.equal(null); + expect(ortbRequest.regs.ext).to.not.equal(null); + expect(ortbRequest.regs.ext.us_privacy).to.equal('1YYY'); + }); + it('Verify Video request', function () { const request = spec.buildRequests(videoSlotConfig, bidderRequest); expect(request.url).to.equal('https://bid.contextweb.com/header/ortb?src=prebid'); @@ -592,15 +606,53 @@ describe('PulsePoint Adapter Tests', function () { expect(ortbRequest.user).to.not.be.undefined; expect(ortbRequest.user.ext).to.not.be.undefined; expect(ortbRequest.user.ext.eids).to.not.be.undefined; - expect(ortbRequest.user.ext.eids).to.have.lengthOf(3); + expect(ortbRequest.user.ext.eids).to.have.lengthOf(2); expect(ortbRequest.user.ext.eids[0].source).to.equal('pubcommon'); expect(ortbRequest.user.ext.eids[0].uids).to.have.lengthOf(1); expect(ortbRequest.user.ext.eids[0].uids[0].id).to.equal('userid_pubcid'); - expect(ortbRequest.user.ext.eids[1].source).to.equal('ttdid'); + expect(ortbRequest.user.ext.eids[1].source).to.equal('adserver.org'); expect(ortbRequest.user.ext.eids[1].uids).to.have.lengthOf(1); expect(ortbRequest.user.ext.eids[1].uids[0].id).to.equal('userid_ttd'); - expect(ortbRequest.user.ext.eids[2].source).to.equal('digitrust'); - expect(ortbRequest.user.ext.eids[2].uids).to.have.lengthOf(1); - expect(ortbRequest.user.ext.eids[2].uids[0].id).to.equal('userid_digitrust'); + expect(ortbRequest.user.ext.eids[1].uids[0].ext).to.not.be.null; + expect(ortbRequest.user.ext.eids[1].uids[0].ext.rtiPartner).to.equal('TDID'); + expect(ortbRequest.user.ext.digitrust).to.not.be.null; + expect(ortbRequest.user.ext.digitrust.id).to.equal('userid_digitrust'); + expect(ortbRequest.user.ext.digitrust.keyv).to.equal(4); + }); + it('Verify new external user id partners', function () { + const bidRequests = deepClone(slotConfigs); + bidRequests[0].userId = { + britepoolid: 'britepool_id123', + criteoId: 'criteo_id234', + idl_env: 'idl_id123', + id5id: 'id5id_234', + parrableid: 'parrable_id234', + lipb: { + lipbid: 'liveintent_id123' + } + }; + const userVerify = function(obj, source, id) { + expect(obj).to.deep.equal({ + source, + uids: [{ + id + }] + }); + }; + const request = spec.buildRequests(bidRequests, bidderRequest); + expect(request).to.be.not.null; + const ortbRequest = request.data; + expect(request.data).to.be.not.null; + // user object + expect(ortbRequest.user).to.not.be.undefined; + expect(ortbRequest.user.ext).to.not.be.undefined; + expect(ortbRequest.user.ext.eids).to.not.be.undefined; + expect(ortbRequest.user.ext.eids).to.have.lengthOf(6); + userVerify(ortbRequest.user.ext.eids[0], 'britepool.com', 'britepool_id123'); + userVerify(ortbRequest.user.ext.eids[1], 'criteo', 'criteo_id234'); + userVerify(ortbRequest.user.ext.eids[2], 'identityLink', 'idl_id123'); + userVerify(ortbRequest.user.ext.eids[3], 'id5-sync.com', 'id5id_234'); + userVerify(ortbRequest.user.ext.eids[4], 'parrable.com', 'parrable_id234'); + userVerify(ortbRequest.user.ext.eids[5], 'liveintent.com', 'liveintent_id123'); }); }); From 745fc123e002e00c52ff2bda91a186949ba4ab87 Mon Sep 17 00:00:00 2001 From: Nick Peceniak Date: Tue, 10 Dec 2019 20:03:23 -0700 Subject: [PATCH 24/41] Add support for TradeDeskID in spotxBidAdapter. (#4564) * Add support for TradeDeskID in spotxBidAdapter. * Update spotxBidAdapter.js --- modules/spotxBidAdapter.js | 30 ++++++++++++++++++----- test/spec/modules/spotxBidAdapter_spec.js | 12 ++++++++- 2 files changed, 35 insertions(+), 7 deletions(-) diff --git a/modules/spotxBidAdapter.js b/modules/spotxBidAdapter.js index cfa308a8670e..ef07190de5db 100644 --- a/modules/spotxBidAdapter.js +++ b/modules/spotxBidAdapter.js @@ -212,12 +212,15 @@ export const spec = { // ID5 fied if (bid && bid.userId && bid.userId.id5id) { - userExt.eids = [{ - source: 'id5-sync.com', - uids: [{ - id: bid.userId.id5id - }] - }]; + userExt.eids = userExt.eids || []; + userExt.eids.push( + { + source: 'id5-sync.com', + uids: [{ + id: bid.userId.id5id + }] + } + ) } // Add common id if available @@ -234,6 +237,21 @@ export const spec = { }; } + if (bid && bid.userId && bid.userId.tdid) { + userExt.eids = userExt.eids || []; + userExt.eids.push( + { + source: 'adserver.org', + uids: [{ + id: bid.userId.tdid, + ext: { + rtiPartner: 'TDID' + } + }] + } + ) + } + // Only add the user object if it's not empty if (!utils.isEmpty(userExt)) { requestPayload.user = { ext: userExt }; diff --git a/test/spec/modules/spotxBidAdapter_spec.js b/test/spec/modules/spotxBidAdapter_spec.js index d1662e162aa5..be550e8fc837 100644 --- a/test/spec/modules/spotxBidAdapter_spec.js +++ b/test/spec/modules/spotxBidAdapter_spec.js @@ -148,7 +148,8 @@ describe('the spotx adapter', function () { }; bid.userId = { - id5id: 'id5id_1' + id5id: 'id5id_1', + tdid: 'tdid_1' }; bid.crumbs = { @@ -192,6 +193,15 @@ describe('the spotx adapter', function () { uids: [{ id: 'id5id_1' }] + }, + { + source: 'adserver.org', + uids: [{ + id: 'tdid_1', + ext: { + rtiPartner: 'TDID' + } + }] }], fpc: 'pubcid_1' }) From 11e8113f35a75293ff36a6b2c98bafddb36d3d94 Mon Sep 17 00:00:00 2001 From: Dan Bogdan <43830380+EMXDigital@users.noreply.github.com> Date: Tue, 10 Dec 2019 22:05:42 -0500 Subject: [PATCH 25/41] adding ccpa support for emx_digital adapter (#4563) * adding ccpa support for emx_digital adapter * emx_digital ccpa compliance: lint fix --- modules/emx_digitalBidAdapter.js | 5 ++++- test/spec/modules/emx_digitalBidAdapter_spec.js | 8 ++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/modules/emx_digitalBidAdapter.js b/modules/emx_digitalBidAdapter.js index 7167f9018aa5..0768c8386fb0 100644 --- a/modules/emx_digitalBidAdapter.js +++ b/modules/emx_digitalBidAdapter.js @@ -7,7 +7,7 @@ import includes from 'core-js/library/fn/array/includes'; const BIDDER_CODE = 'emx_digital'; const ENDPOINT = 'hb.emxdgt.com'; const RENDERER_URL = '//js.brealtime.com/outstream/1.30.0/bundle.js'; -const ADAPTER_VERSION = '1.41.1'; +const ADAPTER_VERSION = '1.41.2'; const DEFAULT_CUR = 'USD'; export const emxAdapter = { @@ -230,6 +230,9 @@ export const spec = { }; emxData = emxAdapter.getGdpr(bidRequest, Object.assign({}, emxData)); + if (bidRequest && bidRequest.uspConsent) { + emxData.us_privacy = bidRequest.uspConsent + } return { method: 'POST', url: url, diff --git a/test/spec/modules/emx_digitalBidAdapter_spec.js b/test/spec/modules/emx_digitalBidAdapter_spec.js index 80fd12a237c6..525e5808e400 100644 --- a/test/spec/modules/emx_digitalBidAdapter_spec.js +++ b/test/spec/modules/emx_digitalBidAdapter_spec.js @@ -355,6 +355,14 @@ describe('emx_digital Adapter', function () { expect(request.regs.ext).to.have.property('gdpr', 0); expect(request).to.not.have.property('user'); }); + it('should add us privacy info to request', function() { + let consentString = '1YNN'; + bidderRequest.uspConsent = consentString; + let request = spec.buildRequests(bidderRequest.bids, bidderRequest); + request = JSON.parse(request.data); + expect(request.us_privacy).to.exist; + expect(request.us_privacy).to.exist.and.to.equal(consentString); + }); }); describe('interpretResponse', function () { From 8593acc064e43d0a756d1779eb922cbc07fd3a0c Mon Sep 17 00:00:00 2001 From: dpapworth-qc <50959025+dpapworth-qc@users.noreply.github.com> Date: Wed, 11 Dec 2019 03:08:04 +0000 Subject: [PATCH 26/41] QC CCPA support (#4557) * Pass uspConsent parameter from bidder request to QC endpoint. * Added uspSignal to indicate if uspConsent has been passed in request. --- modules/quantcastBidAdapter.js | 6 ++++-- test/spec/modules/quantcastBidAdapter_spec.js | 21 +++++++++++++++---- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/modules/quantcastBidAdapter.js b/modules/quantcastBidAdapter.js index 673a7f41c000..93f8e398a9db 100644 --- a/modules/quantcastBidAdapter.js +++ b/modules/quantcastBidAdapter.js @@ -101,8 +101,8 @@ export const spec = { */ buildRequests(bidRequests, bidderRequest) { const bids = bidRequests || []; - const gdprConsent = (bidderRequest && bidderRequest.gdprConsent) ? bidderRequest.gdprConsent : {}; - + const gdprConsent = utils.deepAccess(bidderRequest, 'gdprConsent') || {}; + const uspConsent = utils.deepAccess(bidderRequest, 'uspConsent'); const referrer = utils.deepAccess(bidderRequest, 'refererInfo.referer'); const page = utils.deepAccess(bidderRequest, 'refererInfo.canonicalUrl') || config.getConfig('pageUrl') || utils.deepAccess(window, 'location.href'); const domain = getDomain(page); @@ -139,6 +139,8 @@ export const spec = { bidId: bid.bidId, gdprSignal: gdprConsent.gdprApplies ? 1 : 0, gdprConsent: gdprConsent.consentString, + uspSignal: uspConsent ? 1 : 0, + uspConsent, prebidJsVersion: '$prebid.version$' }; diff --git a/test/spec/modules/quantcastBidAdapter_spec.js b/test/spec/modules/quantcastBidAdapter_spec.js index b91536689dbe..7e7d47d36442 100644 --- a/test/spec/modules/quantcastBidAdapter_spec.js +++ b/test/spec/modules/quantcastBidAdapter_spec.js @@ -137,6 +137,7 @@ describe('Quantcast adapter', function () { }, bidId: '2f7b179d443f14', gdprSignal: 0, + uspSignal: 0, prebidJsVersion: '$prebid.version$' }; @@ -203,6 +204,7 @@ describe('Quantcast adapter', function () { }, bidId: '2f7b179d443f14', gdprSignal: 0, + uspSignal: 0, prebidJsVersion: '$prebid.version$' }; @@ -237,6 +239,7 @@ describe('Quantcast adapter', function () { }, bidId: '2f7b179d443f14', gdprSignal: 0, + uspSignal: 0, prebidJsVersion: '$prebid.version$' }; @@ -267,6 +270,7 @@ describe('Quantcast adapter', function () { }, bidId: '2f7b179d443f14', gdprSignal: 0, + uspSignal: 0, prebidJsVersion: '$prebid.version$' }; @@ -329,6 +333,7 @@ describe('Quantcast adapter', function () { }, bidId: '2f7b179d443f14', gdprSignal: 0, + uspSignal: 0, prebidJsVersion: '$prebid.version$' }; @@ -337,11 +342,19 @@ describe('Quantcast adapter', function () { }); it('propagates GDPR consent string and signal', function () { - const gdprConsent = { gdprApplies: true, consentString: 'consentString' } - const requests = qcSpec.buildRequests([bidRequest], { gdprConsent }); - const parsed = JSON.parse(requests[0].data) + const bidderRequest = { gdprConsent: { gdprApplies: true, consentString: 'consentString' } } + const requests = qcSpec.buildRequests([bidRequest], bidderRequest); + const parsed = JSON.parse(requests[0].data); expect(parsed.gdprSignal).to.equal(1); - expect(parsed.gdprConsent).to.equal(gdprConsent.consentString); + expect(parsed.gdprConsent).to.equal('consentString'); + }); + + it('propagates US Privacy/CCPA consent information', function () { + const bidderRequest = { uspConsent: 'consentString' } + const requests = qcSpec.buildRequests([bidRequest], bidderRequest); + const parsed = JSON.parse(requests[0].data); + expect(parsed.uspSignal).to.equal(1); + expect(parsed.uspConsent).to.equal('consentString'); }); describe('`interpretResponse`', function () { From 317aaa308bf80137d440ec42bb42c62d7c76f3a2 Mon Sep 17 00:00:00 2001 From: DeepthiNeeladri Date: Wed, 11 Dec 2019 08:39:53 +0530 Subject: [PATCH 27/41] Onevideo Adaptor ccpa support (#4558) * outstream changes * removing global filtet * reverting page * message * adapter change * remove space * testcases * testpage * spaces for test page * renderer exist case * reverting package-lock.json * adding schain object * adding tagid * syntaxx error fix * video.html * space trailing * space * tagid * inventoryId and placement * rewarded video * added unit test case * ccpa cahnges * ccpa change * test page * test page change * test page change 2 * change the variable --- modules/oneVideoBidAdapter.js | 7 +++++++ test/spec/modules/oneVideoBidAdapter_spec.js | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/modules/oneVideoBidAdapter.js b/modules/oneVideoBidAdapter.js index 7e8bd3ad2880..f125d88c80c8 100644 --- a/modules/oneVideoBidAdapter.js +++ b/modules/oneVideoBidAdapter.js @@ -243,6 +243,13 @@ function getRequestData(bid, consentData, bidRequest) { }; } } + if (bidRequest && bidRequest.uspConsent) { + bidData.regs = { + ext: { + us_privacy: bidRequest.uspConsent + } + }; + } return bidData; } diff --git a/test/spec/modules/oneVideoBidAdapter_spec.js b/test/spec/modules/oneVideoBidAdapter_spec.js index d46bba038b28..3d21601387bf 100644 --- a/test/spec/modules/oneVideoBidAdapter_spec.js +++ b/test/spec/modules/oneVideoBidAdapter_spec.js @@ -203,6 +203,7 @@ describe('OneVideoBidAdapter', function () { 'consentString': 'test-gdpr-consent-string', 'gdprApplies': true }, + 'uspConsent\'s': '1YN-', 'bidderCode': 'oneVideo', 'auctionId': 'e158486f-8c7f-472f-94ce-b0cbfbb50ab4', 'bidderRequestId': '1e498b84fffc39', @@ -237,6 +238,11 @@ describe('OneVideoBidAdapter', function () { expect(request[0].data.user.ext.consent).to.equal(bidderRequest.gdprConsent.consentString); }); + it('should send the uspConsent string', function () { + const request = spec.buildRequests([ bidRequest ], bidderRequest); + expect(request[0].data.regs.ext.us_privacy).to.equal(bidderRequest.uspConsent); + }); + it('should send schain object', function () { const requests = spec.buildRequests([ bidRequest ], bidderRequest); const data = requests[0].data; From 01450f55934410228cb231ba2b5ef6a6ee54397f Mon Sep 17 00:00:00 2001 From: Harshad Mane Date: Tue, 10 Dec 2019 19:24:41 -0800 Subject: [PATCH 28/41] PubMatic to send test:1 in the request if pubmaticTest=true is present in URL (#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 --- modules/pubmaticBidAdapter.js | 5 +++++ modules/pubmaticBidAdapter.md | 5 ++++- test/spec/modules/pubmaticBidAdapter_spec.js | 18 ++++++++++++++++-- 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/modules/pubmaticBidAdapter.js b/modules/pubmaticBidAdapter.js index 358fd7bcf3a8..cf4ccee17d0c 100644 --- a/modules/pubmaticBidAdapter.js +++ b/modules/pubmaticBidAdapter.js @@ -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 = { diff --git a/modules/pubmaticBidAdapter.md b/modules/pubmaticBidAdapter.md index 1948acba40fa..fc7766430a25 100644 --- a/modules/pubmaticBidAdapter.md +++ b/modules/pubmaticBidAdapter.md @@ -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 + diff --git a/test/spec/modules/pubmaticBidAdapter_spec.js b/test/spec/modules/pubmaticBidAdapter_spec.js index f0c97cd72f3a..85d135d9f790 100644 --- a/test/spec/modules/pubmaticBidAdapter_spec.js +++ b/test/spec/modules/pubmaticBidAdapter_spec.js @@ -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 From 04c775f13078acc10f204be3ac4e49b0768d899e Mon Sep 17 00:00:00 2001 From: Samuel Adu Date: Wed, 11 Dec 2019 03:27:30 +0000 Subject: [PATCH 29/41] Pass CCPA consent string to all endpoints (#4536) --- modules/aolBidAdapter.js | 47 +++---- test/spec/modules/aolBidAdapter_spec.js | 168 +++++++++++++++++++++--- 2 files changed, 175 insertions(+), 40 deletions(-) diff --git a/modules/aolBidAdapter.js b/modules/aolBidAdapter.js index c065828c10d1..434593fbf58a 100644 --- a/modules/aolBidAdapter.js +++ b/modules/aolBidAdapter.js @@ -106,7 +106,11 @@ export const spec = { return isMarketplaceBid(bid) || isMobileBid(bid); }, buildRequests(bids, bidderRequest) { - let consentData = bidderRequest ? bidderRequest.gdprConsent : null; + const consentData = {}; + if (bidderRequest) { + consentData.gdpr = bidderRequest.gdprConsent; + consentData.uspConsent = bidderRequest.uspConsent; + } return bids.map(bid => { const endpointCode = resolveEndpointCode(bid); @@ -230,7 +234,7 @@ export const spec = { } return (url.indexOf('//') === 0) ? `${DEFAULT_PROTO}:${url}` : `${DEFAULT_PROTO}://${url}`; }, - formatMarketplaceDynamicParams(params = {}, consentData) { + formatMarketplaceDynamicParams(params = {}, consentData = {}) { let queryParams = {}; if (params.bidFloor) { @@ -247,7 +251,7 @@ export const spec = { return paramsFormatted; }, - formatOneMobileDynamicParams(params = {}, consentData) { + formatOneMobileDynamicParams(params = {}, consentData = {}) { if (this.isSecureProtocol()) { params.secure = NUMERIC_VALUES.TRUE; } @@ -261,32 +265,27 @@ export const spec = { return paramsFormatted; }, - buildOpenRtbRequestData(bid, consentData) { + buildOpenRtbRequestData(bid, consentData = {}) { let openRtbObject = { id: bid.params.id, imp: bid.params.imp }; - if (this.isConsentRequired(consentData)) { - openRtbObject.regs = { - ext: { - gdpr: NUMERIC_VALUES.TRUE - } - }; - - if (consentData.consentString) { - openRtbObject.user = { - ext: { - consent: consentData.consentString - } - }; + if (this.isEUConsentRequired(consentData)) { + utils.deepSetValue(openRtbObject, 'regs.ext.gdpr', NUMERIC_VALUES.TRUE); + if (consentData.gdpr.consentString) { + utils.deepSetValue(openRtbObject, 'user.ext.consent', consentData.gdpr.consentString); } } + if (consentData.uspConsent) { + utils.deepSetValue(openRtbObject, 'regs.ext.us_privacy', consentData.uspConsent); + } + return openRtbObject; }, - isConsentRequired(consentData) { - return !!(consentData && consentData.gdprApplies); + isEUConsentRequired(consentData) { + return !!(consentData && consentData.gdpr && consentData.gdpr.gdprApplies); }, formatKeyValues(keyValues) { let keyValuesHash = {}; @@ -300,14 +299,18 @@ export const spec = { formatConsentData(consentData) { let params = {}; - if (this.isConsentRequired(consentData)) { + if (this.isEUConsentRequired(consentData)) { params.gdpr = NUMERIC_VALUES.TRUE; - if (consentData.consentString) { - params.euconsent = consentData.consentString; + if (consentData.gdpr.consentString) { + params.euconsent = consentData.gdpr.consentString; } } + if (consentData.uspConsent) { + params.us_privacy = consentData.uspConsent; + } + return params; }, parsePixelItems(pixels) { diff --git a/test/spec/modules/aolBidAdapter_spec.js b/test/spec/modules/aolBidAdapter_spec.js index 8386c2c2462d..0f99901bce41 100644 --- a/test/spec/modules/aolBidAdapter_spec.js +++ b/test/spec/modules/aolBidAdapter_spec.js @@ -495,6 +495,94 @@ describe('AolAdapter', function () { }); }); + describe('buildOpenRtbRequestData', () => { + const bid = { + params: { + id: 'bid-id', + imp: [] + } + }; + let euConsentRequiredStub; + + beforeEach(function () { + euConsentRequiredStub = sinon.stub(spec, 'isEUConsentRequired'); + }); + + afterEach(function () { + euConsentRequiredStub.restore(); + }); + + it('returns the basic bid info when regulation data is omitted', () => { + expect(spec.buildOpenRtbRequestData(bid)).to.deep.equal({ + id: 'bid-id', + imp: [] + }); + }); + + it('returns the basic bid info with gdpr data when gdpr consent data is included', () => { + let consentData = { + gdpr: { + consentString: 'someEUConsent' + } + }; + euConsentRequiredStub.returns(true); + expect(spec.buildOpenRtbRequestData(bid, consentData)).to.deep.equal({ + id: 'bid-id', + imp: [], + regs: { + ext: { + gdpr: 1 + } + }, + user: { + ext: { + consent: 'someEUConsent' + } + } + }); + }); + + it('returns the basic bid info with CCPA data when CCPA consent data is included', () => { + let consentData = { + uspConsent: 'someUSPConsent' + }; + expect(spec.buildOpenRtbRequestData(bid, consentData)).to.deep.equal({ + id: 'bid-id', + imp: [], + regs: { + ext: { + us_privacy: 'someUSPConsent' + } + } + }); + }); + + it('returns the basic bid info with GDPR and CCPA data when GDPR and CCPA consent data is included', () => { + let consentData = { + gdpr: { + consentString: 'someEUConsent' + }, + uspConsent: 'someUSPConsent' + }; + euConsentRequiredStub.returns(true); + expect(spec.buildOpenRtbRequestData(bid, consentData)).to.deep.equal({ + id: 'bid-id', + imp: [], + regs: { + ext: { + gdpr: 1, + us_privacy: 'someUSPConsent' + } + }, + user: { + ext: { + consent: 'someEUConsent' + } + } + }); + }); + }); + describe('getUserSyncs()', function () { let serverResponses; let bidResponse; @@ -545,36 +633,42 @@ describe('AolAdapter', function () { }); }); - describe('isConsentRequired()', function () { + describe('isEUConsentRequired()', function () { it('should return false when consentData object is not present', function () { - expect(spec.isConsentRequired(null)).to.be.false; + expect(spec.isEUConsentRequired(null)).to.be.false; }); it('should return true when gdprApplies equals true and consentString is not present', function () { let consentData = { - consentString: null, - gdprApplies: true + gdpr: { + consentString: null, + gdprApplies: true + } }; - expect(spec.isConsentRequired(consentData)).to.be.true; + expect(spec.isEUConsentRequired(consentData)).to.be.true; }); it('should return false when consentString is present and gdprApplies equals false', function () { let consentData = { - consentString: 'consent-string', - gdprApplies: false + gdpr: { + consentString: 'consent-string', + gdprApplies: false + } }; - expect(spec.isConsentRequired(consentData)).to.be.false; + expect(spec.isEUConsentRequired(consentData)).to.be.false; }); it('should return true when consentString is present and gdprApplies equals true', function () { let consentData = { - consentString: 'consent-string', - gdprApplies: true + gdpr: { + consentString: 'consent-string', + gdprApplies: true + } }; - expect(spec.isConsentRequired(consentData)).to.be.true; + expect(spec.isEUConsentRequired(consentData)).to.be.true; }); }); @@ -596,7 +690,7 @@ describe('AolAdapter', function () { expect(spec.formatMarketplaceDynamicParams()).to.be.equal(''); }); - it('should return formatted params when formatConsentData returns data', function () { + it('should return formatted EU consent params when formatConsentData returns GDPR data', function () { formatConsentDataStub.returns({ euconsent: 'test-consent', gdpr: 1 @@ -604,6 +698,23 @@ describe('AolAdapter', function () { expect(spec.formatMarketplaceDynamicParams()).to.be.equal('euconsent=test-consent;gdpr=1;'); }); + it('should return formatted US privacy params when formatConsentData returns USP data', function () { + formatConsentDataStub.returns({ + us_privacy: 'test-usp-consent' + }); + expect(spec.formatMarketplaceDynamicParams()).to.be.equal('us_privacy=test-usp-consent;'); + }); + + it('should return formatted EU and USP consent params when formatConsentData returns all data', function () { + formatConsentDataStub.returns({ + euconsent: 'test-consent', + gdpr: 1, + us_privacy: 'test-usp-consent' + }); + expect(spec.formatMarketplaceDynamicParams()).to.be.equal( + 'euconsent=test-consent;gdpr=1;us_privacy=test-usp-consent;'); + }); + it('should return formatted params when formatKeyValues returns data', function () { formatKeyValuesStub.returns({ param1: 'val1', @@ -622,16 +733,16 @@ describe('AolAdapter', function () { }); describe('formatOneMobileDynamicParams()', function () { - let consentRequiredStub; + let euConsentRequiredStub; let secureProtocolStub; beforeEach(function () { - consentRequiredStub = sinon.stub(spec, 'isConsentRequired'); + euConsentRequiredStub = sinon.stub(spec, 'isEUConsentRequired'); secureProtocolStub = sinon.stub(spec, 'isSecureProtocol'); }); afterEach(function () { - consentRequiredStub.restore(); + euConsentRequiredStub.restore(); secureProtocolStub.restore(); }); @@ -648,14 +759,35 @@ describe('AolAdapter', function () { expect(spec.formatOneMobileDynamicParams(params)).to.contain('¶m1=val1¶m2=val2¶m3=val3'); }); - it('should return formatted gdpr params when isConsentRequired returns true', function () { + it('should return formatted gdpr params when isEUConsentRequired returns true', function () { let consentData = { - consentString: 'test-consent' + gdpr: { + consentString: 'test-consent' + } }; - consentRequiredStub.returns(true); + euConsentRequiredStub.returns(true); expect(spec.formatOneMobileDynamicParams({}, consentData)).to.be.equal('&gdpr=1&euconsent=test-consent'); }); + it('should return formatted US privacy params when consentData contains USP data', function () { + let consentData = { + uspConsent: 'test-usp-consent' + }; + expect(spec.formatMarketplaceDynamicParams({}, consentData)).to.be.equal('us_privacy=test-usp-consent;'); + }); + + it('should return formatted EU and USP consent params when consentData contains gdpr and usp values', function () { + euConsentRequiredStub.returns(true); + let consentData = { + gdpr: { + consentString: 'test-consent' + }, + uspConsent: 'test-usp-consent' + }; + expect(spec.formatMarketplaceDynamicParams({}, consentData)).to.be.equal( + 'gdpr=1;euconsent=test-consent;us_privacy=test-usp-consent;'); + }); + it('should return formatted secure param when isSecureProtocol returns true', function () { secureProtocolStub.returns(true); expect(spec.formatOneMobileDynamicParams()).to.be.equal('&secure=1'); From ac501846f89e44016cd158771db9902085d9b781 Mon Sep 17 00:00:00 2001 From: Salomon Rada Date: Wed, 11 Dec 2019 05:31:46 +0200 Subject: [PATCH 30/41] Gamoshi: Add missing user object (#4519) * Add placement support to beachfront adapter (#4117) * fix typo on size parameter (#4122) * Long form video price bucket bugfix (#4125) * long form price bucket bugfix * updated logic to use medium as default granularity * remove unused import * use contants * move functions to auction module * Prebid 2.30.0 release * Increment pre version * Optimera added optional device param (#4105). (#4106) * Optimera added optional device param (#4105). * Updating to use deepAccess util method (#4105). * Condensing dealId check (#4105). * SupplyChain object support in Prebid (#4084) * moving dctr related code in a function * moving parsedRequest variable out of the loop and moving GDPR related block at bottom * added a todo comment * exporting hasOwn function * added functionality to pass schain object - adapter manager will validate schain object - if it is valid then only it can be passed on to all bidders - bidders do not need to validate again * changed logMessage to logError - also fixed isInteger check * Moved schain related code from adapaterManager.js to schain.js * indentation chnages * logical bug fix * added test cases for schain * PubMatic: pass schain object in request * indentation * unit test for PubMatic schain support * using isInteger from utils * moved schain as a module * indentation * removed commented code * added try-catch as the statement code was breaking CI for IE-11 * Revert "added try-catch as the statement code was breaking CI for IE-11" This reverts commit 88f495f156a5f9db894de1728ebd7c5020882f31. * added a try-catch for a staement as it was breaking CI sometimes * added schain.md for schain module * added a few links * fixed typos * simplified the approach in adpater code * trying to restart CI * Revert "trying to restart CI" This reverts commit 25f877c1e760abb950d37d58f5d007e54ac2e179. * adding support in prebidServerBidAdpater as well * bug fix * minor changes - moved consts out of function - added a error log on finding an invalid schain object * modified a comment * added name to a test case * Revert "added a try-catch for a staement as it was breaking CI sometimes" This reverts commit e9606bfd348dc16c108ec3af807b95586ece5bbe. * moving schain validation logic inside PM adapter * Revert "moving schain validation logic inside PM adapter" This reverts commit 31d00d5f957ded9c8ed184af59dd24e1177c4b35. * added validation mode: strict, relaxed, off * updated documentation * moved a comment * changed value in example * Auto detect if we can bust out of iframe (#15) (#4099) * Add HTML5 video support param to bid requests * Use const instead of var for consistency * Update supported sizes - Default size returned changed from 0x0 to 1x1 to support PrebidServer - Now will always respect the bid sizes supported when configured Co-authored-by: Josh Becker * Update maintainer contact email * Support Prebid.js User ID module - Add support for Unified ID solution of User ID module by checking for `bidRequest.userId.tdid` param in `buildRequests` method of Sharethrough's adapter - Update specs, maintain 80%+ code coverage * Update logic for changing userAgent string in tests * Add 3 pbjs callbacks to the adapter * Add comments on empty implementations * Update Sharethrough endpoint * Add logic to detect safeframe * Remove console.log statements Fix issue with clientjs detection Small refactors (linting) Co-authored-by: Josh Becker * Continue work on safeframe detection spec Co-authored-by: Josh Becker * [WIP] * update version of sharethrough adapter from 3.0.1 to 3.1.0 * create sharethroughInternal const in adapter so that we can properly stub methods for testing, and utilize utility functions * rename safeframe detection and iframe JS tag insertion code * Finish iframe handler specs Refactor spec file * Change method of detecting whether locked in a frame or not * Add logic to detect safeframe * Remove console.log statements Fix issue with clientjs detection Small refactors (linting) Co-authored-by: Josh Becker * Continue work on safeframe detection spec Co-authored-by: Josh Becker * [WIP] * update version of sharethrough adapter from 3.0.1 to 3.1.0 * create sharethroughInternal const in adapter so that we can properly stub methods for testing, and utilize utility functions * rename safeframe detection and iframe JS tag insertion code * Finish iframe handler specs Refactor spec file * Change method of detecting whether locked in a frame or not * Rubicon adapter: added sizes (#4147) * added missing comma * fixing syntax error * add logic to prefer prebid modules over external modules in build process (#4124) * add check in getModules helper function * update logic based on feedback * update node version of project * Improve Digital adapter: adding bid floor, referrer, more native fields (#4103) * Bid floor, https, native ad update * Update the ad server protocol module * Adding referrer * YIELDONE adapter - change urls to adapt https (#4139) * update: change urls to adapt https * fix test code * Added SupplyChain Object support and an onTimeout Callback (#4137) * - Implemented the 'onTimeout' callback to fire a pixel when there's a timeout. - Added the ability to serialize an schain object according to the description provided here: https://github.com/InteractiveAdvertisingBureau/openrtb/blob/master/supplychainobject.md * some mods to the schain tag generation * - added tests for schain param checking. * - fixed a malformed url for timeouts * - Removed a trailing ',' while generating a schain param. * Revert "Added SupplyChain Object support and an onTimeout Callback (#4137)" This reverts commit e61b246b45bd2c2390350eaeca693f208b1a3a24. This commit doesn't use the schain module added in #4084 * Nobid Prebid Adapter commit (#4050) * Nobid Prebid Adapter commit * Fixed global replace and unit tests * Fixed find function * Added nobidBidAdapter.md * Removed description and added "Bid Params" section. * Added test siteId 2 for testing. * Refactored the Adapter to remove most references to the nobid object. We still need the nobid object because we have a passback tag in DFP that makes reference to it. * Fix concurrent responses on the page * Cosmetic change to log an error in case of missing ad markup * Keep nobid.bidResponses cross adapters. * Added GDPR support in user sync and added test coverage. gulp test-coverage gulp view-coverage * Padding issues * Fix padding issues * Fix padding * update outstream prod url (#4104) * support pubcid and uids (#4143) * Fix misspelling and minor cleanup of schain docs (#4150) * Prebid 2.31.0 Release * Increment pre version * Rubicon: tuning logged messages (#4157) * Rubicon: tuning logged messages * Update rubiconBidAdapter.js * fixed indentation * Rubicon Video COPPA fix (#4155) * Rubicon Video COPPA fix * Unit test for Rubicon Video COPPA fix * Playground XYZ adapter - iframe usersync bug fix (#4141) * corrected user sync type * removed support for iframe usersync * added unit tests for getUserSyncs * update nvmrc file (#4162) * update gulp-footer package (#4160) * Datablocks bid/analytics adapter (#4128) * add datablocks Analytics and Bidder Adapters * remove preload param * remove preloadid * better coverage of tests * better coverage * IE doesn't support array.find * lint test * update example host * native asset id should be integer * update logic of ad_types field in appnexusBidAdapter (#4065) * Shorten SomoAudience to just Somo (#4163) * Shorten SomoAudience to just Somo * Make package-lock return * Quantcast: Fix for empty video parameters (#4145) * Copy params from bid.params.video. * Added test for missing video parameters. * Include mimes from adunit. * One Video adding Rewarded Video Feature (#4142) * outstream changes * removing global filtet * reverting page * message * adapter change * remove space * testcases * testpage * spaces for test page * renderer exist case * reverting package-lock.json * adding schain object * adding tagid * syntaxx error fix * video.html * space trailing * space * tagid * inventoryId and placement * rewarded video * added unit test case * Module to pass User Ids to DFP (#4140) * first commit * renamed * minor doc change * documentation * small change * EB * removed unused imports * minor changes * reanmaed a const * adding more methods to test shareUserIds module * unit tets cases for shareUserIds * indentation * renamed DFP to GAM * renamed shareUserIds to userIdTargeting * Update userIdTargeting.md * trying to restart CI * digitrust userId case handled * minor comment change * using auctionEnd event instead of requestBids.before * using events.on * Buzzoola bid adapter (#4127) * initial commit for buzzoola adapter * leave only banners for now * fix bid validation * change endpoint url * add video type * restore renderer * fix renderer * add fixed player sizes * switch bids * convert dimentions to strings * write tests * 100% tests * remove new DOM element creation in tests * handle empty response from server * change description * E2e tests for Native and Outstream video Ad formats. (#4116) * reorganize e2e/ tests into separate directories * new test page for e2e-banner testing * add test to check if Banner Ad is getting loaded * change location of the spec files to reflect change in test/e2e directory structure * add test case to check for generation of valid targeting keys * create Native Ad test page * add test case to check validity of the targeting keys and correct rendering of the Ad * update old browser versions to new * update browser version * update title * remove console.log statements * add basic functional test for e2e outstream video ad format * Update LockerDome adUnitId bid param (#4176) This is not a breaking change * fix several issues in appnexus video bids (#4154) * S2s testing disable client side (#4123) * Add microadBidAdapter * Remove unnecessary encodeURIComponent from microadBidAdapter * Submit Advangelists Prebid Adapter * Submit Advangelists Prebid Adapter 1.1 * Correct procudtion endpoint for prebid * analytics update with wrapper name * reverted error merge * New testServerOnly flag * Tests and a bug fix * Removed dead code * Fixes requested in review * Check each adUnit * isTestingServerOnly changes per Eric * Fixed IE 11 bug * More tests * improved test case names * New option to Include deal KVPs when enableSendAllBids === false (#4136) * new option to include KVPs which have deals when enableSendAllBids === false * updating tests to be more realistic * Prebid 2.32.0 Release * increment pre version * Rubicon doc: changing video test zone (#4187) * added schain support to sonobi adapter (#4173) * if schain config is not defined then error should not be thrown (#4165) * if schain config is not defiend then error should not be thrown * relaxed mode nodes param not defined error handled * added test cases for config validation * a curly bracket was missing in the example * Rubicon: updating test params (#4190) * myTargetBidAdapter: support currency config (#4188) * Update README.md (#4193) * Update README.md * Update README.md * cedato bid adapter instream video support (#4153) * Added adxpremium prebid analytics adapter (#4181) * feat(OAFLO-186): added support for schain (#4194) * Sonobi - send entire userid payload (#4196) * added userid param to pass the entire userId payload to sonobis bid request endpoint * removed console log git p * fixed lint * OpenX Adapter fix: updating outdated video examples (#4198) * userId - Add support for refreshing the cached user id (#4082) * [userId] Added support for refreshing the cached user id: refreshInSeconds storage parameter, related tests and implementation in id5 module * [userId] Added support for refreshing the cached user id: refreshInSeconds storage parameter, related tests and implementation in id5 module * UserId - ID5 - Updated doc with new contact point for partners * UserId - Merged getStoredValue and getStoredDate * [UserId] - ID5 - Moved back ID5 in ./modules * UserId - ID5 - Fixed incorrect GDPR condition * [UserId] - Doc update and test cleanup * Prebid 2.33.0 Release * Increment pre version * SupplyChainObject support and fires a pixel onTimeout (#4152) * - Implemented the 'onTimeout' callback to fire a pixel when there's a timeout. - Added the ability to serialize an schain object according to the description provided here: https://github.com/InteractiveAdvertisingBureau/openrtb/blob/master/supplychainobject.md * some mods to the schain tag generation * - added tests for schain param checking. * - fixed a malformed url for timeouts * - Removed a trailing ',' while generating a schain param. * - Using the schain object from validBidRequest if present. Reverting to checking if params has it if not. * - reverting changes to merge with master * - Resolving merge issues * Feature/add profile parameter (#4185) * Add optional profile parameter * EMXDigital Bid Adapter: Add video dimensions in request (#4174) * addressed feedback from #3731 ticket * removed commented code from emx test spec * logging removed from spec * flip h & w values from playerSize for video requests * adding Outstream mediaType to EMX Digital * adding device info. update to grab video param. styling changes. * add video dimensions from playerSize * fix test for video dimensions * Added keywords parameter support in TrustX Bid Adapter (#4183) * Add trustx adapter and tests for it * update integration example * Update trustx adapter * Post-review fixes of Trustx adapter * Code improvement for trustx adapter: changed default price type from gross to net * Update TrustX adapter to support the 1.0 version * Make requested changes for TrustX adapter * Updated markdown file for TrustX adapter * Fix TrustX adapter and spec file * Update TrustX adapter: r parameter was added to ad request as cache buster * Add support of gdpr to Trustx Bid Adapter * Add wtimeout to ad request params for TrustX Bid Adapter * TrustX Bid Adapter: remove last ampersand in the ad request * Update TrustX Bid Adapter to support identical uids in parameters * Update TrustX Bid Adapter to ignore bids that sizes do not match the size of the request * Update TrustX Bid Adapter to support instream and outstream video * Added wrapperType and wrapperVersion parameters in ad request for TrustX Bid Adapter * Update TrustX Bid Adapter to use refererInfo instead depricated function utils.getTopWindowUrl * HOTFIX for referrer encodind in TrustX Bid Adapter * Fix test for TrustX Bid Adapter * TrustX Bid Adapter: added keywords passing support * rubicon: avoid passing unknown position (#4207) * rubicon: not passing pos if not specified * added comment * not sending pos for video when undefined * cleaning up test * fixed unit test * correctly reference bidrequest and determine mediatype of bidresponse (#4204) * GumGum: only send gdprConsent when found (#4205) * adds digitrust module, mods gdpr from bool to int * update unit test * only send gdprconsent if present * LKQD: Use refererInfo.referer as fallback pageurl (#4210) * Refactored URL query parameter passthrough for additional values, changed SSP endpoint to v.lkqd.net, and updated associated unit tests * Use refererInfo.referer as fallback pageurl * Removed logs and testing values * [UserId] - ID5 - Fixed case when consentData is undefined (No CMP) (#4215) * create stubs for localStorage in widespaceBidAdapter test file (#4208) * added adId property to adRenderFailed event (#4097) When no bid (therefore no adUnitCode) is available in the adRenderFailed event it can be difficult to identify the erroring slot.But in almost all cases the given slot still has the adId targeting. * OpenX Adapter: Forcing https requests and adding UserID module support for LiveRamp and TTD (#4182) * OpenX Adapter: Updated requests to force https * OpenX Adapter: Added support for TTD's UnifiedID and LiveRamp's IDL * PubMatic to support userId sub-modules (#4191) * added support for pubcommon, digitrust, id5id * added support for IdentityLink * changed the source for id5 * added unit test cases * changed source param for identityLink * TripleLift support for UnifiedId and IdentityLink (#4197) * Add IdentityLink support and fix UnifiedId. It appears we've been looking for UnifiedId userIds on the bidderRequest object, when they are found on bidRequests. This commit fixes that error, and adds support for IdentityLink. * change maintainer email to group * Added lemma adapter (#4126) * lemmaBidAdapter.js Added lemma bid adapter file * lemmaBidAdapter.md Added lemma bid adapter md file * lemmaBidAdapter_spec.js Added lemma bid adapter test spec file * Update lemmaBidAdapter.js Fixed automated code review alert comparison between inconvertible types * Update lemmaBidAdapter.js Fixed review changes * Update lemmaBidAdapter.md Correct parameter value. * Adkernel adapter new alias (#4221) * Force https scheme for Criteo Bidder (#4227) * assign adapter version number * Ensure that Criteo's bidder is always called through https * Add Video Support for Datablocks Bid Adapter (#4195) * add datablocks Analytics and Bidder Adapters * remove preload param * remove preloadid * better coverage of tests * better coverage * IE doesn't support array.find * lint test * update example host * native asset id should be integer * add datablocks Video * remove isInteger * skip if empty * update adUnit, bidRequest and bidResponse object (#4180) * update adUnit, bidRequest and bidResponse object * add test for mediaTypes object * 3 display banner and video vast support for rads (#4209) * add stv adapter * remove comments from adapter file * start rads adapter * fix adapter and tests * fixes * fix adapter and doc * fix adapter * fix tests * little fix * add ip param * fix dev url * #3 radsBidAdapter.md * #3 radsBidAdapter.md: cleanup * fix code and doc * UserId - Add SameSite and server-side pubcid support (#3869) * Add SameSite and server-side pubcid support * Fix emoteevBidAdapter unit test * added schain to appnexus bid adapter (#4229) * added schain to appnexus bid adapter * semicolon * update doubleclick url (#4179) * Prebid 2.34.0 release * increment pre version * Rubi Analytics handles > 1 bidResponse per bidRequest (#4224) * videoNow bid adapter (#4088) * -- first commit * -- cors and bidder's name fixed * -- almost ready * -- added docs * -- added nurl tracking * -- bid params * -- tests added * -- test fixed * -- replace placeholder in the onBidWon pixel's url * -- commit for restart tests * -- change response data format for display ad * -- tests updated * -- 100% tests coverage * -- a few clean the test's code * -- custom urls from localStorage * -- tests updated * -- a few clean the test's code * -- new init model * -- spec for new init model * -- fix for new init model * -- code cleaned * -- 100% tests coverage * -- 100% tests coverage * -- fixed test * -- commit for restart tests * djax new bidder adapter (#4192) * djax bidder adapter * djax bidder adapter * Update hello_world.html * Added Turk Telekom Bid Adapter (#4203) * Added Turk Telekom Bid Adapter * Fix md file for Turk Telekom Bid Adapter * MicroAd: Use HTTPS in all requests (#4220) * Always use HTTPS endpoint in MicroAd * Update code * Fixed a broken test in MicroAd * Schain: avoiding Object.values as it is breaking on IE11 (#4238) * added support for pubcommon, digitrust, id5id * added support for IdentityLink * changed the source for id5 * added unit test cases * changed source param for identityLink * avoiding use of Object.values * 3952 delay auction for ids (#4115) * 3952 delay auction for user ids * 3952 add integration example * 3952 add tests * 3952 fix html example * add todos * 3952 continue auction if ids received * 3952 add tests for auction delay * increase test coverage * set config for test * remove todo * add a few more checks to tests * add comment, force tests to rerun * Feature: adUnitBidLimit (#3906) * added new feature to config to limit bids when sendallbids is enabled * cleaned up code. removed extra spaces etc * removed trailing spaces in config * remove .flat() and replaced with spread operator * removed flat function and instead pushing using spread operator * updated to use sendBidsControl instead * updated targeting_spec to test bidLimit * removed trailing spaces from targeting_spec * Update Rubicon Adapter netRevenue default (#4242) * Add microadBidAdapter * Remove unnecessary encodeURIComponent from microadBidAdapter * Submit Advangelists Prebid Adapter * Submit Advangelists Prebid Adapter 1.1 * Correct procudtion endpoint for prebid * analytics update with wrapper name * reverted error merge * update changed default value of netRevenue to true * Removed AdastaMadia from alias (#4255) * Update appnexusBidAdapter.js (#4251) * IdentityLink - change expiration time to 30 days (#4239) * Add coppa support for AppNexus adapter (#4253) * Add coppa support for AppNexus adapter * test name * add new longform e2e tests (#4206) * Konduit module (#4184) * Adding Konduit module * Removed superfluous arguments passed to obtainVastUrl function * Removed superfluous arguments passed to obtainVastUrl function. * Build trigger (empty commit) * Module documentation updated according to the comments * Logic in obtainVastUrl function updated according to the review comment. * Removed hook, enabled eslint * Circle CI runs e2e tests on every push (#4200) * run functional tests on circle ci on push to any remote branch * remove extraneous key from config file * add test.localhost as alias to 127.0.0.1 * check 0: execute circle-ci * move /etc/config to a separate command * change bid partner to rubicon * test appnexus bid adapter in ci * comment browserstack command * remove console.log statement * test1: circle-ci * change reference dev -> prod while loading prebid * add console.log statement * check-2: circle-ci * comment browserstack testing * change bid adapter * change bid adapter * remove test case for checking targeting keys * remove the ci flag * uncomment test for checking correct generation of targeting keys * swap AN -> Rubicon for testing targeting keys * Outcon bid adapter. (#4161) * Outcon bid adapter. * Fix identation * Fixes * Fixes * Fixes * Spec fixes * Fixes * Fix urls * Fix * Fix parameters * Fix space operators * Fix bidder timeout * Update * Fix whitespace * no message * Outcon unit test * no message * no message * no message * no message * Fixes * Fixes * Change url * no message * no message * no message * Added bidId * no message * no message * no message * no message * Wrapping url with html * no message * no message * no message * Adding workflow to run end to end tests (#4230) * Adding workflow to run end to end tests * trying self branch * Update to run at 12 every day * cleanup config using aliases * update branch and cron time * add command * update prebid path for e2e test pages (#4274) * Prebid 2.35.0 release * Increment pre version * Add usersync to adpone adapter (#4245) * add user sync to adpone adapter * move adpone usersync to global variable * added withcredentials to http request * fix http request options * fix http request options * add withCredentials: true * add withCredentials: true * added test coverage to usersync * update sync function * add test coverage * adpone adapter * package lock * add more testing * add more testing * testing for onBidWon fucntion * test onbidwon function * trigger build * Revert GumGum Adapter 2.28 resizing changes (#4277) * changed resizing unit tests to return the first size dimensions in the sizes array * added some changes * reverted adapter changes * SpotX Bid Adapter: Support schain, ID5 object, Google consent object, and hide_skin (#4281) * Add SpotXBidAdapter * Minor updates * Undo testing changes to shared files * Fix relative imports * Remove superfluous imports and write a few more tests * Formatting, ID5 object, Google consent objects - Added ID5 object support - Added Google Consent object - Reformatted indentaiton on spec file * Revert content_width and content_height changes in docs - not sure how these got moved, lets put them back * Remove click_to_replay flag in example - no reason to use this one in the example * Spotx adapter - Add schain support and update unit tests * Update schain path in ORTB 2.3 request body - schain object is now added to ortb request body at request.ext.source.ext.schain * Add hide_skin to documentation - whoops, this got removed, let's add it back * Update Rubicon Analytics Adapter `bidId` to match PBS (#4156) * Add microadBidAdapter * Remove unnecessary encodeURIComponent from microadBidAdapter * Submit Advangelists Prebid Adapter * Submit Advangelists Prebid Adapter 1.1 * Correct procudtion endpoint for prebid * analytics update with wrapper name * reverted error merge * update for rubicon analytics to send seat[].bid.id for PBS video and banner * fixed conditional for server and video or banner * updated with optimized value test for bidid * update changed default value of netRevenue to true * remove var declaration for rightSlot to correct lgtm error for unused variable * update defineSlot div id to match div id defined in html body * update test ad unit test props * revert lock to match remote master * add seatBidId to bidObj in rpBidAdapter interpretResponse * update setTargeting to execute in the bids back handler * remove dev integration test page * meaningless commit to get lgtm to re-run * SmartRTB adapter update (#4246) * modules: Implement SmartRTB adapter and spec. * Fix for-loop syntax to support IE; refactor getDomain out of exported set. * Remove debugs, update doc * Update test for video support * Handle missing syncs. Add video to media types in sample ad unit * Add null response check, update primary endpoint * Note smrtb video requires renderer * Support Vast Track (#4276) * Add microadBidAdapter * Remove unnecessary encodeURIComponent from microadBidAdapter * Submit Advangelists Prebid Adapter * Submit Advangelists Prebid Adapter 1.1 * Correct procudtion endpoint for prebid * analytics update with wrapper name * reverted error merge * update changed default value of netRevenue to true * Add parameters if config.cache.vasttrack is true * Use requestId instead of adId * Test new vasttrack payload params * Removed commented out code * Relaxed conditional check per review * Removed commented out line * Added 1000x250 size (#4295) * prepare vidazoo adapter for v3.0 (#4291) * Improve Digital adapter: support schain (#4286) * LiveIntent Identity Module. (#4178) * LiveIntentIdSystem. Initial implementation. * LiveIntentIdSystem. Removed whitespace. * Fixed typo * Renamed variables, cookiesm added md. * Changed the default identity url. * Composite id, with having more than just the lipbid passed around. * Composite id. * Merge conflict resolution. * Changed docs and param description. * Added typedoc & mentioned liveIntentIdSystem in submodule.json. * Extracted the LiveIntentIdSystem under modules, removed it from default userId modules. * Fixing the 204 + no body scenario. * Added liveIntent to submodule.json * Fixing docs indentation. * Updated prebidServer & specs. * Minor specs update. * updating liveintent eids source (#4300) * updating liveintent eids source these are supposed to be domains * updating unit test * fix appnexusBidAdapter view-script regex (#4289) * fix an view script regex * minor syntax update * 33Across adding bidder specific extension field (#4298) * - add 33across specific ext field for statedAt * - fix unit test for 33Across adapter * PubMatic to support LiveIntent User Id sub-module (#4306) * added support for pubcommon, digitrust, id5id * added support for IdentityLink * changed the source for id5 * added unit test cases * changed source param for identityLink * supporting LiveIntent Id in PubMatic adapter * updated source for liveintent * Finteza Analytics Adapter: fix cookies (#4292) * fix reading and sending cookies * fix lint errors * clear comments * add unit tests * fix calling of setCookies for IE * clear cookies after test * use own setCookie method inside tests * Update LockerDome adapter to support Prebid 3.0 (#4301) * Returning the `IdResponse` type with an obj + callback. Fix for 4304 (#4305) * Returning the `IdResponse` type with an obj + callback. * Renamed resp -> result. * Removed whitespace. * ShowHeroes adapter - expanded outstream support (#4222) * add ShowHeroes Adapter * ShowHeroes adapter - expanded outstream support * Revert "ShowHeroes adapter - expanded outstream support" This reverts commit bfcdb913b52012b5afbf95a84956b906518a4b51. * ShowHeroes adapter - expanded outstream support * ShowHeroes adapter - fixes (#4222) * ShowHeroes adapter - banner and outstream fixes (#4222) * ShowHeroes adapter - description and outstream changes (#4222) * ShowHeroes adapter - increase test coverage and small fix * [Orbidder-Adapter] Add bidRequestCount and remove bid.params.keyValues (#4264) * initial orbidder version in personal github repo * use adUnits from orbidder_example.html * replace obsolete functions * forgot to commit the test * check if bidderRequest object is available * try to fix weird safari/ie issue * ebayK: add more params * update orbidderBidAdapter.md * use spec. instead of this. for consistency reasons * add bidfloor parameter to params object * fix gdpr object handling * default to consentRequired: false when not explicitly given * wip - use onSetTargeting callback * add tests for onSetTargeting callback * fix params and respective tests * remove not used bid.params.keyValues * add bidRequestCount to orbidder.otto.de/bid Post request * add bidRequestCount to test object defaultBidRequest * PulsePoint: remove usage of deprecated utils method / prep for 3.0 (#4257) * ET-1691: Pulsepoint Analytics adapter for Prebid. (#1) * ET-1691: Adding pulsepoint analytics and tests for pulsepoint adapter * ET-1691: Adding pulsepoint analytics and tests for pulsepoint adapter * ET-1691: cleanup * ET-1691: minor * ET-1691: revert package.json change * Adding bidRequest to bidFactory.createBid method as per https://github.com/prebid/Prebid.js/issues/509 * ET-1765: Adding support for additional params in PulsePoint adapter (#2) * ET-1850: Fixing https://github.com/prebid/Prebid.js/issues/866 * Minor fix * Adding mandatory parameters to Bid * Removing usage of deprecated utils method * minor refactor * Use isArray method (#4288) * Add Parrable ID submodule (#4266) * add parrable id submodule * fix integration test config * fix var name * always refresh sotredId for parrable * add submodulesThatAlwaysRefresh concept * remove comment * add parrable url as one string * add parrable prod endpoint * use .indexOf instead of .includes * add params to test config * comment failing test * uncomment failing assertion * add parrable ID to prebid server adapter * add parrableIdSystem to .submodules.json * extract parrableId unit tests from userId spec * remove breakline between imports * remove unused param * remove userId generic feature from parrableId module * remove trailing space * fix failing test due to none merged conflict * Prebid 2.36.0 Release * Increment pre version * Support schain module and send bidfloor param in Sharethrough adapter (#4271) * Add support for supply chain object module Story: [#168742394](https://www.pivotaltracker.com/story/show/168742394) Co-authored-by: Josh Becker * Add bidfloor parameter to bid request sent to STX Story: [#168742573](https://www.pivotaltracker.com/story/show/168742573) * Platform One Analytics Adapter (#4233) * Added Y1 Analytics Adapter * rename y1AnalyticsAdapter in yieldoneAnalyticsAdapter * Yieldone Bid Adapter: fixes from lint check * Yieldone Analytics Adapter: fix endpoint protocol * Added spec file for yieldone Analytics Adapter * Fix parrable id integration example (#4317) * fix parrableId integration example * add parentheses * Improve Digital adapter: support for video (#4318) * Bid floor, https, native ad update * Update the ad server protocol module * Adding referrer * Improve Digital support for video * Improve Digital adapter: video * adapter version -> 6.0.0 * Gamoshi: Update aliases list. Add support for userSync. (#4319) * Add support for multi-format ad units. Add favoredMediaType property to params. * Add tests for gdpr consent. * Add adId to outbids * Modify media type resolving * Refactor multi-format ad units handler. * Modify the way of sending GDPR data. Update aliases. * Add new consent fields. Add unit test. * Add new consent fields. Add unit test. * Add support for id5 and unified id cookie sync. * Add support for id5 and unified id cookie sync. * Add restricted check for gdpr consent. * fix for userSync endpoint getting called with bidder alias names, instead of actual bidder names (#4265) * modify ixBidAdapater to always use the secure endpoint (#4323) * PubMatic to support Parrable User Id sub-module (#4324) * 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 support parrable id * VISX: currency validation & fix double escape of referer (#4299) * PubMatic to support coppa (#4336) * added support for pubcommon, digitrust, id5id * added support for IdentityLink * changed the source for id5 * added unit test cases * changed source param for identityLink * added coppa compliance * vuble: outstream has fullscreen option (#4320) * Mod: vuble oustream has fullscreen option * Add: vuble test for outstream scenario * EMXDigital: hotfix to resolve URIError from decodeURIComponent (#4333) * hotfix to resolve URIError from decodeURIComponent * added unit for decoding adm * Specify second parameter for parseInt for pubmaticBidAdapter (#4347) * Remove usage of getTopWindowUrl in Prebid Adapter (#4341) * Conversant Bid Adapter update for 3.0 (#4284) * Add cpmDistribution function for Google Analytics adapter (#4240) * Add cpmDistribution function for Google Analytics adapter * Add test for the cpmDistribution function * Remove half written comment * fixing SRA p_pos (#4337) * In Sonobi Adapter, only read sizes from bid.mediaTypes (#4311) * Fix mediaTypes (#4332) * Outcon bid adapter. * Fix identation * Fixes * Fixes * Fixes * Spec fixes * Fixes * Fix urls * Fix * Fix parameters * Fix space operators * Fix bidder timeout * Update * Fix whitespace * no message * Outcon unit test * no message * no message * no message * no message * Fixes * Fixes * Change url * no message * no message * no message * Added bidId * no message * no message * no message * no message * Wrapping url with html * no message * no message * no message * Fix mediaTypes * no message * Update outconBidAdapter_spec.js * Adding VAS response * no message * no message * no message * Fix * Changed ttl * no message * supportedMediaTypes * no message * no message * Prebid 2.37.0 release * increment pre version * Add vast xml support and other minor changes to Beachfront adapter (#4350) * Add support for vast xml in the bid response * add secure protocol to outstream player url * add device connection type * add player setting for poster color * add new value for creative Id * Update smartrtbBidAdapter (#4362) * modules: Implement SmartRTB adapter and spec. * Fix for-loop syntax to support IE; refactor getDomain out of exported set. * Remove debugs, update doc * Update test for video support * Handle missing syncs. Add video to media types in sample ad unit * Add null response check, update primary endpoint * Note smrtb video requires renderer * Remove old params checks, fix documentation playerSize field name * Revert "Update smartrtbBidAdapter (#4362)" (#4368) This reverts commit be6704bcec65a28d80b6d09a8d1c51ef9a8ba824. * Add userSync in onetagBidAdapter (#4358) * Minor bug fixing in onetagBidAdapter.js Fixed a minor bug. Updated TTL in response to align the correct specifications. * Update onetagBidAdapter Added additional page info and user sync function. * Update onetagBidAdapter_spec.js Added the test for getUserSyncs function. * Fix about userSync * getUserSyncs: test update with gdpr params * Sovrn adapter updates: schain, digitrust, pixel syncing, and 3.0 upgrades (#4335) * schain and digitrust * pixel beacons * unit tests and fixes from testing * Prebid 3.0 updates * review fix * Add bid adapter for ablida (#4256) * Add ablida adapter * rename category parameter, add documentation * AdKernel: added waardex_ak alias (#4290) * added alias Added a new alias * fixing unit test * Revert "Sovrn adapter updates: schain, digitrust, pixel syncing, and 3.0 upgrades (#4335)" (#4376) This reverts commit 6114a3dba93815dcfb535707d7b4d84f1adb2bc7. * Vrtcal Markets Inc. Bid Adapter Addition (#4259) * Added 3 key Vrtcal Adapter files: adapter,markdown,unit tests * Removed unused getUserSyncs;Added mediaTypes.banner.sizes support;Raised test coverage to 85% * lint formatting errors corrected * Update schain path in ORTB path for spotxBidAdapter (#4377) - Move schain object from request.ext.source.ext.schain to request.source.ext.schain * Update Grid Bid Adapter (#4379) * Added Grid Bid Adapter * remove priceType from TheMediaGrid Bid Adapter * Add video support in Grid Bid Adapter * Added test parameter for video slot * update Grid Bid Adapter to set size in response bid * Update Grid Bid Adapter to support identical uids in parameters * Fix typo in test file for Grid Bid Adapter * Update The Grid Media Bidder Adapter to send refererInfo.referer as 'u' parameter in ad request * Hotfix for referrer in Grid Bid Adapter * Grid Bid Adapter: added wrapperType and wrappweVersion to the ad request * TripleLift: Sending schain (#4375) * Add IdentityLink support and fix UnifiedId. It appears we've been looking for UnifiedId userIds on the bidderRequest object, when they are found on bidRequests. This commit fixes that error, and adds support for IdentityLink. * change maintainer email to group * TripleLift: Sending schain (#1) * Sending schain * null -> undefined * DistrictmDMX: adding support for schain and remove content type to default to prebid selection (#4366) * adding DMX test @97%, two files added one updated * Update districtm_spec.js * Update districtmDMX.js * adding all districtm needed file * remove legacy file * remove typo || 0 in the test method * force default to return a valid width and height * update unit test code for failing test * changed class for an object * remove package-lock.json * change file name for dmx adapter * renamed files * restaure package-lock.json * update to last package-lock state * update gdpr user consent * fix sizes issue * Documentation updates Adding the readme.md info * update file name and update unit testing import file location * current machine state * lint correction * remove variable assigment duplicate * Support for ID5 + receive meta data (#4352) * Livewrapped bid and analytics adapter * Fixed some tests for browser compatibility * Fixed some tests for browser compatibility * Changed analytics adapter code name * Fix double quote in debug message * modified how gdpr is being passed * Added support for Publisher Common ID Module * Corrections for ttr in analytics * ANalytics updates * Auction start time stamp changed * Detect recovered ad blocked requests Make it possible to pass dynamic parameters to adapter * Collect info on ad units receiving any valid bid * Support for ID5 Pass metadata from adapter * Typo in test + eids on wrong level * Rubicon Adapter: Always make requests using HTTPS (#4380) * Add microadBidAdapter * Remove unnecessary encodeURIComponent from microadBidAdapter * Submit Advangelists Prebid Adapter * Submit Advangelists Prebid Adapter 1.1 * Correct procudtion endpoint for prebid * analytics update with wrapper name * reverted error merge * update changed default value of netRevenue to true * Always make bids requests using https * rp_secure and imp.secure should always be 1 * 7xbid adapter (#4328) * 7xbid adapter * fix error when cli build * - update 33across adapter cookie sync end point (#4345) - update unit test for 33across adapter * Adform adapter: add renderer for outstream bids (#4363) * Prebid 2.38.0 Release * Increment pre version * Adagio: update with external js (#4217) * Add external loader in AdagioBidAdapter * Change adagioAnalyticsAdapter to "endpoint" type * Change _setPredictions for a generic method * Improve AdagioBidAdapter test coverage * Add features detection in Adagio adapter * Fix adagioBidAdapter tests * Add featuresVersion field to bidRequest * Refacto adagio.queue * Expose versions in ADAGIO namespace * Generate a ADAGIO.pageviewId if missing * Move ad-server events tracking to adagioBidAdapter * Store adUnitCodes in ADAGIO namespace * Update documentation Better description of test parameters. * Add internal array to prevent empty pbjs.adUnits * Be sure to access to window.top - does not work in safe-frame env * Add PrintNumber feature * Be sure to compute features on window.top * Bump versions * Add Post-Bid support - ad-server events are listen in current window (instead of window.top) - a new "outerAdUnitElementId" property is set to ADAGIO.pbjsAdUnits array in case of Post-Bid scenario. This property is the 1st parent element id attribute of the iframe in window.top. * Set pagetype param as optional * Add AdThink ad-server support * Improve internal `pbjsAdUnits.sizes` detection Use the adUnit `mediaTypes.banner.sizes` property if exists to build the `ADAGIO.pbjsAdUnits.sizes`. The use of the `sizes` root property is deprecated. * adagioAnalyticsAdapter: add and improve tests * adagioBidAdapter: add and improve tests # Conflicts: # modules/adagioBidAdapter.js # test/spec/modules/adagioBidAdapter_spec.js * adagioBidAdapter: Bump version 1.5 * Adagio: fix import path * PostBid: insure window.top is accessible for specifics functions * Consistency: use Prebid.js utils and fix deprecated * PostBid: do not build a request if in safeframe * Bump version 2.0.0 * Try to fix tests without UA stubing * Try to fix adagioAnalytics failling tests on CI * Consistency: use Prebid loadExternalScript() * Add "adagio" to Prebid.js adloader vendor whitelist * Remove proprietary ad-server listeners * Add RSA validation to adagio external script * add viewdeosDX whitelabel (#4231) * add viewdeosDX hitelabel * Fixed tests and support for sizes * Fix strings * Fix strings * remove only * Fix tests * fix codereview * Fix test + Code review * code review + tests * One video display ad (#4344) * outstream changes * removing global filtet * reverting page * message * adapter change * remove space * testcases * testpage * spaces for test page * renderer exist case * reverting package-lock.json * adding schain object * adding tagid * syntaxx error fix * video.html * space trailing * space * tagid * inventoryId and placement * rewarded video * added unit test case * testing display ad * adding banner * validating banner object * display=1 changes * checking whether diplsy == 1 * html page change * reverting video.html * adding more test cases * spaces * md file change * updated working oneVideoBidAdapter.md file * Update oneVideoBidAdapter.md * Update oneVideoBidAdapter.md * updated the file with both video params and banner * Update video.html * fix double-urlecoded referrer (#4386) * fix double-urlecoded referer (#4388) * PulsePoint Adapter - update for ttl logic (#4400) * ET-1691: Pulsepoint Analytics adapter for Prebid. (#1) * ET-1691: Adding pulsepoint analytics and tests for pulsepoint adapter * ET-1691: Adding pulsepoint analytics and tests for pulsepoint adapter * ET-1691: cleanup * ET-1691: minor * ET-1691: revert package.json change * Adding bidRequest to bidFactory.createBid method as per https://github.com/prebid/Prebid.js/issues/509 * ET-1765: Adding support for additional params in PulsePoint adapter (#2) * ET-1850: Fixing https://github.com/prebid/Prebid.js/issues/866 * Minor fix * Adding mandatory parameters to Bid * Using the TTL from the bid.ext * Minor refactor * IdentityLink - add logic for sending consent string (#4346) * Fix adagio analytics adapter circleci (#4409) * Add microadBidAdapter * Remove unnecessary encodeURIComponent from microadBidAdapter * Submit Advangelists Prebid Adapter * Submit Advangelists Prebid Adapter 1.1 * Correct procudtion endpoint for prebid * analytics update with wrapper name * reverted error merge * update changed default value of netRevenue to true * update to skip broken circleci tests * skip all * Feature/7xbid remove unneeded params (#4402) * 7xbid adapter * fix error when cli build * remove unneeded params * Empty commit * Empty commit * Remove none ssl (#4406) * adding DMX test @97%, two files added one updated * Update districtm_spec.js * Update districtmDMX.js * adding all districtm needed file * remove legacy file * remove typo || 0 in the test method * force default to return a valid width and height * update unit test code for failing test * changed class for an object * remove package-lock.json * change file name for dmx adapter * renamed files * restaure package-lock.json * update to last package-lock state * update gdpr user consent * fix sizes issue * Documentation updates Adding the readme.md info * update file name and update unit testing import file location * current machine state * lint correction * remove variable assigment duplicate * remove none ssl element from all request] * fixed reference to global object (#4412) * ucfunnel adapter support supply chain (#4383) * Add a new ucfunnel Adapter and test page * Add a new ucfunnel Adapter and test page * 1. Use prebid lib in the repo to keep updated 2. Replace var with let 3. Put JSON.parse(JSON.stringify()) into try catch block * utils.getTopWindowLocation is a function * Change to modules from adapters * Migrate to module design * [Dev Fix] Remove width and height which can be got from ad unit id * Update ucfunnelBidAdapter to fit into new spec * Correct the endpoint. Fix the error of query string * Add test case for ucfunnelBidAdapter * Fix lint error * Update version number * Combine all checks on bid request * Add GDPR support for ucfunnel adapter * Add in-stream video and native support for ucfunnel adapter * Remove demo page. Add more test cases. * Change request method from POST to GET * Remove unnecessary comment * Support vastXml and vastUrl for video request * update TTL to 30 mins * Avoid using arrow function which is not discuraged in mocha * ucfunnel tdid support * ucfunnel adapter support supply chain * LiveIntent support in RP Adapter and PBS Adapter update to pass segments (#4303) * Add microadBidAdapter * Remove unnecessary encodeURIComponent from microadBidAdapter * Submit Advangelists Prebid Adapter * Submit Advangelists Prebid Adapter 1.1 * Correct procudtion endpoint for prebid * analytics update with wrapper name * reverted error merge * update changed default value of netRevenue to true * added semi-colon * update eid source to use domain * update video oRTB with liveintent segments * update pbs adapter with liveintent segments support * update rp adapter liveintent support for fastlane * reverted package lock, fix for unintentional update * added unit tests for fastlane.json and ortb, fix to join segments with commas * fix obj property path data.tpid * update remove unnecessary function call * re-ordering query string params * Rubicon Adapter: Add multiple sizes to sizeMap (#4407) * Add Utils to remove item in LocalStorage (#4355) * Making originalCpm and originalCurrency fields in bid object always available (#4396) * added support for pubcommon, digitrust, id5id * added support for IdentityLink * changed the source for id5 * added unit test cases * changed source param for identityLink * moving originalCurrency declaration from currency to bidderFactory * added a comment * trying to re-run the CI job * added unit test case * trying to re-run the CI job * Placement and inventory (#4353) * outstream changes * removing global filtet * reverting page * message * adapter change * remove space * testcases * testpage * spaces for test page * renderer exist case * reverting package-lock.json * adding schain object * adding tagid * syntaxx error fix * video.html * space trailing * space * tagid * inventoryId and placement * rewarded video * added unit test case * inventory_id and placement * removed unnecessary file * lint error * Update oneVideoBidAdapter.js * lint error fix * Fixes for Platform One Analytics Adapter (#4359) * Added Y1 Analytics Adapter * rename y1AnalyticsAdapter in yieldoneAnalyticsAdapter * Yieldone Bid Adapter: fixes from lint check * Yieldone Analytics Adapter: fix endpoint protocol * Added spec file for yieldone Analytics Adapter * Add adUnitName to analytics data for Yieldone Analytics Adapter * Fix yieldone Analytics Adapter to log only id from adUnitPath * Fix bug with timeout event in Yieldone Analytics Adapter * Added protocol to url (#4395) * initial commit * updated contact and tag details * changes ti support the renderers * changes to pass dimId * fixed names of internal mapping * added comment * added gdpr param to request and other fixes * modified api url * fix * fixed the secure api call * rolled back video event callback till we support it * updated doc with video details * added bid won and timeout pixel * added testcase for bid events * modified testcase * fixed the url logged * tag param values passed ot renderer * added a conditioal check * changes to support new param to adserver for purpose of tracking * passed param to renderer * missing variable defined * added protocol to url * fixed test for protocol * changed urls to secure only * Update emoteev endpoints (#4329) * JustPremium: Update to Prebid 3.0 (#4410) * Update underdogmedia adapter for pbjs 3.0 (#4390) * Update underdogmedia adapter for pbjs 3.0 * Ensure request to endpoint is secure * Update prebid version * Lint fix * Update Consumable adapter for Prebid.js 3.0 (#4401) * Consumable: Clean up tests. * Consumable: Update use of deprecated function. * Consumable: Read sizes from mediaTypes.banner.sizes. * Consumable: Fix lint violation. * CriteoId User Module (#4287) * Add CriteoId module * Update the return type of getId in Criteo Id module Changes: - Use of url parsing function from url lib - Update the return type of getId() - Update the jsdoc to reflect the real return types * Fix failing tests for Criteo user module * Add CriteoIdSystem submodule to .submodule.json. * 2019/10/18 Create Mobsmart bidder adapter (#4339) * Adpod deal support (#4389) * Adpod deal support * Replacing filterBids with minTier * fix potential issue * remove querystringify package (#4422) * Browsi real time data module (#4114) * real time data module, browsi sub module for real time data, new hook bidsBackCallback, fix for config unsubscribe * change timeout&primary ad server only to auctionDelay update docs * support multiple providers * change promise to callbacks configure submodule on submodules.json * bug fixes * use Prebid ajax * tests fix * Prebid 2.39.0 Release * increment pre version * OpenX Adapter: Prebid 3.0 Compatibility Update (#4413) * Removed usage of deprecated functions * Removed beacons * Banner sizes now reads from bidRequest.mediaTypes.banner.sizes instead of bidRequest.sizes * Updated tests to reflect changes. * GumGum: use mediaTypes.banner.sizes (#4416) * adds digitrust module, mods gdpr from bool to int * update unit test * only send gdprconsent if present * uses mediaTypes before trying bidRequest sizes * removes use of deprecated method * RTBhouse Bid Adapter update for 3.0 (#4428) * add viewable rendering format (#4201) * Feature/adapter (#4219) * feat(bidrequest): code for making bidrequest * feat(bidresponse): format and return the response * feat(tests): added tests for adapter * feat(docs): added docs for the adapter * refactor(url): changed adserver url * test(user sync): added unit tests for the user syncs * refactor(endpoint): changed endpoint for prebid * refactor(endpoint): changed endpoint for prebid * doc(tagid): mandatory param definition added * fix(imp id): fix for correct impression id * fix(width/height): fix for correct width and height sequence * PulsePoint Bid Adapter: Support for schain (#4433) * ET-1691: Pulsepoint Analytics adapter for Prebid. (#1) * ET-1691: Adding pulsepoint analytics and tests for pulsepoint adapter * ET-1691: Adding pulsepoint analytics and tests for pulsepoint adapter * ET-1691: cleanup * ET-1691: minor * ET-1691: revert package.json change * Adding bidRequest to bidFactory.createBid method as per https://github.com/prebid/Prebid.js/issues/509 * ET-1765: Adding support for additional params in PulsePoint adapter (#2) * ET-1850: Fixing https://github.com/prebid/Prebid.js/issues/866 * Minor fix * Adding mandatory parameters to Bid * ET-5938 SupplyChain Object Support * Formatting * Code review * Code review * Fix to currency parsing on response * Add supply chain support for Teads adapter (#4420) * Rubicon: support SupplyChain (schain) (#4315) * Add microadBidAdapter * Remove unnecessary encodeURIComponent from microadBidAdapter * Submit Advangelists Prebid Adapter * Submit Advangelists Prebid Adapter 1.1 * Correct procudtion endpoint for prebid * analytics update with wrapper name * reverted error merge * update changed default value of netRevenue to true * Starting schain * More tests for banner schain support * Video tests * Encoding tweaks, required fields and comments * Removed .only() from tests * Change requests per Bret * Add 1ad4good bidder (#4081) * adding bidder code and A bidder for non-profit free ads. more info about this bidder project can be found on project site http://1ad4good.org * removed unused code test coverage is improved to >80% tested for instream video support * removed some legacy code, unused params * hardcoding https to endpoint * Improve Digital adapter fix: don't send sizes for instream video (#4427) * Bid floor, https, native ad update * Update the ad server protocol module * Adding referrer * Improve Digital support for video * Improve Digital adapter: video * adapter version -> 6.0.0 * Improve Digital adapter: don't send sizes for video * Fix a typo in code comment (#4450) * Inventory id and schain support for display (#4426) * supporting schain * Update coinzillaBidAdapter.js (#4438) Update sizes const. * Support schain in ZEDO adapter (#4441) * changes to pass schain * PubMatic supporting updated Criteo User Id module (#4431) * 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 supporting updated Criteo User Id module * added a comment to re-start CI * Remove duplicate param to fix unit tests (#4459) * Brightcom Bid Adapter update for 3.0 (#4343) * add support for min_height field in pbs native requests (#4434) * Supporting Alias via Video Requests (#4460) * New adapter Proxistore (#4365) * add test adapter and documentation * integration test with hello_world * reset package-lock.json * delete useless conditionnal * make integrate test work * revert hello-world * revert hello_world * fix descriptor * change adUnits for integration test * remove proxistore widget * uncomment file * change sizes * remove useless script tag * Implementation of setBidderConfig and bidder-specific data (#4334) * initial implementation of setBidderConfig * fix ie11 test errors * Support new setBidderConfig format. Include props from both config and bidderConfig in _getConfig * Use core-js Set to avoid issues with IE * Fix tests in IE * put registerSyncs back on bidderFactory * run bidder event methods with bidder config enabled * Prebid 2.40.0 Release * Increment pre version * Conversant Bid Adapter checks pubcid directly (#4430) * Cookie Sync functionality (#4457) * changing PID param value for testing * cookie sync integration * merge from upstream * Staq Adapter: update with meta envelope (#4372) * initial dev * fix staq adapter name * fix hello world staq call * get hello world working again * add user agent collection * fix some unite tests * Add STAQ Analytics Adapter doc * clean up hello world * fix tests to play nice with browserstack * fix around issues with browserstack and deep equals of objects * dump variable env testing since we can't mod user agent stuff in browserstack * Update STAQ adapter to stop using deprecated utils for referrer * remove package-lock.json changes via master rebase * improve call frequency for ref util * change ajax content type * adjust ajax request to not expect whitelisting * remove superflous commented-out code * update event package to use meta information in envelope rather than per event basis * fix formatting * more formatting fixes * more formatting! * Rhythmone Adapter - schain support (#4414) Circle CI failing tests are not related to this PR. * Media.net Adapter: Support Prebid 3.0 (#4378) * Media.net Adapter: Support Prebid 3.0 * Media.net Adapter: add tests to increase code coverage * Vi Adapter: Passes additional param in the bid request (#4134) * Add focus check (cherry picked from commit 9d6d6dfb83580d6a5ffed8faa5762db48f8fd44d) * Pass focus as numeric value (cherry picked from commit 9fae56a637f87b0d39cc1d24eeb1f9ff9df88f64) * Add unit test (cherry picked from commit 946710f2e9960b3839613d4bdf730e57ba38a964) * Sovrn adapter updates: schain, digitrust, pixel syncing, and 3.0 upgrades (#4385) * schain and digitrust * pixel beacons * unit tests and fixes from testing * Prebid 3.0 updates * review fix * use backwards compatible flatMap impl * update pixel tests * unit test fix * update one more url to ssl * fixed test * review updates * TheMediaGrid Bid Adapter update (#4447) * Added Grid Bid Adapter * remove priceType from TheMediaGrid Bid Adapter * Add video support in Grid Bid Adapter * Added test parameter for video slot * update Grid Bid Adapter to set size in response bid * Update Grid Bid Adapter to support identical uids in parameters * Fix typo in test file for Grid Bid Adapter * Update The Grid Media Bidder Adapter to send refererInfo.referer as 'u' parameter in ad request * Hotfix for referrer in Grid Bid Adapter * Grid Bid Adapter: added wrapperType and wrappweVersion to the ad request * TheMediaGrid Bid Adapter: added sync url * TheMediaGrid Bid Adapter: added GDPR params to sync url * TheMediaGrid Bid Adapter: added tests for getUserSyncs function * Conversant Bid Adapter adds support for extended ids (#4462) * Adkernel 3.0 compatibility (#4477) * Rubicon Adapter pchain support (#4480) * rubicon pchain support * removed describe.only * Implemented changes required to provide support for video in the IX bidding adapter for Instream and Outstream contexts. (#4424) * Default size filter & KVP support (#4452) * adding DMX test @97%, two files added one updated * Update districtm_spec.js * Update districtmDMX.js * adding all districtm needed file * remove legacy file * remove typo || 0 in the test method * force default to return a valid width and height * update unit test code for failing test * changed class for an object * remove package-lock.json * change file name for dmx adapter * renamed files * restaure package-lock.json * update to last package-lock state * update gdpr user consent * fix sizes issue * Documentation updates Adding the readme.md info * update file name and update unit testing import file location * current machine state * lint correction * remove variable assigment duplicate * adding logic upto5 * adding support for removing and shuffle sizes * adding array split test * re-assign none standard size to the request * resolve duplicate format inside format array * update .md and adaptor file for KVP support * remove array helper includes * inforce two digit after decimal * RUn error check nothing on my side but error form another adapter * add id5id to prebid server bid adapter (#4468) * Added _pbjsGlobals for tracking renames. Resolves #4254 (#4419) * Feature/smart video (#4367) * Adding outstream video support. * Fixing unit test. * Adding video instream support. * Handling video startDelay parameter. * Improving unit tests. * Fixing indent. * Handling the request when videoMediaType context is not supported. * Changing maintainer mail address. * Remove video outstream specific code. * Unit test updated. * do not select element that gets removed after dfp render (#4423) * add smms adapter (#4439) * add smms adapter * re-run ci, why adigo adapter failed?? * review comments fix, remove deprecated functions, fix unit test * Prebid 2.41.0 release * Increment pre version * adds schain param (#4442) * Create newborntownWeb adapter (#4455) * Create newborntownWeb adapter * only https protocol * Provide criteoId to server by user.ext.eids (#4478) * ucfunnel adapter fix error message in debug mode (#4338) * Add a new ucfunnel Adapter and test page * Add a new ucfunnel Adapter and test page * 1. Use prebid lib in the repo to keep updated 2. Replace var with let 3. Put JSON.parse(JSON.stringify()) into try catch block * utils.getTopWindowLocation is a function * Change to modules from adapters * Migrate to module design * [Dev Fix] Remove width and height which can be got from ad unit id * Update ucfunnelBidAdapter to fit into new spec * Correct the endpoint. Fix the error of query string * Add test case for ucfunnelBidAdapter * Fix lint error * Update version number * Combine all checks on bid request * Add GDPR support for ucfunnel adapter * Add in-stream video and native support for ucfunnel adapter * Remove demo page. Add more test cases. * Change request method from POST to GET * Remove unnecessary comment * Support vastXml and vastUrl for video request * update TTL to 30 mins * Avoid using arrow function which is not discuraged in mocha * ucfunnel tdid support * ucfunnel fix error message in debug mode * explicitly check undefined to allow falsey values in getConfig (#4486) * Conversant Bid Adapter handles vast xml (#4492) * [feature] Add a config list of submodules that require refreshing the stored ID after each bid request (#4325) * add a feature to always refresh stored id on each bid request for submodules that require that * update test comments * Prebid 2.42.0 Release * Increment pre version * Make adhese adapter prebid 3.0 compatible (#4507) * Added 'adhese' attribute to bid that contains meta data - Jira AD-2642 * added DALE to adhese determination * extra config option: no format, but use size array as format string * Read sizes from mediaTypes.banner.sizes + Apply Eslint suggestions * Use map and join, add originData to response * properly use originData obj * Remove duplicated ids * Update tests * BugFix: Site id missing (#4467) * outstream changes * removing global filtet * reverting page * message * adapter change * remove space * testcases * testpage * spaces for test page * renderer exist case * reverting package-lock.json * adding schain object * adding tagid * syntaxx error fix * video.html * space trailing * space * tagid * inventoryId and placement * rewarded video * added unit test case * adding site id * adding placement and siteis * site id param test case * removing deprecated functions * correcting test cases * indentation * test cases fix * Add missing user object in rtb request object --- modules/gamoshiBidAdapter.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/gamoshiBidAdapter.js b/modules/gamoshiBidAdapter.js index b18188cf33a8..89ffde51889f 100644 --- a/modules/gamoshiBidAdapter.js +++ b/modules/gamoshiBidAdapter.js @@ -72,7 +72,10 @@ export const spec = { 'ua': navigator.userAgent }, 'imp': [], - 'ext': {} + 'ext': {}, + 'user': { + 'ext': {} + } }; const gdprConsent = bidderRequest.gdprConsent; From 8c4039baf531586b267574e2552b9622804c9362 Mon Sep 17 00:00:00 2001 From: ucfunnel <39581136+ucfunnel@users.noreply.github.com> Date: Wed, 11 Dec 2019 11:54:54 +0800 Subject: [PATCH 31/41] ucfunnel adapter change cookie sync setting (#4535) * Add a new ucfunnel Adapter and test page * Add a new ucfunnel Adapter and test page * 1. Use prebid lib in the repo to keep updated 2. Replace var with let 3. Put JSON.parse(JSON.stringify()) into try catch block * utils.getTopWindowLocation is a function * Change to modules from adapters * Migrate to module design * [Dev Fix] Remove width and height which can be got from ad unit id * Update ucfunnelBidAdapter to fit into new spec * Correct the endpoint. Fix the error of query string * Add test case for ucfunnelBidAdapter * Fix lint error * Update version number * Combine all checks on bid request * Add GDPR support for ucfunnel adapter * Add in-stream video and native support for ucfunnel adapter * Remove demo page. Add more test cases. * Change request method from POST to GET * Remove unnecessary comment * Support vastXml and vastUrl for video request * update TTL to 30 mins * Avoid using arrow function which is not discuraged in mocha * ucfunnel tdid support * ucfunnel fix error message in debug mode * ucfunnel adapter change cookie sync setting --- modules/ucfunnelBidAdapter.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/ucfunnelBidAdapter.js b/modules/ucfunnelBidAdapter.js index f967f30bd449..993c33534a31 100644 --- a/modules/ucfunnelBidAdapter.js +++ b/modules/ucfunnelBidAdapter.js @@ -126,12 +126,12 @@ export const spec = { if (syncOptions.iframeEnabled) { return [{ type: 'iframe', - url: '//cdn.aralego.com/ucfad/cookie/sync.html' + url: '//cdn.aralego.net/ucfad/cookie/sync.html' }]; } else if (syncOptions.pixelEnabled) { return [{ type: 'image', - url: '//sync.aralego.com/idSync' + url: 'https://sync.aralego.com/idSync' }]; } } From 4de8eb77db455377600c94c659ca0605fc7f29ff Mon Sep 17 00:00:00 2001 From: sumit116 Date: Wed, 11 Dec 2019 20:04:18 +0530 Subject: [PATCH 32/41] E2e mock server (#4456) * e2e test mock server and midlleware * mock server request response * remove unwanted logs and packages * fix jshint errors * update folder to /dist * temporary changes to run only banner test * remove trailing space * refactor * make mock server a child process of test task --- gulpfile.js | 25 +- package-lock.json | 469 ++++++++++++------ package.json | 2 + .../request-response-pairs/banner/index.js | 96 ++++ test/mock-server/index.js | 36 ++ .../request-middlewares/prebid-request.js | 75 +++ test/pages/banner.html | 34 +- test/spec/e2e/banner/basic_banner_ad.spec.js | 23 +- wdio.conf.js | 3 +- 9 files changed, 577 insertions(+), 186 deletions(-) create mode 100644 test/mock-server/expectations/request-response-pairs/banner/index.js create mode 100644 test/mock-server/index.js create mode 100644 test/mock-server/request-middlewares/prebid-request.js diff --git a/gulpfile.js b/gulpfile.js index 2566b52de596..7c4ca3068866 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -32,6 +32,9 @@ var prebid = require('./package.json'); var dateString = 'Updated : ' + (new Date()).toISOString().substring(0, 10); var banner = '/* <%= prebid.name %> v<%= prebid.version %>\n' + dateString + ' */\n'; var port = 9999; +const mockServerPort = 4444; +const host = argv.host ? argv.host : 'localhost'; +const { spawn } = require('child_process'); // these modules must be explicitly listed in --modules to be included in the build, won't be part of "all" modules var explicitModules = [ @@ -234,12 +237,26 @@ function test(done) { wdioConf ]; } + + //run mock-server + const mockServer = spawn('node', ['./test/mock-server/index.js', '--port='+mockServerPort]); + mockServer.stdout.on('data', (data) => { + console.log(`stdout: ${data}`); + }); + mockServer.stderr.on('data', (data) => { + console.log(`stderr: ${data}`); + }); + execa(wdioCmd, wdioOpts, { stdio: 'inherit' }) .then(stdout => { + //kill mock server + mockServer.kill('SIGINT'); done(); process.exit(0); }) .catch(err => { + //kill mock server + mockServer.kill('SIGINT'); done(new Error(`Tests failed with error: ${err}`)); process.exit(1); }); @@ -309,6 +326,12 @@ function setupE2e(done) { done(); } +gulp.task('updatepath', function(){ + return gulp.src(['build/dist/*.js']) + .pipe(replace('ib.adnxs.com/ut/v3/prebid', host + ':' + mockServerPort + '/')) + .pipe(gulp.dest('build/dist')); +}); + // support tasks gulp.task(lint); gulp.task(watch); @@ -334,7 +357,7 @@ gulp.task('build-postbid', gulp.series(escapePostbidConfig, buildPostbid)); gulp.task('serve', gulp.series(clean, lint, gulp.parallel('build-bundle-dev', watch, test))); gulp.task('default', gulp.series(clean, makeWebpackPkg)); -gulp.task('e2e-test', gulp.series(clean, setupE2e, gulp.parallel('build-bundle-prod', watch), test)) +gulp.task('e2e-test', gulp.series(clean, setupE2e, gulp.parallel('build-bundle-prod', watch), 'updatepath', test)); // other tasks gulp.task(bundleToStdout); gulp.task('bundle', gulpBundle.bind(null, false)); // used for just concatenating pre-built files with no build step diff --git a/package-lock.json b/package-lock.json index c244909d3bd0..2917f038101c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1246,7 +1246,6 @@ "version": "1.3.7", "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.7.tgz", "integrity": "sha512-Il80Qs2WjYlJIBNzNkK6KYqlVMTbZLXgHx2oT0pU/fjRHyEp+PEfEPY0R3WCwAGVOtauxh1hOxNgIf5bv7dQpA==", - "dev": true, "requires": { "mime-types": "~2.1.24", "negotiator": "0.6.2" @@ -1597,8 +1596,7 @@ "array-flatten": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", - "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=", - "dev": true + "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=" }, "array-from": { "version": "2.1.1", @@ -4174,19 +4172,14 @@ "dev": true }, "content-disposition": { - "version": "0.5.3", - "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.3.tgz", - "integrity": "sha512-ExO0774ikEObIAEV9kDo50o+79VCUdEB6n6lzKgGwupcVeRlhrj3qGAfwq8G6uBJjkqLrhT0qEYFcWng8z1z0g==", - "dev": true, - "requires": { - "safe-buffer": "5.1.2" - } + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.2.tgz", + "integrity": "sha1-DPaLud318r55YcOoUXjLhdunjLQ=" }, "content-type": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz", - "integrity": "sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==", - "dev": true + "integrity": "sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==" }, "continuable-cache": { "version": "0.3.1", @@ -4206,14 +4199,12 @@ "cookie": { "version": "0.3.1", "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.3.1.tgz", - "integrity": "sha1-5+Ch+e9DtMi6klxcWpboBtFoc7s=", - "dev": true + "integrity": "sha1-5+Ch+e9DtMi6klxcWpboBtFoc7s=" }, "cookie-signature": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", - "integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw=", - "dev": true + "integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw=" }, "copy-descriptor": { "version": "0.1.1", @@ -4551,6 +4542,11 @@ "type-detect": "^4.0.0" } }, + "deep-equal": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/deep-equal/-/deep-equal-1.0.1.tgz", + "integrity": "sha1-9dJgKStmDghO/0zbyfCK0yR0SLU=" + }, "deep-is": { "version": "0.1.3", "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.3.tgz", @@ -4671,8 +4667,7 @@ "depd": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", - "integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=", - "dev": true + "integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=" }, "des.js": { "version": "1.0.1", @@ -4687,8 +4682,7 @@ "destroy": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz", - "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=", - "dev": true + "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=" }, "detab": { "version": "2.0.2", @@ -5222,8 +5216,7 @@ "ee-first": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", - "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=", - "dev": true + "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=" }, "ejs": { "version": "2.5.9", @@ -5267,8 +5260,7 @@ "encodeurl": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", - "integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k=", - "dev": true + "integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k=" }, "end-of-stream": { "version": "1.4.4", @@ -5568,8 +5560,7 @@ "escape-html": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", - "integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg=", - "dev": true + "integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg=" }, "escape-string-regexp": { "version": "1.0.5", @@ -6058,8 +6049,7 @@ "etag": { "version": "1.8.1", "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", - "integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc=", - "dev": true + "integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc=" }, "event-emitter": { "version": "0.3.5", @@ -6286,123 +6276,142 @@ } }, "express": { - "version": "4.17.1", - "resolved": "https://registry.npmjs.org/express/-/express-4.17.1.tgz", - "integrity": "sha512-mHJ9O79RqluphRrcw2X/GTh3k9tVv8YcoyY4Kkh4WDMUYKRZUq0h1o0w2rrrxBqM7VoeUVqgb27xlEMXTnYt4g==", - "dev": true, + "version": "4.15.4", + "resolved": "https://registry.npmjs.org/express/-/express-4.15.4.tgz", + "integrity": "sha1-Ay4iU0ic+PzgJma+yj0R7XotrtE=", "requires": { - "accepts": "~1.3.7", + "accepts": "~1.3.3", "array-flatten": "1.1.1", - "body-parser": "1.19.0", - "content-disposition": "0.5.3", - "content-type": "~1.0.4", - "cookie": "0.4.0", + "content-disposition": "0.5.2", + "content-type": "~1.0.2", + "cookie": "0.3.1", "cookie-signature": "1.0.6", - "debug": "2.6.9", - "depd": "~1.1.2", - "encodeurl": "~1.0.2", + "debug": "2.6.8", + "depd": "~1.1.1", + "encodeurl": "~1.0.1", "escape-html": "~1.0.3", - "etag": "~1.8.1", - "finalhandler": "~1.1.2", - "fresh": "0.5.2", + "etag": "~1.8.0", + "finalhandler": "~1.0.4", + "fresh": "0.5.0", "merge-descriptors": "1.0.1", "methods": "~1.1.2", "on-finished": "~2.3.0", - "parseurl": "~1.3.3", + "parseurl": "~1.3.1", "path-to-regexp": "0.1.7", - "proxy-addr": "~2.0.5", - "qs": "6.7.0", - "range-parser": "~1.2.1", - "safe-buffer": "5.1.2", - "send": "0.17.1", - "serve-static": "1.14.1", - "setprototypeof": "1.1.1", - "statuses": "~1.5.0", - "type-is": "~1.6.18", - "utils-merge": "1.0.1", - "vary": "~1.1.2" + "proxy-addr": "~1.1.5", + "qs": "6.5.0", + "range-parser": "~1.2.0", + "send": "0.15.4", + "serve-static": "1.12.4", + "setprototypeof": "1.0.3", + "statuses": "~1.3.1", + "type-is": "~1.6.15", + "utils-merge": "1.0.0", + "vary": "~1.1.1" }, "dependencies": { - "cookie": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.0.tgz", - "integrity": "sha512-+Hp8fLp57wnUSt0tY0tHEXh4voZRDnoIrZPqlo3DPiI4y9lwg/jqx+1Om94/W6ZaPDOUbnjOt/99w66zk+l1Xg==", - "dev": true - }, "debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "dev": true, + "version": "2.6.8", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.8.tgz", + "integrity": "sha1-5zFTHKLt4n0YgiJCfaF4IdaP9Pw=", "requires": { "ms": "2.0.0" } }, - "http-errors": { - "version": "1.7.3", - "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.3.tgz", - "integrity": "sha512-ZTTX0MWrsQ2ZAhA1cejAwDLycFsd7I7nVtnkT3Ol0aqodaKW+0CTZDQ1uBv5whptCnc8e8HeRRJxRs0kmm/Qfw==", - "dev": true, + "finalhandler": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.0.6.tgz", + "integrity": "sha1-AHrqM9Gk0+QgF/YkhIrVjSEvgU8=", "requires": { - "depd": "~1.1.2", - "inherits": "2.0.4", - "setprototypeof": "1.1.1", - "statuses": ">= 1.5.0 < 2", - "toidentifier": "1.0.0" + "debug": "2.6.9", + "encodeurl": "~1.0.1", + "escape-html": "~1.0.3", + "on-finished": "~2.3.0", + "parseurl": "~1.3.2", + "statuses": "~1.3.1", + "unpipe": "~1.0.0" + }, + "dependencies": { + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "requires": { + "ms": "2.0.0" + } + } } }, + "fresh": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.0.tgz", + "integrity": "sha1-9HTKXmqSRtb9jglTz6m5yAWvp44=" + }, + "mime": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/mime/-/mime-1.3.4.tgz", + "integrity": "sha1-EV+eO2s9rylZmDyzjxSaLUDrXVM=" + }, "ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", - "dev": true + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" }, "path-to-regexp": { "version": "0.1.7", "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", - "integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w=", - "dev": true + "integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w=" }, "qs": { - "version": "6.7.0", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz", - "integrity": "sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ==", - "dev": true + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.0.tgz", + "integrity": "sha512-fjVFjW9yhqMhVGwRExCXLhJKrLlkYSaxNWdyc9rmHlrVZbk35YHH312dFd7191uQeXkI3mKLZTIbSvIeFwFemg==" }, "send": { - "version": "0.17.1", - "resolved": "https://registry.npmjs.org/send/-/send-0.17.1.tgz", - "integrity": "sha512-BsVKsiGcQMFwT8UxypobUKyv7irCNRHk1T0G680vk88yf6LBByGcZJOTJCrTP2xVN6yI+XjPJcNuE3V4fT9sAg==", - "dev": true, + "version": "0.15.4", + "resolved": "https://registry.npmjs.org/send/-/send-0.15.4.tgz", + "integrity": "sha1-mF+qPihLAnPHkzZKNcZze9k5Bbk=", "requires": { - "debug": "2.6.9", - "depd": "~1.1.2", + "debug": "2.6.8", + "depd": "~1.1.1", "destroy": "~1.0.4", - "encodeurl": "~1.0.2", + "encodeurl": "~1.0.1", "escape-html": "~1.0.3", - "etag": "~1.8.1", - "fresh": "0.5.2", - "http-errors": "~1.7.2", - "mime": "1.6.0", - "ms": "2.1.1", + "etag": "~1.8.0", + "fresh": "0.5.0", + "http-errors": "~1.6.2", + "mime": "1.3.4", + "ms": "2.0.0", "on-finished": "~2.3.0", - "range-parser": "~1.2.1", - "statuses": "~1.5.0" - }, - "dependencies": { - "ms": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", - "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==", - "dev": true - } + "range-parser": "~1.2.0", + "statuses": "~1.3.1" + } + }, + "serve-static": { + "version": "1.12.4", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.12.4.tgz", + "integrity": "sha1-m2qpjutyU8Tu3Ewfb9vKYJkBqWE=", + "requires": { + "encodeurl": "~1.0.1", + "escape-html": "~1.0.3", + "parseurl": "~1.3.1", + "send": "0.15.4" } }, "setprototypeof": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.1.tgz", - "integrity": "sha512-JvdAWfbXeIGaZ9cILp38HntZSFSo3mWg6xGcJJsd+d4aRMOqauag1C63dJfDw7OaMYwEbHMOxEZ1lqVRYP2OAw==", - "dev": true + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.0.3.tgz", + "integrity": "sha1-ZlZ+NwQ+608E2RvWWMDL77VbjgQ=" + }, + "statuses": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.3.1.tgz", + "integrity": "sha1-+vUbnrdKrvOzrPStX2Gr8ky3uT4=" + }, + "utils-merge": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.0.tgz", + "integrity": "sha1-ApT7kiu5N1FTVBxPcJYjHyh8ivg=" } } }, @@ -6848,8 +6857,7 @@ "forwarded": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.2.tgz", - "integrity": "sha1-mMI9qxF1ZXuMBXPozszZGw/xjIQ=", - "dev": true + "integrity": "sha1-mMI9qxF1ZXuMBXPozszZGw/xjIQ=" }, "fragment-cache": { "version": "0.2.1", @@ -6978,7 +6986,8 @@ "ansi-regex": { "version": "2.1.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "aproba": { "version": "1.2.0", @@ -6999,12 +7008,14 @@ "balanced-match": { "version": "1.0.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, "dev": true, + "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -7019,17 +7030,20 @@ "code-point-at": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "concat-map": { "version": "0.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "console-control-strings": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "core-util-is": { "version": "1.0.2", @@ -7146,7 +7160,8 @@ "inherits": { "version": "2.0.3", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "ini": { "version": "1.3.5", @@ -7158,6 +7173,7 @@ "version": "1.0.0", "bundled": true, "dev": true, + "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -7172,6 +7188,7 @@ "version": "3.0.4", "bundled": true, "dev": true, + "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -7179,12 +7196,14 @@ "minimist": { "version": "0.0.8", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "minipass": { "version": "2.3.5", "bundled": true, "dev": true, + "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -7203,6 +7222,7 @@ "version": "0.5.1", "bundled": true, "dev": true, + "optional": true, "requires": { "minimist": "0.0.8" } @@ -7283,7 +7303,8 @@ "number-is-nan": { "version": "1.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "object-assign": { "version": "4.1.1", @@ -7295,6 +7316,7 @@ "version": "1.4.0", "bundled": true, "dev": true, + "optional": true, "requires": { "wrappy": "1" } @@ -7380,7 +7402,8 @@ "safe-buffer": { "version": "5.1.2", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "safer-buffer": { "version": "2.1.2", @@ -7416,6 +7439,7 @@ "version": "1.0.2", "bundled": true, "dev": true, + "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -7435,6 +7459,7 @@ "version": "3.0.1", "bundled": true, "dev": true, + "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -7478,12 +7503,14 @@ "wrappy": { "version": "1.0.2", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "yallist": { "version": "3.0.3", "bundled": true, - "dev": true + "dev": true, + "optional": true } } }, @@ -8990,7 +9017,6 @@ "version": "1.6.3", "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.6.3.tgz", "integrity": "sha1-i1VoC7S+KDoLW/TqLjhYC+HZMg0=", - "dev": true, "requires": { "depd": "~1.1.2", "inherits": "2.0.3", @@ -9001,8 +9027,7 @@ "inherits": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", - "dev": true + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" } } }, @@ -9222,10 +9247,9 @@ "dev": true }, "ipaddr.js": { - "version": "1.9.0", - "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.0.tgz", - "integrity": "sha512-M4Sjn6N/+O6/IXSJseKqHoFc+5FdGJ22sXqnjTpdZweHK64MzEPAyQZyEU3R/KRv2GLoa7nNtg/C2Ev6m7z+eA==", - "dev": true + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.4.0.tgz", + "integrity": "sha1-KWrKh4qCGBbluF0KKFqZvP9FgvA=" }, "is-absolute": { "version": "1.0.0", @@ -11662,8 +11686,7 @@ "media-typer": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", - "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=", - "dev": true + "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=" }, "mem": { "version": "1.1.0", @@ -11817,8 +11840,7 @@ "merge-descriptors": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz", - "integrity": "sha1-sAqqVW3YtEVoFQ7J0blT8/kMu2E=", - "dev": true + "integrity": "sha1-sAqqVW3YtEVoFQ7J0blT8/kMu2E=" }, "merge-stream": { "version": "2.0.0", @@ -11829,8 +11851,7 @@ "methods": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", - "integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4=", - "dev": true + "integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4=" }, "micromatch": { "version": "3.1.10", @@ -12198,8 +12219,7 @@ "negotiator": { "version": "0.6.2", "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.2.tgz", - "integrity": "sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw==", - "dev": true + "integrity": "sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw==" }, "neo-async": { "version": "2.6.1", @@ -12610,7 +12630,6 @@ "version": "2.3.0", "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", "integrity": "sha1-IPEzZIGwg811M3mSoWlxqi2QaUc=", - "dev": true, "requires": { "ee-first": "1.1.1" } @@ -12987,8 +13006,7 @@ "parseurl": { "version": "1.3.3", "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", - "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==", - "dev": true + "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==" }, "pascalcase": { "version": "0.1.1", @@ -13299,13 +13317,12 @@ "dev": true }, "proxy-addr": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.5.tgz", - "integrity": "sha512-t/7RxHXPH6cJtP0pRG6smSr9QJidhB+3kXu0KgXnbGYMgzEnUxRQ4/LDdfOwZEMyIh3/xHb8PX3t+lfL9z+YVQ==", - "dev": true, + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-1.1.5.tgz", + "integrity": "sha1-ccDuOxAt4/IC87ZPYI0XP8uhqRg=", "requires": { - "forwarded": "~0.1.2", - "ipaddr.js": "1.9.0" + "forwarded": "~0.1.0", + "ipaddr.js": "1.4.0" } }, "prr": { @@ -13475,8 +13492,7 @@ "range-parser": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", - "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==", - "dev": true + "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==" }, "raw-body": { "version": "1.1.7", @@ -14421,8 +14437,7 @@ "setprototypeof": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.0.tgz", - "integrity": "sha512-BvE/TwpZX4FXExxOxZyRGQQv651MSwmWKZGqvmPcRIjDqWub67kTKuIMx43cZZrS/cBBzwBcNDWoFxt2XEFIpQ==", - "dev": true + "integrity": "sha512-BvE/TwpZX4FXExxOxZyRGQQv651MSwmWKZGqvmPcRIjDqWub67kTKuIMx43cZZrS/cBBzwBcNDWoFxt2XEFIpQ==" }, "sha.js": { "version": "2.4.11", @@ -14942,8 +14957,7 @@ "statuses": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz", - "integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow=", - "dev": true + "integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow=" }, "stealthy-require": { "version": "1.1.1", @@ -15711,7 +15725,6 @@ "version": "1.6.18", "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==", - "dev": true, "requires": { "media-typer": "0.3.0", "mime-types": "~2.1.24" @@ -15999,8 +16012,7 @@ "unpipe": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", - "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=", - "dev": true + "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=" }, "unset-value": { "version": "1.0.0", @@ -16209,8 +16221,7 @@ "vary": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", - "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=", - "dev": true + "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=" }, "verror": { "version": "1.10.0", @@ -16907,12 +16918,156 @@ "integrity": "sha512-gac8OEcQ2Li1dxIEWGZzsp2BitJxwkwcOm0zHAJLcPJaVvm58FRnk6RkuLRpU1EujipU2ZFODv2P9DLMfnV8mw==", "dev": true }, + "content-disposition": { + "version": "0.5.3", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.3.tgz", + "integrity": "sha512-ExO0774ikEObIAEV9kDo50o+79VCUdEB6n6lzKgGwupcVeRlhrj3qGAfwq8G6uBJjkqLrhT0qEYFcWng8z1z0g==", + "dev": true, + "requires": { + "safe-buffer": "5.1.2" + } + }, + "cookie": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.0.tgz", + "integrity": "sha512-+Hp8fLp57wnUSt0tY0tHEXh4voZRDnoIrZPqlo3DPiI4y9lwg/jqx+1Om94/W6ZaPDOUbnjOt/99w66zk+l1Xg==", + "dev": true + }, + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dev": true, + "requires": { + "ms": "2.0.0" + } + }, "ejs": { "version": "2.7.4", "resolved": "https://registry.npmjs.org/ejs/-/ejs-2.7.4.tgz", "integrity": "sha512-7vmuyh5+kuUyJKePhQfRQBhXV5Ce+RnaeeQArKu1EAMpL3WbgMt5WG6uQZpEVvYSSsxMXRKOewtDk9RaTKXRlA==", "dev": true }, + "express": { + "version": "4.17.1", + "resolved": "https://registry.npmjs.org/express/-/express-4.17.1.tgz", + "integrity": "sha512-mHJ9O79RqluphRrcw2X/GTh3k9tVv8YcoyY4Kkh4WDMUYKRZUq0h1o0w2rrrxBqM7VoeUVqgb27xlEMXTnYt4g==", + "dev": true, + "requires": { + "accepts": "~1.3.7", + "array-flatten": "1.1.1", + "body-parser": "1.19.0", + "content-disposition": "0.5.3", + "content-type": "~1.0.4", + "cookie": "0.4.0", + "cookie-signature": "1.0.6", + "debug": "2.6.9", + "depd": "~1.1.2", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "finalhandler": "~1.1.2", + "fresh": "0.5.2", + "merge-descriptors": "1.0.1", + "methods": "~1.1.2", + "on-finished": "~2.3.0", + "parseurl": "~1.3.3", + "path-to-regexp": "0.1.7", + "proxy-addr": "~2.0.5", + "qs": "6.7.0", + "range-parser": "~1.2.1", + "safe-buffer": "5.1.2", + "send": "0.17.1", + "serve-static": "1.14.1", + "setprototypeof": "1.1.1", + "statuses": "~1.5.0", + "type-is": "~1.6.18", + "utils-merge": "1.0.1", + "vary": "~1.1.2" + } + }, + "http-errors": { + "version": "1.7.3", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.3.tgz", + "integrity": "sha512-ZTTX0MWrsQ2ZAhA1cejAwDLycFsd7I7nVtnkT3Ol0aqodaKW+0CTZDQ1uBv5whptCnc8e8HeRRJxRs0kmm/Qfw==", + "dev": true, + "requires": { + "depd": "~1.1.2", + "inherits": "2.0.4", + "setprototypeof": "1.1.1", + "statuses": ">= 1.5.0 < 2", + "toidentifier": "1.0.0" + } + }, + "ipaddr.js": { + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.0.tgz", + "integrity": "sha512-M4Sjn6N/+O6/IXSJseKqHoFc+5FdGJ22sXqnjTpdZweHK64MzEPAyQZyEU3R/KRv2GLoa7nNtg/C2Ev6m7z+eA==", + "dev": true + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "dev": true + }, + "path-to-regexp": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", + "integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w=", + "dev": true + }, + "proxy-addr": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.5.tgz", + "integrity": "sha512-t/7RxHXPH6cJtP0pRG6smSr9QJidhB+3kXu0KgXnbGYMgzEnUxRQ4/LDdfOwZEMyIh3/xHb8PX3t+lfL9z+YVQ==", + "dev": true, + "requires": { + "forwarded": "~0.1.2", + "ipaddr.js": "1.9.0" + } + }, + "qs": { + "version": "6.7.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz", + "integrity": "sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ==", + "dev": true + }, + "send": { + "version": "0.17.1", + "resolved": "https://registry.npmjs.org/send/-/send-0.17.1.tgz", + "integrity": "sha512-BsVKsiGcQMFwT8UxypobUKyv7irCNRHk1T0G680vk88yf6LBByGcZJOTJCrTP2xVN6yI+XjPJcNuE3V4fT9sAg==", + "dev": true, + "requires": { + "debug": "2.6.9", + "depd": "~1.1.2", + "destroy": "~1.0.4", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "fresh": "0.5.2", + "http-errors": "~1.7.2", + "mime": "1.6.0", + "ms": "2.1.1", + "on-finished": "~2.3.0", + "range-parser": "~1.2.1", + "statuses": "~1.5.0" + }, + "dependencies": { + "ms": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", + "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==", + "dev": true + } + } + }, + "setprototypeof": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.1.tgz", + "integrity": "sha512-JvdAWfbXeIGaZ9cILp38HntZSFSo3mWg6xGcJJsd+d4aRMOqauag1C63dJfDw7OaMYwEbHMOxEZ1lqVRYP2OAw==", + "dev": true + }, "ws": { "version": "6.2.1", "resolved": "https://registry.npmjs.org/ws/-/ws-6.2.1.tgz", diff --git a/package.json b/package.json index b25a94f7b6b2..c24cfcd6dc8e 100755 --- a/package.json +++ b/package.json @@ -97,8 +97,10 @@ "babel-plugin-transform-object-assign": "^6.22.0", "core-js": "^2.4.1", "crypto-js": "^3.1.9-1", + "deep-equal": "^1.0.1", "dlv": "1.1.3", "dset": "2.0.1", + "express": "^4.15.4", "fun-hooks": "^0.9.5", "jsencrypt": "^3.0.0-rc.1", "just-clone": "^1.0.2" diff --git a/test/mock-server/expectations/request-response-pairs/banner/index.js b/test/mock-server/expectations/request-response-pairs/banner/index.js new file mode 100644 index 000000000000..17538c8b33d3 --- /dev/null +++ b/test/mock-server/expectations/request-response-pairs/banner/index.js @@ -0,0 +1,96 @@ +var app = require('../../../index'); + +/** + * This file will have the fixtures for request and response. Each one has to export two functions getRequest and getResponse. + * expectation directory will hold all the request reponse pairs of different types. middlewares added to the server will parse + * these files and return the response when expecation is met + * + * The expecation created here is replicating trafficSourceCode example in Prebid. + */ + +/** + * This function will return the request object with all the entities method, path, body, header etc. + * + * @return {object} Request object + */ +exports.getRequest = function() { + return { + 'httpRequest': { + 'method': 'POST', + 'path': '/', + 'body': { + 'tags': [{ + 'sizes': [{ + 'width': 300, + 'height': 250 + }, { + 'width': 300, + 'height': 600 + }], + 'primary_size': { + 'width': 300, + 'height': 250 + }, + 'ad_types': ['banner'], + 'id': 13144370, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true + }], + 'user': {} + } + } + } +} + +/** + * This function will return the response object with all the entities method, path, body, header etc. + * + * @return {object} Response object + */ +exports.getResponse = function() { + return { + 'httpResponse': { + 'body': { + 'version': '3.0.0', + 'tags': [{ + 'uuid': '2c8c83a1deaf1a', + 'tag_id': 13144370, + 'auction_id': '8147841645883553832', + 'nobid': false, + 'no_ad_url': 'http://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Fgpt%2Fhello_world.html%3Fpbjs_debug%3Dtrue&e=wqT_3QKzCKAzBAAAAwDWAAUBCJKPpe4FEKjwl-js2byJcRiq5MnUovf28WEqNgkAAAkCABEJBywAABkAAACA61HgPyEREgApEQkAMREb8GkwsqKiBjjtSEDtSEgAUABYnPFbYABotc95eACAAQGKAQCSAQNVU0SYAawCoAH6AagBAbABALgBAcABAMgBAtABANgBAOABAPABAIoCO3VmKCdhJywgMjUyOTg4NSwgMTU3MzQ3MjE0Nik7AR0scicsIDk2ODQ2MDM1Nh4A8PWSAqUCIXp6ZmhVQWl1c0s0S0VOT0JseTRZQUNDYzhWc3dBRGdBUUFSSTdVaFFzcUtpQmxnQVlJSUNhQUJ3Q0hncWdBRWtpQUVxa0FFQW1BRUFvQUVCcUFFRHNBRUF1UUVwaTRpREFBRGdQOEVCS1l1SWd3QUE0RF9KQVozRkl5WjA1Tm9fMlFFQUFBQUFBQUR3UC1BQkFQVUJBQUFBQUpnQ0FLQUNBTFVDQUFBQUFMMENBQUFBQU9BQ0FPZ0NBUGdDQUlBREFaZ0RBYWdEcnJDdUNyb0RDVk5KVGpNNk5EY3pOZUFEcUJXSUJBQ1FCQUNZQkFIQkIFRQkBCHlRUQkJAQEUTmdFQVBFEY0BkEg0QkFDSUJmOGuaAokBIUl3OTBCOikBJG5QRmJJQVFvQUQROFhEZ1B6b0pVMGxPTXpvME56TTFRS2dWUxFoDFBBX1URDAxBQUFXHQwAWR0MAGEdDABjHQzwQGVBQS7CAi9odHRwOi8vcHJlYmlkLm9yZy9kZXYtZG9jcy9nZXR0aW5nLXN0YXJ0ZWQuaHRtbNgCAOACrZhI6gJTDTrYdGVzdC5sb2NhbGhvc3Q6OTk5OS9pbnRlZ3JhdGlvbkV4YW1wbGVzL2dwdC9oZWxsb193b3JsZAVO8EA_cGJqc19kZWJ1Zz10cnVlgAMAiAMBkAMAmAMXoAMBqgMAwAOsAsgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92Mw248F6YBACiBAsxMC43NS43NC42OagEkECyBBIIBBAEGKwCIPoBKAEoAjAAOAK4BADABADIBADSBA45MzI1I1NJTjM6NDczNdoEAggA4AQB8ATTgZcuiAUBmAUAoAX______wEDFAHABQDJBWmAFPA_0gUJCQkMcAAA2AUB4AUB8AUB-gUECAAQAJAGAJgGALgGAMEGCSM08L_IBgDQBvUv2gYWChAJFBkBUBAAGADgBgHyBgIIAIAHAYgHAKAHAQ..&s=68cfb6ed042ea47f5d3fc2c32cc068500e542066', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'banner', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 96846035, + 'media_type_id': 1, + 'media_subtype_id': 1, + 'cpm': 0.500000, + 'cpm_publisher_currency': 0.500000, + 'is_bin_price_applied': false, + 'publisher_currency_code': '$', + 'brand_category_id': 0, + 'client_initiated_ad_counting': true, + 'rtb': { + 'banner': { + 'content': "
", + 'width': 300, + 'height': 250 + }, + 'trackers': [{ + 'impression_urls': ['http://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Fgpt%2Fhello_world.html%3Fpbjs_debug%3Dtrue&e=wqT_3QK7CKA7BAAAAwDWAAUBCJKPpe4FEKjwl-js2byJcRiq5MnUovf28WEqNgkAAAECCOA_EQEHNAAA4D8ZAAAAgOtR4D8hERIAKREJADERG6gwsqKiBjjtSEDtSEgCUNOBly5YnPFbYABotc95eJK4BYABAYoBA1VTRJIBAQbwUpgBrAKgAfoBqAEBsAEAuAEBwAEEyAEC0AEA2AEA4AEA8AEAigI7dWYoJ2EnLCAyNTI5ODg1LCAxNTczNDcyMTQ2KTt1ZigncicsIDk2ODQ2MDM1Nh4A8PWSAqUCIXp6ZmhVQWl1c0s0S0VOT0JseTRZQUNDYzhWc3dBRGdBUUFSSTdVaFFzcUtpQmxnQVlJSUNhQUJ3Q0hncWdBRWtpQUVxa0FFQW1BRUFvQUVCcUFFRHNBRUF1UUVwaTRpREFBRGdQOEVCS1l1SWd3QUE0RF9KQVozRkl5WjA1Tm9fMlFFQUFBQUFBQUR3UC1BQkFQVUJBQUFBQUpnQ0FLQUNBTFVDQUFBQUFMMENBQUFBQU9BQ0FPZ0NBUGdDQUlBREFaZ0RBYWdEcnJDdUNyb0RDVk5KVGpNNk5EY3pOZUFEcUJXSUJBQ1FCQUNZQkFIQkIFRQkBCHlRUQkJAQEUTmdFQVBFEY0BkEg0QkFDSUJmOGuaAokBIUl3OTBCOikBJG5QRmJJQVFvQUQROFhEZ1B6b0pVMGxPTXpvME56TTFRS2dWUxFoDFBBX1URDAxBQUFXHQwAWR0MAGEdDABjHQzwQGVBQS7CAi9odHRwOi8vcHJlYmlkLm9yZy9kZXYtZG9jcy9nZXR0aW5nLXN0YXJ0ZWQuaHRtbNgCAOACrZhI6gJTDTrYdGVzdC5sb2NhbGhvc3Q6OTk5OS9pbnRlZ3JhdGlvbkV4YW1wbGVzL2dwdC9oZWxsb193b3JsZAVO8EA_cGJqc19kZWJ1Zz10cnVlgAMAiAMBkAMAmAMXoAMBqgMAwAOsAsgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92Mw248F6YBACiBAsxMC43NS43NC42OagEkECyBBIIBBAEGKwCIPoBKAEoAjAAOAK4BADABADIBADSBA45MzI1I1NJTjM6NDczNdoEAggB4AQB8ATTgZcuiAUBmAUAoAX______wEDFAHABQDJBWmIFPA_0gUJCQkMcAAA2AUB4AUB8AUB-gUECAAQAJAGAJgGALgGAMEGCSM08D_IBgDQBvUv2gYWChAJFBkBUBAAGADgBgHyBgIIAIAHAYgHAKAHAQ..&s=951a029669a69e3f0c527c937c2d852be92802e1'], + 'video_events': {} + }] + } + }] + }] + }, + } + } +} diff --git a/test/mock-server/index.js b/test/mock-server/index.js new file mode 100644 index 000000000000..30ead952fcc6 --- /dev/null +++ b/test/mock-server/index.js @@ -0,0 +1,36 @@ +const express = require('express'); +const argv = require('yargs').argv; +const app = module.exports = express(); +const port = (argv.port) ? argv.port : 3000; +const bodyParser = require('body-parser'); +const renderCreative = require('./request-middlewares/prebid-request.js'); + +app.use(express.static(__dirname + '/content')); +app.use(bodyParser.text({type: 'text/plain'})); + +app.locals = { + 'port': port, + 'host': 'localhost' +}; + +// get type will be used to test prebid jsonp requests +app.get('/', renderCreative, (request, response) => { + response.send(); +}); + +// prebid make POST type request to ut endpoint so here we will match ut endpoint request. +app.post('/', renderCreative, (request, response) => { + response.send(); +}); + +app.listen(port, (err) => { + if (err) { + return console.log('something bad happened', err); + } + + console.log(`server is listening on ${port}`); +}); + +process.on('SIGTERM', function() { console.log('halt mock-server'); process.exit(0) }); + +process.on('SIGINT', function() { console.log('shutdown mock-server'); process.exit(0) }); diff --git a/test/mock-server/request-middlewares/prebid-request.js b/test/mock-server/request-middlewares/prebid-request.js new file mode 100644 index 000000000000..6e2d03487cf2 --- /dev/null +++ b/test/mock-server/request-middlewares/prebid-request.js @@ -0,0 +1,75 @@ +/** + * This middleware will be used to find matching request hitting the ut endpoint by prebid. + * As of now it only uses the request payload to compare with httpRequest.body defined in expectations dir. + * Matching headers or cookies can also be the use case. + */ + +const glob = require('glob'); +const path = require('path'); +const deepEqual = require('deep-equal'); + +module.exports = function (req, res, next) { + let reqBody; + try { + if (req.method === 'GET') { + reqBody = JSON.parse(req.query.q); + } else { + reqBody = JSON.parse(req.body); + } + } catch (e) { + // error + } + + // prebid uses uuid to match request response pairs. + // On each request new uuid is generated, so here i am grabbing the uuid from incoming request and adding it to matched response. + let uuidObj = {}; + if (reqBody && reqBody.uuid) { + uuidObj.response = reqBody.uuid; + delete reqBody.uuid; + } + + if (reqBody && reqBody.tags) { + uuidObj.tags = reqBody.tags.map((tag) => { + let uuid = tag.uuid; + delete tag.uuid; + return uuid; + }); + } + + // values within these request props are dynamically generated and aren't + // vital to check in these tests, so they are deleted rather than updating + // the request-response pairs continuously + ['sdk', 'referrer_detection'].forEach(prop => { + if (reqBody && reqBody[prop]) { + delete reqBody[prop]; + } + }); + + // Parse all the expectation to find response for this request + glob.sync('./test/mock-server/expectations/**/*.js').some((file) => { + file = require(path.resolve(file)); + let expectedReqBody = JSON.parse(JSON.stringify(file.getRequest().httpRequest.body)); + // respond to all requests + // TODO send a 404 if resource not found + res.set({ + 'Access-Control-Allow-Credentials': 'true', + 'Access-Control-Allow-Origin': req.headers.origin + }); + + // As of now only body is compared. We can also add other request properties like headers, cookies if required + if (deepEqual(reqBody, expectedReqBody)) { + let response = file.getResponse().httpResponse.body; + if (Object.keys(uuidObj).length > 0) { + response.tags.forEach((tag, index) => { + tag.uuid = uuidObj.tags[index]; + }); + } + res.type('json'); + response = JSON.stringify(response); + res.write(response); + return true; + } + }); + + next(); +}; diff --git a/test/pages/banner.html b/test/pages/banner.html index 05085089f72a..e1859abdd85c 100644 --- a/test/pages/banner.html +++ b/test/pages/banner.html @@ -30,22 +30,24 @@ placementId: 13144370 } }] - }, { - code: 'div-gpt-ad-1460505748561-1', - mediaTypes: { - banner: { - sizes: [[300, 250], [300, 600]], - } - }, - bids: [{ - bidder: "rubicon", - params: { - accountId: 14062, - siteId: 70608, - zoneId: 498816 - } - }] - }]; + } + //, { + // code: 'div-gpt-ad-1460505748561-1', + // mediaTypes: { + // banner: { + // sizes: [[300, 250], [300, 600]], + // } + // }, + // bids: [{ + // bidder: "appnexus", + // params: { + // accountId: 14062, + // siteId: 70608, + // zoneId: 498816 + // } + // }] + // } + ]; ' : ''; - const nativeContainer = format === 'native' ? '
' : ''; - return ` - ${nativeStyle} - -
- - - ${nativeContainer} -
- -`; -}; - -/** - * Get the current window location URL correctly encoded for use in a URL query string. - * @returns {String} URI-encoded URL - */ -const getTopWindowUrlEncoded = () => encodeURIComponent(getTopWindowUrl()); - -/** - * Convert each bid request to a single URL to fetch those bids. - * @param {Array} bids - list of bids - * @param {String} bids[].placementCode - Prebid placement identifier - * @param {Object} bids[].params - * @param {String} bids[].params.placementId - Audience Network placement identifier - * @param {String} bids[].params.platform - Audience Network platform identifier (optional) - * @param {String} bids[].params.format - Optional format, one of 'video' or 'native' if set - * @param {Array} bids[].sizes - list of desired advert sizes - * @param {Array} bids[].sizes[] - Size arrays [h,w]: should include one of [300, 250], [320, 50] - * @returns {Array} List of URLs to fetch, plus formats and sizes for later use with interpretResponse - */ -const buildRequests = bids => { - // Build lists of placementids, adformats, sizes and SDK versions - const placementids = []; - const adformats = []; - const sizes = []; - const sdk = []; - const platforms = []; - const requestIds = []; - - bids.forEach(bid => bid.sizes - .map(flattenSize) - .filter(size => isValidSizeAndFormat(size, bid.params.format)) - .reduce(sortByPreferredSize, []) - .slice(0, 1) - .forEach(preferredSize => { - const [size, format] = mapDeprecatedSizeAndFormat(preferredSize, bid.params.format); - placementids.push(bid.params.placementId); - adformats.push(format || size); - sizes.push(size); - sdk.push(sdkVersion(format)); - platforms.push(bid.params.platform); - requestIds.push(bid.bidId); - }) - ); - - // Build URL - const testmode = isTestmode(); - const pageurl = getTopWindowUrlEncoded(); - const platform = findPlatform(platforms); - const cb = generateUUID(); - const search = { - placementids, - adformats, - testmode, - pageurl, - sdk, - adapterver, - platform, - platver, - cb - }; - const video = findIndex(adformats, isVideo); - if (video !== -1) { - [search.playerwidth, search.playerheight] = expandSize(sizes[video]); - } - const data = formatQS(search); - - return [{ adformats, data, method, requestIds, sizes, url }]; -}; - -/** - * Convert a server response to a bid response. - * @param {Object} response - object representing the response - * @param {Object} response.body - response body, already converted from JSON - * @param {Object} bidRequests - the original bid requests - * @param {Array} bidRequest.adformats - list of formats for the original bid requests - * @param {Array} bidRequest.sizes - list of sizes fot the original bid requests - * @returns {Array} A list of bid response objects - */ -const interpretResponse = ({ body }, { adformats, requestIds, sizes }) => { - const { bids = {} } = body; - return Object.keys(bids) - // extract Array of bid responses - .map(placementId => bids[placementId]) - // flatten - .reduce((a, b) => a.concat(b), []) - // transform to bidResponse - .map((bid, i) => { - const { - bid_id: fbBidid, - placement_id: creativeId, - bid_price_cents: cpm - } = bid; - - const format = adformats[i]; - const [width, height] = expandSize(flattenSize(sizes[i])); - const ad = createAdHtml(creativeId, format, fbBidid); - const requestId = requestIds[i]; - - const bidResponse = { - // Prebid attributes - requestId, - cpm: cpm / 100, - width, - height, - ad, - ttl, - creativeId, - netRevenue, - currency, - // Audience Network attributes - hb_bidder: hbBidder, - fb_bidid: fbBidid, - fb_format: format, - fb_placementid: creativeId - }; - // Video attributes - if (isVideo(format)) { - const pageurl = getTopWindowUrlEncoded(); - bidResponse.mediaType = 'video'; - bidResponse.vastUrl = `https://an.facebook.com/v1/instream/vast.xml?placementid=${creativeId}&pageurl=${pageurl}&playerwidth=${width}&playerheight=${height}&bidid=${fbBidid}`; - bidResponse.ttl = videoTtl; - } - return bidResponse; - }); -}; - -/** - * Covert bid param types for S2S - * @param {Object} params bid params - * @param {Boolean} isOpenRtb boolean to check openrtb2 protocol - * @return {Object} params bid params - */ -const transformBidParams = (params, isOpenRtb) => { - return convertTypes({ - 'placementId': 'string' - }, params); -} - -export const spec = { - code, - supportedMediaTypes, - isBidRequestValid, - buildRequests, - interpretResponse, - transformBidParams -}; - -registerBidder(spec); diff --git a/modules/betweenBidAdapter.js b/modules/betweenBidAdapter.js index 9da6b4dbe296..374ea200b60a 100644 --- a/modules/betweenBidAdapter.js +++ b/modules/betweenBidAdapter.js @@ -96,7 +96,7 @@ export const spec = { if (syncOptions.iframeEnabled) { syncs.push({ type: 'iframe', - url: '//acdn.adnxs.com/ib/static/usersync/v3/async_usersync.html' + url: 'https://acdn.adnxs.com/ib/static/usersync/v3/async_usersync.html' }); } if (syncOptions.pixelEnabled && serverResponses.length > 0) { @@ -108,11 +108,11 @@ export const spec = { // syncs.push({ // type: 'iframe', - // url: '//acdn.adnxs.com/ib/static/usersync/v3/async_usersync.html' + // url: 'https://acdn.adnxs.com/ib/static/usersync/v3/async_usersync.html' // }); syncs.push({ type: 'iframe', - url: '//ads.betweendigital.com/sspmatch-iframe' + url: 'https://ads.betweendigital.com/sspmatch-iframe' }); return syncs; } diff --git a/modules/bidfluenceBidAdapter.js b/modules/bidfluenceBidAdapter.js index 4a9c4433ee0e..c6adc2897b0d 100644 --- a/modules/bidfluenceBidAdapter.js +++ b/modules/bidfluenceBidAdapter.js @@ -81,7 +81,7 @@ export const spec = { const payloadString = JSON.stringify(payload); return { method: 'POST', - url: `//bdf${payload.bids[0].pid}.bidfluence.com/Prebid`, + url: `https://bdf${payload.bids[0].pid}.bidfluence.com/Prebid`, data: payloadString, options: { contentType: 'text/plain' } }; diff --git a/modules/bidglassBidAdapter.js b/modules/bidglassBidAdapter.js index f5991f7f3a58..553a52b25f43 100644 --- a/modules/bidglassBidAdapter.js +++ b/modules/bidglassBidAdapter.js @@ -22,7 +22,7 @@ export const spec = { * @param {validBidRequests[]} - an array of bids * @return ServerRequest Info describing the request to the server. */ - buildRequests: function(validBidRequests, bidderRequest) { + buildRequests: function(validBidRequests, bidderRequest) { /* Sample array entry for validBidRequests[]: [{ @@ -42,32 +42,32 @@ export const spec = { */ let imps = []; - let getReferer = function() { - return window === window.top ? window.location.href : window.parent === window.top ? document.referrer : null; + let getReferer = function() { + return window === window.top ? window.location.href : window.parent === window.top ? document.referrer : null; }; - let getOrigins = function() { - var ori = [window.location.protocol + '//' + window.location.hostname]; - - if (window.location.ancestorOrigins) { - for (var i = 0; i < window.location.ancestorOrigins.length; i++) { - ori.push(window.location.ancestorOrigins[i]); - } - } else if (window !== window.top) { + let getOrigins = function() { + var ori = ['https://' + window.location.hostname]; + + if (window.location.ancestorOrigins) { + for (var i = 0; i < window.location.ancestorOrigins.length; i++) { + ori.push(window.location.ancestorOrigins[i]); + } + } else if (window !== window.top) { // Derive the parent origin var parts = document.referrer.split('/'); - ori.push(parts[0] + '//' + parts[2]); + ori.push('https://' + parts[2]); - if (window.parent !== window.top) { + if (window.parent !== window.top) { // Additional unknown origins exist - ori.push('null'); - } + ori.push('null'); + } } - return ori; + return ori; }; - utils._each(validBidRequests, function(bid) { + utils._each(validBidRequests, function(bid) { bid.sizes = ((utils.isArray(bid.sizes) && utils.isArray(bid.sizes[0])) ? bid.sizes : [bid.sizes]); bid.sizes = bid.sizes.filter(size => utils.isArray(size)); @@ -76,7 +76,7 @@ export const spec = { bidId: bid.bidId, sizes: bid.sizes, adUnitId: utils.getBidIdParameter('adUnitId', bid.params) - }); + }); }); // Stuff to send: page URL @@ -98,7 +98,7 @@ export const spec = { contentType: 'text/plain', withCredentials: false } - } + } }, /** @@ -107,10 +107,10 @@ export const spec = { * @param {ServerResponse} serverResponse A successful response from the server. * @return {Bid[]} An array of bids which were nested inside the server. */ - interpretResponse: function(serverResponse) { + interpretResponse: function(serverResponse) { const bidResponses = []; - utils._each(serverResponse.body.bidResponses, function(bid) { + utils._each(serverResponse.body.bidResponses, function(bid) { bidResponses.push({ requestId: bid.requestId, cpm: parseFloat(bid.cpm), @@ -123,10 +123,10 @@ export const spec = { netRevenue: true, ttl: bid.ttl || 10, ad: bid.ad - }); + }); }); - return bidResponses; + return bidResponses; } } diff --git a/modules/bidphysicsBidAdapter.js b/modules/bidphysicsBidAdapter.js index cbd76c8bc108..cdf30e670fc6 100644 --- a/modules/bidphysicsBidAdapter.js +++ b/modules/bidphysicsBidAdapter.js @@ -2,7 +2,7 @@ import {registerBidder} from '../src/adapters/bidderFactory'; import * as utils from '../src/utils'; import {BANNER} from '../src/mediaTypes'; -const ENDPOINT_URL = '//exchange.bidphysics.com/auction'; +const ENDPOINT_URL = 'https://exchange.bidphysics.com/auction'; const DEFAULT_BID_TTL = 30; const DEFAULT_CURRENCY = 'USD'; diff --git a/modules/bizzclickBidAdapter.js b/modules/bizzclickBidAdapter.js deleted file mode 100644 index a9b202b4c977..000000000000 --- a/modules/bizzclickBidAdapter.js +++ /dev/null @@ -1,105 +0,0 @@ -import { registerBidder } from '../src/adapters/bidderFactory'; -import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes'; -import * as utils from '../src/utils'; - -const BIDDER_CODE = 'bizzclick'; -const URL = '//supply.bizzclick.com/?c=o&m=multi'; -const URL_SYNC = '//supply.bizzclick.com/?c=o&m=cookie'; - -function isBidResponseValid(bid) { - if (!bid.requestId || !bid.cpm || !bid.creativeId || !bid.ttl || !bid.currency) { - return false; - } - switch (bid.mediaType) { - case BANNER: - return Boolean(bid.width && bid.height && bid.ad); - case VIDEO: - return Boolean(bid.vastUrl); - case NATIVE: - return Boolean(bid.native); - } - return false; -} - -export const spec = { - code: BIDDER_CODE, - supportedMediaTypes: [BANNER, VIDEO, NATIVE], - /** - * Determines whether or not the given bid request is valid. - * - * @param {object} bid The bid to validate. - * @return boolean True if this is a valid bid, and false otherwise. - */ - isBidRequestValid: (bid) => { - return Boolean(bid.bidId && bid.params && !isNaN(bid.params.placementId) && bid.params.type); - }, - - /** - * Make a server request from the list of BidRequests. - * - * @param {BidRequest[]} validBidRequests A non-empty list of valid bid requests that should be sent to the Server. - * @return ServerRequest Info describing the request to the server. - */ - buildRequests: (validBidRequests) => { - let winTop = window; - try { - window.top.location.toString(); - winTop = window.top; - } catch (e) { - utils.logMessage(e); - }; - const location = utils.getTopWindowLocation(); - const placements = []; - const len = validBidRequests.length; - for (let i = 0; i < len; i++) { - const bid = validBidRequests[i]; - const placement = { - placementId: bid.params.placementId, - bidId: bid.bidId, - sizes: bid.sizes, - type: bid.params.type - }; - placements.push(placement); - } - return { - method: 'POST', - url: URL, - data: { - 'deviceWidth': winTop.screen.width, - 'deviceHeight': winTop.screen.height, - 'secure': (location.protocol === 'https:') ? 1 : 0, - 'host': location.host, - 'page': location.pathname, - 'placements': placements - } - }; - }, - - /** - * Unpack the response from the server into a list of bids. - * - * @param {*} serverResponse A successful response from the server. - * @return {Bid[]} An array of bids which were nested inside the server. - */ - interpretResponse: (bidResponses) => { - const res = []; - bidResponses = bidResponses.body; - const len = bidResponses.length; - for (let i = 0; i < len; i++) { - const bid = bidResponses[i]; - if (isBidResponseValid(bid)) { - res.push(bid); - } - } - return res; - }, - - getUserSyncs: () => { - return [{ - type: 'image', - url: URL_SYNC - }]; - } -}; - -registerBidder(spec); diff --git a/modules/brainyBidAdapter.js b/modules/brainyBidAdapter.js deleted file mode 100644 index a5d076d8fd03..000000000000 --- a/modules/brainyBidAdapter.js +++ /dev/null @@ -1,154 +0,0 @@ -import * as utils from '../src/utils'; -import {registerBidder} from '../src/adapters/bidderFactory'; -import { BANNER } from '../src/mediaTypes'; - -const BIDDER_CODE = 'brainy'; -const BASE_URL = '//proparm.jp/ssp/p/pbjs'; - -/** - * Check if the browser supports flash - * 0 is return if it dosen't support flash - * @return {int} Flash version - */ -/** - * 接続元のブラウザがフラッシュに対応しているか判定 - * 対応していなければ0を返す - * @return {int} フラッシュのバージョン - */ -function _getFlash() { - try { - var _mac = (navigator.userAgent.indexOf('Mac') != -1); - if (document.all) { - if (_mac) { - if (window['sample']) { - return ((window['sample'].FlashVersion() & 0xffff0000) >> 16); - } - } else { - var _axo = new ActiveXObject('ShockwaveFlash.ShockwaveFlash'); - return Math.floor(_axo.FlashVersion() / 0x10000); - } - } else { - if (navigator.plugins && navigator.plugins['Shockwave Flash']) { - var info = navigator.plugins['Shockwave Flash'].description.split(' '); - var _v = parseInt(info[2]); - if (!isNaN(_v)) { - return _v; - } - } - } - } catch (e) {} - return 0; -} - -export const spec = { - code: BIDDER_CODE, - supportedMediaTypes: [BANNER], - - /** - * Check if the bid account ID and slotID is valid - * @param {object} bid the brainy bid to validate - * @return {boolean} - */ - /** - * adUnits.bidに値が入っているかを判断する - * @param {object} bid 検証する入札リクエスト - * @return {boolean} - */ - isBidRequestValid: function(bid) { - return !!(bid && bid.params && bid.params.accountID && bid.params.slotID); - }, - - /** - * Format the bid request object for our endpoint - * @param {BidRequest[]} bidRequests Array of brainy bidders - * @return object of parameters for Prebid AJAX request - */ - /** - * 入札リクエストをbrainyに対応するように整形する - * @param {BidRequest[]} bidRequests 入札のための配列 - * @return Prebid AJAX用に整形したオブジェクト - */ - buildRequests: function(validBidRequests) { - var bidRequests = []; - for (var i = 0, len = validBidRequests.length; i < len; i++) { - var bid = validBidRequests[i]; - var accountID = utils.getBidIdParameter('accountID', bid.params); - var slotID = utils.getBidIdParameter('slotID', bid.params); - var url = utils.getTopWindowUrl(); - var flash = _getFlash(); - var nocache = new Date().getTime() + Math.floor(Math.random() * 100000000); - var requestURL; - - requestURL = '_aid=' + accountID + '&'; - requestURL += '_slot=' + slotID + '&'; - requestURL += '_url=' + url + '&'; - requestURL += '_flash=' + flash + '&'; - requestURL += '_nocache=' + nocache; - - bidRequests.push({ - method: 'GET', - url: BASE_URL, - data: requestURL, - bidRequest: bid - }) - } - return bidRequests; - }, - - /** - * Format brainy responses as Prebid bid responses - * @param {String} brainyResponseObj A successful response from brainy. - * @param {object} request Object received from web page - * @return {object} An array of formatted bids. - */ - /** - * brainySSPからのレスポンスを解釈するメソッド - * @param {String} brainyResponseObj SSPから受け取った文字列 - * @param {object} request メディアから受け取ったオブジェクト - * @return {object} 分解、再格納したbidResponses - */ - interpretResponse: function (brainyResponseObj, request) { - var bidResponses = []; - var bidRequest = request.bidRequest; - var responseBody = brainyResponseObj ? brainyResponseObj.body : {}; - - bidResponses.push({ - requestId: bidRequest.bidId, - cpm: responseBody.cpm || 0, - width: responseBody.width, - height: responseBody.height, - creativeId: responseBody.adID, - currency: 'USD', - netRevenue: true, - ttl: 1000, - mediaType: BANNER, - ad: responseBody.src - }); - - return bidResponses; - }, - - /** - * SyncURLがある場合にレスポンスを解析してURLを返す - * @param {object} syncOptions Syncの設定 - * @param {object} serverResponses SSPからのレスポンス - * @return {object} 表示タイプとURLが入ったオブジェクト - */ - getUserSyncs: function(syncOptions, serverResponses) { - const syncs = []; - if (syncOptions.pixelEnabled) { - const brainyResponseObj = serverResponses[0].body; - if (!brainyResponseObj) { - return []; - } - if (brainyResponseObj.syncUrl && brainyResponseObj.syncUrl != 'null' && brainyResponseObj.syncUrl.length > 0) { - syncs.push({ - type: 'image', - url: brainyResponseObj.syncUrl - }); - } - } - return syncs; - } -}; -registerBidder(spec); diff --git a/modules/bridgewellBidAdapter.js b/modules/bridgewellBidAdapter.js deleted file mode 100644 index cac827e5a5d0..000000000000 --- a/modules/bridgewellBidAdapter.js +++ /dev/null @@ -1,269 +0,0 @@ -import * as utils from '../src/utils'; -import {registerBidder} from '../src/adapters/bidderFactory'; -import {BANNER, NATIVE} from '../src/mediaTypes'; -import find from 'core-js/library/fn/array/find'; - -const BIDDER_CODE = 'bridgewell'; -const REQUEST_ENDPOINT = '//rec.scupio.com/recweb/prebid.aspx?cb=' + Math.random(); -const BIDDER_VERSION = '0.0.2'; - -export const spec = { - code: BIDDER_CODE, - supportedMediaTypes: [BANNER, NATIVE], - - /** - * Determines whether or not the given bid request is valid. - * - * @param {BidRequest} bid The bid params to validate. - * @return boolean True if this is a valid bid, and false otherwise. - */ - isBidRequestValid: function(bid) { - let valid = false; - let typeOfCpmWeight; - - if (bid && bid.params) { - if (bid.params.ChannelID) { - // cpmWeight is optinal parameter and should above than zero - typeOfCpmWeight = typeof bid.params.cpmWeight; - if (typeOfCpmWeight === 'undefined') { - bid.params.cpmWeight = 1; - valid = true; - } else if (typeOfCpmWeight === 'number' && bid.params.cpmWeight > 0) { - valid = true; - } else { - valid = false; - } - } - } - - return valid; - }, - - /** - * Make a server request from the list of BidRequests. - * - * @param {BidRequest[]} validBidRequests - an array of bids - * @return ServerRequest Info describing the request to the server. - */ - buildRequests: function(validBidRequests) { - const adUnits = []; - utils._each(validBidRequests, function(bid) { - adUnits.push({ - ChannelID: bid.params.ChannelID, - mediaTypes: bid.mediaTypes || { - banner: { - sizes: bid.sizes - } - } - }); - }); - - return { - method: 'POST', - url: REQUEST_ENDPOINT, - data: { - version: { - prebid: '$prebid.version$', - bridgewell: BIDDER_VERSION - }, - inIframe: utils.inIframe(), - url: utils.getTopWindowUrl(), - referrer: utils.getTopWindowReferrer(), - adUnits: adUnits - }, - validBidRequests: validBidRequests - }; - }, - - /** - * Unpack the response from the server into a list of bids. - * - * @param {*} serverResponse A successful response from the server. - * @param {*} bidRequest - * @return {Bid[]} An array of bids which were nested inside the server. - */ - interpretResponse: function(serverResponse, bidRequest) { - const bidResponses = []; - - // map responses to requests - utils._each(bidRequest.validBidRequests, function(req) { - const bidResponse = {}; - - if (!serverResponse.body) { - return; - } - - let matchedResponse = find(serverResponse.body, function(res) { - let valid = false; - - if (!!res && !res.consumed) { // response exists and not consumed - if (res.width && res.height) { - let mediaTypes = req.mediaTypes; - // for prebid 1.0 and later usage, mediaTypes.banner.sizes - let sizes = mediaTypes && mediaTypes.banner && mediaTypes.banner.sizes ? mediaTypes.banner.sizes : req.sizes; - if (sizes) { - let sizeValid; - let width = res.width; - let height = res.height; - // check response size validation - if (typeof sizes[0] === 'number') { // for foramt Array[Number] check - sizeValid = width === sizes[0] && height === sizes[1]; - } else { // for format Array[Array[Number]] check - sizeValid = find(sizes, function(size) { - return (width === size[0] && height === size[1]); - }); - } - - if (sizeValid || (mediaTypes && mediaTypes.native)) { // dont care native sizes - valid = true; - } - } - } - } - - return valid; - }); - - if (matchedResponse) { - matchedResponse.consumed = true; - - // check required parameters - if (typeof matchedResponse.cpm !== 'number') { - return; - } else if (typeof matchedResponse.netRevenue !== 'boolean') { - return; - } else if (typeof matchedResponse.currency !== 'string') { - return; - } else if (typeof matchedResponse.mediaType !== 'string') { - return; - } - - bidResponse.requestId = req.bidId; - bidResponse.cpm = matchedResponse.cpm * req.params.cpmWeight; - bidResponse.width = matchedResponse.width; - bidResponse.height = matchedResponse.height; - bidResponse.ttl = matchedResponse.ttl; - bidResponse.creativeId = matchedResponse.id; - bidResponse.netRevenue = matchedResponse.netRevenue; - bidResponse.currency = matchedResponse.currency; - bidResponse.mediaType = matchedResponse.mediaType; - - // check required parameters by matchedResponse.mediaType - switch (matchedResponse.mediaType) { - case BANNER: - // check banner required parameters - if (typeof matchedResponse.ad !== 'string') { - return; - } - - bidResponse.ad = matchedResponse.ad; - break; - case NATIVE: - // check native required parameters - if (!matchedResponse.native) { - return; - } - - let reqNativeLayout = req.mediaTypes.native; - let resNative = matchedResponse.native; - - // check title - let title = reqNativeLayout.title; - if (title && title.required) { - if (typeof resNative.title !== 'string') { - return; - } else if (title.len && title.len < resNative.title.length) { - return; - } - } - - // check body - let body = reqNativeLayout.body; - if (body && body.required) { - if (typeof resNative.body !== 'string') { - return; - } - } - - // check image - let image = reqNativeLayout.image; - if (image && image.required) { - if (resNative.image) { - if (typeof resNative.image.url !== 'string') { // check image url - return; - } else { - if (resNative.image.width !== image.sizes[0] || resNative.image.height !== image.sizes[1]) { // check image sizes - return; - } - } - } else { - return; - } - } - - // check sponsoredBy - let sponsoredBy = reqNativeLayout.sponsoredBy; - if (sponsoredBy && sponsoredBy.required) { - if (typeof resNative.sponsoredBy !== 'string') { - return; - } - } - - // check icon - let icon = reqNativeLayout.icon; - if (icon && icon.required) { - if (resNative.icon) { - if (typeof resNative.icon.url !== 'string') { // check icon url - return; - } else { - if (resNative.icon.width !== icon.sizes[0] || resNative.icon.height !== icon.sizes[0]) { // check image sizes - return; - } - } - } else { - return; - } - } - - // check clickUrl - if (typeof resNative.clickUrl !== 'string') { - return; - } - - // check clickTracker - let clickTrackers = resNative.clickTrackers; - if (clickTrackers) { - if (clickTrackers.length === 0) { - return; - } - } else { - return; - } - - // check impressionTrackers - let impressionTrackers = resNative.impressionTrackers; - if (impressionTrackers) { - if (impressionTrackers.length === 0) { - return; - } - } else { - return; - } - - bidResponse.native = matchedResponse.native; - - break; - - default: // response mediaType is not supported - return; - } - - bidResponses.push(bidResponse); - } - }); - - return bidResponses; - } -}; - -registerBidder(spec); diff --git a/modules/c1xBidAdapter.js b/modules/c1xBidAdapter.js index 1e8d3cf2e0ae..9364ef2256ae 100644 --- a/modules/c1xBidAdapter.js +++ b/modules/c1xBidAdapter.js @@ -4,7 +4,7 @@ import { userSync } from '../src/userSync'; const BIDDER_CODE = 'c1x'; const URL = 'https://ht.c1exchange.com/ht'; -const PIXEL_ENDPOINT = '//px.c1exchange.com/pubpixel/'; +const PIXEL_ENDPOINT = 'https://px.c1exchange.com/pubpixel/'; const LOG_MSG = { invalidBid: 'C1X: [ERROR] bidder returns an invalid bid', noSite: 'C1X: [ERROR] no site id supplied', @@ -41,7 +41,6 @@ export const c1xAdapter = { // flattened tags in a tag object tagObj = c1xTags.reduce((current, next) => Object.assign(current, next)); const pixelId = tagObj.pixelId; - const useSSL = document.location.protocol; payload = { adunits: adunits.toString(), @@ -58,7 +57,7 @@ export const c1xAdapter = { } if (pixelId) { - pixelUrl = (useSSL ? 'https:' : 'http:') + PIXEL_ENDPOINT + pixelId; + pixelUrl = PIXEL_ENDPOINT + pixelId; if (payload.consent_required) { pixelUrl += '&gdpr=' + (bidderRequest.gdprConsent.gdprApplies ? 1 : 0); pixelUrl += '&consent=' + encodeURIComponent(bidderRequest.gdprConsent.consentString || ''); diff --git a/modules/ccxBidAdapter.js b/modules/ccxBidAdapter.js deleted file mode 100644 index 226ed44f6da1..000000000000 --- a/modules/ccxBidAdapter.js +++ /dev/null @@ -1,216 +0,0 @@ -import * as utils from '../src/utils' -import { registerBidder } from '../src/adapters/bidderFactory' -import { config } from '../src/config' -const BIDDER_CODE = 'ccx' -const BID_URL = 'https://delivery.clickonometrics.pl/ortb/prebid/bid' -const SUPPORTED_VIDEO_PROTOCOLS = [2, 3, 5, 6] -const SUPPORTED_VIDEO_MIMES = ['video/mp4', 'video/x-flv'] -const SUPPORTED_VIDEO_PLAYBACK_METHODS = [1, 2, 3, 4] - -function _getDeviceObj () { - let device = {} - device.w = screen.width - device.y = screen.height - device.ua = navigator.userAgent - return device -} - -function _getSiteObj () { - let site = {} - let url = config.getConfig('pageUrl') || utils.getTopWindowUrl() - if (url.length > 0) { - url = url.split('?')[0] - } - site.page = url - - return site -} - -function _validateSizes (sizeObj, type) { - if (!utils.isArray(sizeObj) || typeof sizeObj[0] === 'undefined') { - return false - } - - if (type === 'video' && (!utils.isArray(sizeObj[0]) || sizeObj[0].length !== 2)) { - return false - } - - let result = true - - if (type === 'banner') { - utils._each(sizeObj, function (size) { - if (!utils.isArray(size) || (size.length !== 2)) { - result = false - } - }) - return result - } - - if (type === 'old') { - if (!utils.isArray(sizeObj[0]) && sizeObj.length !== 2) { - result = false - } else if (utils.isArray(sizeObj[0])) { - utils._each(sizeObj, function (size) { - if (!utils.isArray(size) || (size.length !== 2)) { - result = false - } - }) - } - return result; - } - - return true -} - -function _buildBid (bid) { - let placement = {} - placement.id = bid.bidId - placement.secure = 1 - - let sizes = utils.deepAccess(bid, 'mediaTypes.banner.sizes') || utils.deepAccess(bid, 'mediaTypes.video.playerSize') || utils.deepAccess(bid, 'sizes') - - if (utils.deepAccess(bid, 'mediaTypes.banner') || utils.deepAccess(bid, 'mediaType') === 'banner' || (!utils.deepAccess(bid, 'mediaTypes.video') && !utils.deepAccess(bid, 'mediaType'))) { - placement.banner = {'format': []} - if (utils.isArray(sizes[0])) { - utils._each(sizes, function (size) { - placement.banner.format.push({'w': size[0], 'h': size[1]}) - }) - } else { - placement.banner.format.push({'w': sizes[0], 'h': sizes[1]}) - } - } else if (utils.deepAccess(bid, 'mediaTypes.video') || utils.deepAccess(bid, 'mediaType') === 'video') { - placement.video = {} - - if (typeof sizes !== 'undefined') { - if (utils.isArray(sizes[0])) { - placement.video.w = sizes[0][0] - placement.video.h = sizes[0][1] - } else { - placement.video.w = sizes[0] - placement.video.h = sizes[1] - } - } - - placement.video.protocols = utils.deepAccess(bid, 'params.video.protocols') || SUPPORTED_VIDEO_PROTOCOLS - placement.video.mimes = utils.deepAccess(bid, 'params.video.mimes') || SUPPORTED_VIDEO_MIMES - placement.video.playbackmethod = utils.deepAccess(bid, 'params.video.playbackmethod') || SUPPORTED_VIDEO_PLAYBACK_METHODS - placement.video.skip = utils.deepAccess(bid, 'params.video.skip') || 0 - if (placement.video.skip === 1 && utils.deepAccess(bid, 'params.video.skipafter')) { - placement.video.skipafter = utils.deepAccess(bid, 'params.video.skipafter') - } - } - - placement.ext = {'pid': bid.params.placementId} - - return placement -} - -function _buildResponse (bid, currency, ttl) { - let resp = { - requestId: bid.impid, - cpm: bid.price, - width: bid.w, - height: bid.h, - creativeId: bid.crid, - netRevenue: false, - ttl: ttl, - currency: currency - } - - if (bid.ext.type === 'video') { - resp.vastXml = bid.adm - } else { - resp.ad = bid.adm - } - - if (utils.deepAccess(bid, 'dealid')) { - resp.dealId = bid.dealid - } - - return resp -} - -export const spec = { - code: BIDDER_CODE, - supportedMediaTypes: ['banner', 'video'], - - isBidRequestValid: function (bid) { - if (!utils.deepAccess(bid, 'params.placementId')) { - utils.logWarn('placementId param is reqeuired.') - return false - } - if (utils.deepAccess(bid, 'mediaTypes.banner.sizes')) { - let isValid = _validateSizes(bid.mediaTypes.banner.sizes, 'banner') - if (!isValid) { - utils.logWarn('Bid sizes are invalid.') - } - return isValid - } else if (utils.deepAccess(bid, 'mediaTypes.video.playerSize')) { - let isValid = _validateSizes(bid.mediaTypes.video.playerSize, 'video') - if (!isValid) { - utils.logWarn('Bid sizes are invalid.') - } - return isValid - } else if (utils.deepAccess(bid, 'sizes')) { - let isValid = _validateSizes(bid.sizes, 'old') - if (!isValid) { - utils.logWarn('Bid sizes are invalid.') - } - return isValid - } else { - utils.logWarn('Bid sizes are required.') - return false - } - }, - buildRequests: function (validBidRequests, bidderRequest) { - // check if validBidRequests is not empty - if (validBidRequests.length > 0) { - let requestBody = {} - requestBody.imp = [] - requestBody.site = _getSiteObj() - requestBody.device = _getDeviceObj() - requestBody.id = bidderRequest.bids[0].auctionId - requestBody.ext = {'ce': (utils.cookiesAreEnabled() ? 1 : 0)} - utils._each(validBidRequests, function (bid) { - requestBody.imp.push(_buildBid(bid)) - }) - // Return the server request - return { - 'method': 'POST', - 'url': BID_URL, - 'data': JSON.stringify(requestBody) - } - } - }, - interpretResponse: function (serverResponse, request) { - const bidResponses = [] - - // response is not empty (HTTP 204) - if (!utils.isEmpty(serverResponse.body)) { - utils._each(serverResponse.body.seatbid, function (seatbid) { - utils._each(seatbid.bid, function (bid) { - bidResponses.push(_buildResponse(bid, serverResponse.body.cur, serverResponse.body.ext.ttl)) - }) - }) - } - - return bidResponses - }, - getUserSyncs: function (syncOptions, serverResponses) { - const syncs = [] - - if (utils.deepAccess(serverResponses[0], 'body.ext.usersync') && !utils.isEmpty(serverResponses[0].body.ext.usersync)) { - utils._each(serverResponses[0].body.ext.usersync, function (match) { - if ((syncOptions.iframeEnabled && match.type === 'iframe') || (syncOptions.pixelEnabled && match.type === 'image')) { - syncs.push({ - type: match.type, - url: match.url - }) - } - }) - } - - return syncs - } -} -registerBidder(spec) diff --git a/modules/cedatoBidAdapter.js b/modules/cedatoBidAdapter.js index a9e7814842cb..dc6b3c44f3d8 100644 --- a/modules/cedatoBidAdapter.js +++ b/modules/cedatoBidAdapter.js @@ -3,8 +3,8 @@ import { registerBidder } from '../src/adapters/bidderFactory'; import { BANNER, VIDEO } from '../src/mediaTypes'; const BIDDER_CODE = 'cedato'; -const BID_URL = '//h.cedatoplayer.com/hb'; -const SYNC_URL = '//h.cedatoplayer.com/hb_usync?uid={UUID}'; +const BID_URL = 'https://h.cedatoplayer.com/hb'; +const SYNC_URL = 'https://h.cedatoplayer.com/hb_usync?uid={UUID}'; const COOKIE_NAME = 'hb-cedato-id'; const UUID_LEN = 36; const TTL = 10000; diff --git a/modules/cleanmedianetBidAdapter.js b/modules/cleanmedianetBidAdapter.js deleted file mode 100644 index 15871e1a6ae9..000000000000 --- a/modules/cleanmedianetBidAdapter.js +++ /dev/null @@ -1,300 +0,0 @@ -import * as utils from '../src/utils'; -import {parse} from '../src/url'; -import {registerBidder} from '../src/adapters/bidderFactory'; -import {config} from '../src/config'; -import {Renderer} from '../src/Renderer'; -import {BANNER, VIDEO} from '../src/mediaTypes'; - -export const helper = { - startsWith: function (str, search) { - return str.substr(0, search.length) === search; - }, - getMediaType: function (bid) { - if (bid.ext) { - if (bid.ext.media_type) { - return bid.ext.media_type.toLowerCase(); - } else if (bid.ext.vast_url) { - return VIDEO; - } else { - return BANNER; - } - } - return BANNER; - } -}; - -export const spec = { - code: 'cleanmedianet', - aliases: [], - supportedMediaTypes: [BANNER, VIDEO], - - isBidRequestValid: function (bid) { - return ( - !!bid.params.supplyPartnerId && - typeof bid.params.supplyPartnerId === 'string' && - (typeof bid.params.bidfloor === 'undefined' || - typeof bid.params.bidfloor === 'number') && - (typeof bid.params['adpos'] === 'undefined' || - typeof bid.params['adpos'] === 'number') && - (typeof bid.params['protocols'] === 'undefined' || - Array.isArray(bid.params['protocols'])) && - (typeof bid.params.instl === 'undefined' || - bid.params.instl === 0 || - bid.params.instl === 1) - ); - }, - - buildRequests: function (validBidRequests, bidderRequest) { - return validBidRequests.map(bidRequest => { - const { - adUnitCode, - auctionId, - mediaTypes, - params, - sizes, - transactionId - } = bidRequest; - const baseEndpoint = 'https://bidder.cleanmediaads.com'; - const rtbEndpoint = - `${baseEndpoint}/r/${ - params.supplyPartnerId - }/bidr?rformat=open_rtb&reqformat=rtb_json&bidder=prebid` + - (params.query ? '&' + params.query : ''); - let url = - config.getConfig('pageUrl') || bidderRequest.refererInfo.referer; - - const rtbBidRequest = { - id: auctionId, - site: { - domain: parse(url).hostname, - page: url, - ref: bidderRequest.refererInfo.referer - }, - device: { - ua: navigator.userAgent - }, - imp: [], - ext: {} - }; - - if ( - bidderRequest.gdprConsent && - bidderRequest.gdprConsent.consentString && - bidderRequest.gdprConsent.gdprApplies - ) { - rtbBidRequest.ext.gdpr_consent = { - consent_string: bidderRequest.gdprConsent.consentString, - consent_required: bidderRequest.gdprConsent.gdprApplies - }; - } - - const imp = { - id: transactionId, - instl: params.instl === 1 ? 1 : 0, - tagid: adUnitCode, - bidfloor: params.bidfloor || 0, - bidfloorcur: 'USD', - secure: helper.startsWith( - utils.getTopWindowUrl().toLowerCase(), - 'http://' - ) - ? 0 - : 1 - }; - - const hasFavoredMediaType = - params.favoredMediaType && - this.supportedMediaTypes.includes(params.favoredMediaType); - - if (!mediaTypes || mediaTypes.banner) { - if (!hasFavoredMediaType || params.favoredMediaType === BANNER) { - const bannerImp = Object.assign({}, imp, { - banner: { - w: sizes.length ? sizes[0][0] : 300, - h: sizes.length ? sizes[0][1] : 250, - pos: params.pos || 0, - topframe: bidderRequest.refererInfo.reachedTop - } - }); - rtbBidRequest.imp.push(bannerImp); - } - } - - if (mediaTypes && mediaTypes.video) { - if (!hasFavoredMediaType || params.favoredMediaType === VIDEO) { - let videoImp = { - video: { - protocols: params.protocols || [1, 2, 3, 4, 5, 6], - pos: params.pos || 0, - ext: {context: mediaTypes.video.context} - } - }; - - let playerSize = mediaTypes.video.playerSize || sizes; - if (utils.isArray(playerSize[0])) { - videoImp.video.w = playerSize[0][0]; - videoImp.video.h = playerSize[0][1]; - } else if (utils.isNumber(playerSize[0])) { - videoImp.video.w = playerSize[0]; - videoImp.video.h = playerSize[1]; - } else { - videoImp.video.w = 300; - videoImp.video.h = 250; - } - - videoImp = Object.assign({}, imp, videoImp); - rtbBidRequest.imp.push(videoImp); - } - } - - if (rtbBidRequest.imp.length === 0) { - return; - } - - return { - method: 'POST', - url: rtbEndpoint, - data: rtbBidRequest, - bidRequest - }; - }); - }, - - interpretResponse: function (serverResponse, bidRequest) { - const response = serverResponse && serverResponse.body; - if (!response) { - utils.logError('empty response'); - return []; - } - - const bids = response.seatbid.reduce( - (acc, seatBid) => acc.concat(seatBid.bid), - [] - ); - let outBids = []; - - bids.forEach(bid => { - const outBid = { - requestId: bidRequest.bidRequest.bidId, - cpm: bid.price, - width: bid.w, - height: bid.h, - ttl: 60 * 10, - creativeId: bid.crid || bid.adid, - netRevenue: true, - currency: bid.cur || response.cur, - mediaType: helper.getMediaType(bid) - }; - - if ( - utils.deepAccess( - bidRequest.bidRequest, - 'mediaTypes.' + outBid.mediaType - ) - ) { - if (outBid.mediaType === BANNER) { - outBids.push(Object.assign({}, outBid, {ad: bid.adm})); - } else if (outBid.mediaType === VIDEO) { - const context = utils.deepAccess( - bidRequest.bidRequest, - 'mediaTypes.video.context' - ); - outBids.push( - Object.assign({}, outBid, { - vastUrl: bid.ext.vast_url, - vastXml: bid.adm, - renderer: - context === 'outstream' - ? newRenderer(bidRequest.bidRequest, bid) - : undefined - }) - ); - } - } - }); - return outBids; - }, - - getUserSyncs: function (syncOptions, serverResponses, gdprConsent) { - const syncs = []; - const gdprApplies = - gdprConsent && typeof gdprConsent.gdprApplies === 'boolean' - ? gdprConsent.gdprApplies - : false; - const suffix = gdprApplies - ? 'gc=' + encodeURIComponent(gdprConsent.consentString) - : 'gc=missing'; - serverResponses.forEach(resp => { - if (resp.body) { - const bidResponse = resp.body; - if (bidResponse.ext && Array.isArray(bidResponse.ext['utrk'])) { - bidResponse.ext['utrk'].forEach(pixel => { - const url = - pixel.url + - (pixel.url.indexOf('?') > 0 ? '&' + suffix : '?' + suffix); - return syncs.push({type: pixel.type, url}); - }); - } - if (Array.isArray(bidResponse.seatbid)) { - bidResponse.seatbid.forEach(seatBid => { - if (Array.isArray(seatBid.bid)) { - seatBid.bid.forEach(bid => { - if (bid.ext && Array.isArray(bid.ext['utrk'])) { - bid.ext['utrk'].forEach(pixel => { - const url = - pixel.url + - (pixel.url.indexOf('?') > 0 - ? '&' + suffix - : '?' + suffix); - return syncs.push({type: pixel.type, url}); - }); - } - }); - } - }); - } - } - }); - return syncs; - } -}; - -function newRenderer(bidRequest, bid, rendererOptions = {}) { - const renderer = Renderer.install({ - url: - (bidRequest.params && bidRequest.params.rendererUrl) || - (bid.ext && bid.ext.renderer_url) || - '//s.wlplayer.com/video/latest/renderer.js', - config: rendererOptions, - loaded: false - }); - try { - renderer.setRender(renderOutstream); - } catch (err) { - utils.logWarn('Prebid Error calling setRender on renderer', err); - } - return renderer; -} - -function renderOutstream(bid) { - bid.renderer.push(() => { - const unitId = bid.adUnitCode + '/' + bid.adId; - window['GamoshiPlayer'].renderAd({ - id: unitId, - debug: window.location.href.indexOf('pbjsDebug') >= 0, - placement: document.getElementById(bid.adUnitCode), - width: bid.width, - height: bid.height, - events: { - ALL_ADS_COMPLETED: () => - window.setTimeout(() => { - window['GamoshiPlayer'].removeAd(unitId); - }, 300) - }, - vastUrl: bid.vastUrl, - vastXml: bid.vastXml - }); - }); -} - -registerBidder(spec); diff --git a/modules/clickforceBidAdapter.js b/modules/clickforceBidAdapter.js index 16ecdf713d9b..43ef76cc9315 100644 --- a/modules/clickforceBidAdapter.js +++ b/modules/clickforceBidAdapter.js @@ -2,7 +2,7 @@ import * as utils from '../src/utils'; import {registerBidder} from '../src/adapters/bidderFactory'; import {BANNER, NATIVE} from '../src/mediaTypes'; const BIDDER_CODE = 'clickforce'; -const ENDPOINT_URL = '//ad.doublemax.net/adserver/prebid.json?cb=' + new Date().getTime() + '&hb=1&ver=1.21'; +const ENDPOINT_URL = 'https://ad.doublemax.net/adserver/prebid.json?cb=' + new Date().getTime() + '&hb=1&ver=1.21'; export const spec = { code: BIDDER_CODE, diff --git a/modules/collectcentBidAdapter.js b/modules/collectcentBidAdapter.js index 50ac377788eb..f7f5f3ef0c41 100644 --- a/modules/collectcentBidAdapter.js +++ b/modules/collectcentBidAdapter.js @@ -3,8 +3,8 @@ import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes'; import * as utils from '../src/utils'; const BIDDER_CODE = 'collectcent'; -const URL_MULTI = '//publishers.motionspots.com/?c=o&m=multi'; -const URL_SYNC = '//publishers.motionspots.com/?c=o&m=cookie'; +const URL_MULTI = 'https://publishers.motionspots.com/?c=o&m=multi'; +const URL_SYNC = 'https://publishers.motionspots.com/?c=o&m=cookie'; export const spec = { code: BIDDER_CODE, diff --git a/modules/colombiaBidAdapter.js b/modules/colombiaBidAdapter.js deleted file mode 100644 index e5ebc41ebfde..000000000000 --- a/modules/colombiaBidAdapter.js +++ /dev/null @@ -1,72 +0,0 @@ -import * as utils from '../src/utils'; -import {config} from '../src/config'; -import {registerBidder} from '../src/adapters/bidderFactory'; -const BIDDER_CODE = 'colombia'; -const ENDPOINT_URL = 'https://ade.clmbtech.com/cde/prebid.htm'; -const HOST_NAME = document.location.protocol + '//' + window.location.host; - -export const spec = { - code: BIDDER_CODE, - aliases: ['clmb'], - isBidRequestValid: function(bid) { - return !!(bid.params.placementId); - }, - buildRequests: function(validBidRequests) { - return validBidRequests.map(bidRequest => { - const params = bidRequest.params; - const sizes = utils.parseSizesInput(bidRequest.sizes)[0]; - const width = sizes.split('x')[0]; - const height = sizes.split('x')[1]; - const placementId = params.placementId; - const cb = Math.floor(Math.random() * 99999999999); - const referrer = encodeURIComponent(utils.getTopWindowUrl()); - const bidId = bidRequest.bidId; - const payload = { - v: 'hb1', - p: placementId, - w: width, - h: height, - cb: cb, - r: referrer, - uid: bidId, - t: 'i', - d: HOST_NAME, - }; - return { - method: 'POST', - url: ENDPOINT_URL, - data: payload, - } - }); - }, - interpretResponse: function(serverResponse, bidRequest) { - const bidResponses = []; - const response = serverResponse.body; - const crid = response.creativeId || 0; - const width = response.width || 0; - const height = response.height || 0; - const cpm = response.cpm || 0; - if (width !== 0 && height !== 0 && cpm !== 0 && crid !== 0) { - const dealId = response.dealid || ''; - const currency = response.currency || 'USD'; - const netRevenue = (response.netRevenue === undefined) ? true : response.netRevenue; - const referrer = utils.getTopWindowUrl(); - const bidResponse = { - requestId: bidRequest.data.uid, - cpm: cpm, - width: response.width, - height: response.height, - creativeId: crid, - dealId: dealId, - currency: currency, - netRevenue: netRevenue, - ttl: config.getConfig('_bidderTimeout'), - referrer: referrer, - ad: response.ad - }; - bidResponses.push(bidResponse); - } - return bidResponses; - } -} -registerBidder(spec); diff --git a/modules/contentigniteBidAdapter.js b/modules/contentigniteBidAdapter.js deleted file mode 100644 index 2e3092114f63..000000000000 --- a/modules/contentigniteBidAdapter.js +++ /dev/null @@ -1,115 +0,0 @@ -import { registerBidder } from '../src/adapters/bidderFactory'; -import { config } from '../src/config'; -import * as utils from '../src/utils'; - -const BIDDER_CODE = 'contentignite'; - -export const spec = { - code: BIDDER_CODE, - pageID: Math.floor(Math.random() * 10e6), - - isBidRequestValid: (bid) => { - return !!(bid.params.accountID && bid.params.zoneID); - }, - - buildRequests: (validBidRequests) => { - let i; - let zoneID; - let bidRequest; - let accountID; - let keyword; - let requestURI; - const serverRequests = []; - const zoneCounters = {}; - - for (i = 0; i < validBidRequests.length; i++) { - bidRequest = validBidRequests[i]; - zoneID = utils.getBidIdParameter('zoneID', bidRequest.params); - accountID = utils.getBidIdParameter('accountID', bidRequest.params); - keyword = utils.getBidIdParameter('keyword', bidRequest.params); - - if (!(zoneID in zoneCounters)) { - zoneCounters[zoneID] = 0; - } - - requestURI = - location.protocol + '//serve.connectignite.com/adserve/;type=hbr;'; - requestURI += `ID=${encodeURIComponent(accountID)};`; - requestURI += `setID=${encodeURIComponent(zoneID)};`; - requestURI += `pid=${spec.pageID};`; - requestURI += `place=${encodeURIComponent(zoneCounters[zoneID])};`; - - // append the keyword for targeting if one was passed in - if (keyword !== '') { - requestURI += `kw=${encodeURIComponent(keyword)};`; - } - - zoneCounters[zoneID]++; - serverRequests.push({ - method: 'GET', - url: requestURI, - data: {}, - bidRequest: bidRequest - }); - } - return serverRequests; - }, - - // tslint:disable-next-line:cyclomatic-complexity - interpretResponse: (serverResponse, bidRequest) => { - const bidObj = bidRequest.bidRequest; - const bidResponses = []; - const bidResponse = {}; - let isCorrectSize = false; - let isCorrectCPM = true; - let cpm; - let minCPM; - let maxCPM; - let width; - let height; - - serverResponse = serverResponse.body; - if (serverResponse && serverResponse.status === 'SUCCESS' && bidObj) { - cpm = serverResponse.cpm; - minCPM = utils.getBidIdParameter('minCPM', bidObj.params); - maxCPM = utils.getBidIdParameter('maxCPM', bidObj.params); - width = parseInt(serverResponse.width); - height = parseInt(serverResponse.height); - - // Ensure response CPM is within the given bounds - if (minCPM !== '' && cpm < parseFloat(minCPM)) { - isCorrectCPM = false; - utils.logWarn('ContentIgnite: CPM did not meet minCPM requirements.'); - } else if (maxCPM !== '' && cpm > parseFloat(maxCPM)) { - isCorrectCPM = false; - utils.logWarn('ContentIgnite: CPM did not meet maxCPM requirements.'); - } - - // Ensure that response ad matches one of the placement sizes. - utils._each(bidObj.sizes, (size) => { - if (width === size[0] && height === size[1]) { - isCorrectSize = true; - } else { - utils.logWarn( - 'ContentIgnite: Returned ad is of a different size to that requested.' - ); - } - }); - if (isCorrectCPM && isCorrectSize) { - bidResponse.requestId = bidObj.bidId; - bidResponse.creativeId = serverResponse.placement_id; - bidResponse.cpm = cpm; - bidResponse.width = width; - bidResponse.height = height; - bidResponse.ad = serverResponse.ad_code; - bidResponse.currency = 'USD'; - bidResponse.netRevenue = true; - bidResponse.ttl = config.getConfig('_bidderTimeout'); - bidResponse.referrer = utils.getTopWindowUrl(); - bidResponses.push(bidResponse); - } - } - return bidResponses; - } -}; -registerBidder(spec); diff --git a/modules/cosmosBidAdapter.js b/modules/cosmosBidAdapter.js index 84131bfa1319..f3a8979165b8 100644 --- a/modules/cosmosBidAdapter.js +++ b/modules/cosmosBidAdapter.js @@ -3,8 +3,8 @@ import { BANNER, VIDEO } from '../src/mediaTypes'; import * as utils from '../src/utils'; const BIDDER_CODE = 'cosmos'; -const BID_ENDPOINT = '//bid.cosmoshq.com/openrtb2/bids'; -const USER_SYNC_ENDPOINT = '//sync.cosmoshq.com/js/v1/usersync.html'; +const BID_ENDPOINT = 'https://bid.cosmoshq.com/openrtb2/bids'; +const USER_SYNC_ENDPOINT = 'https://sync.cosmoshq.com/js/v1/usersync.html'; const HTTP_POST = 'POST'; const LOG_PREFIX = 'COSMOS: '; const DEFAULT_CURRENCY = 'USD'; diff --git a/modules/cpmstarBidAdapter.js b/modules/cpmstarBidAdapter.js index 84b76cbbc357..8d2ec31a2c62 100644 --- a/modules/cpmstarBidAdapter.js +++ b/modules/cpmstarBidAdapter.js @@ -5,9 +5,9 @@ import {VIDEO, BANNER} from '../src/mediaTypes'; const BIDDER_CODE = 'cpmstar'; -const ENDPOINT_DEV = '//dev.server.cpmstar.com/view.aspx'; -const ENDPOINT_STAGING = '//staging.server.cpmstar.com/view.aspx'; -const ENDPOINT_PRODUCTION = '//server.cpmstar.com/view.aspx'; +const ENDPOINT_DEV = 'https://dev.server.cpmstar.com/view.aspx'; +const ENDPOINT_STAGING = 'https://staging.server.cpmstar.com/view.aspx'; +const ENDPOINT_PRODUCTION = 'https://server.cpmstar.com/view.aspx'; const DEFAULT_TTL = 300; const DEFAULT_CURRENCY = 'USD'; diff --git a/modules/danmarketBidAdapter.js b/modules/danmarketBidAdapter.js deleted file mode 100644 index 77f90f433192..000000000000 --- a/modules/danmarketBidAdapter.js +++ /dev/null @@ -1,161 +0,0 @@ -import * as utils from '../src/utils'; -import {registerBidder} from '../src/adapters/bidderFactory'; -const BIDDER_CODE = 'danmarket'; -const ENDPOINT_URL = '//ads.danmarketplace.com/hb'; -const TIME_TO_LIVE = 360; -const ADAPTER_SYNC_URL = '//ads.danmarketplace.com/push_sync'; -const LOG_ERROR_MESS = { - noAuid: 'Bid from response has no auid parameter - ', - noAdm: 'Bid from response has no adm parameter - ', - noBid: 'Array of bid objects is empty', - noPlacementCode: 'Can\'t find in requested bids the bid with auid - ', - emptyUids: 'Uids should be not empty', - emptySeatbid: 'Seatbid array from response has empty item', - emptyResponse: 'Response is empty', - hasEmptySeatbidArray: 'Response has empty seatbid array', - hasNoArrayOfBids: 'Seatbid from response has no array of bid objects - ' -}; - -/** - * Dentsu Aegis Network Marketplace Bid Adapter. - * Contact: niels@baarsma.net - * - */ -export const spec = { - code: BIDDER_CODE, - - aliases: ['DANMarketplace', 'DAN_Marketplace', 'danmarketplace'], - - isBidRequestValid: function(bid) { - return !!bid.params.uid; - }, - - buildRequests: function(validBidRequests, bidderRequest) { - const auids = []; - const bidsMap = {}; - const bids = validBidRequests || []; - let priceType = 'net'; - let reqId; - - bids.forEach(bid => { - if (bid.params.priceType === 'gross') { - priceType = 'gross'; - } - if (!bidsMap[bid.params.uid]) { - bidsMap[bid.params.uid] = [bid]; - auids.push(bid.params.uid); - } else { - bidsMap[bid.params.uid].push(bid); - } - reqId = bid.bidderRequestId; - }); - - const payload = { - u: utils.getTopWindowUrl(), - pt: priceType, - auids: auids.join(','), - r: reqId, - }; - - if (bidderRequest && bidderRequest.gdprConsent) { - if (bidderRequest.gdprConsent.consentString) { - payload.gdpr_consent = bidderRequest.gdprConsent.consentString; - } - payload.gdpr_applies = - (typeof bidderRequest.gdprConsent.gdprApplies === 'boolean') - ? Number(bidderRequest.gdprConsent.gdprApplies) : 1; - } - - return { - method: 'GET', - url: ENDPOINT_URL, - data: payload, - bidsMap: bidsMap, - }; - }, - - interpretResponse: function(serverResponse, bidRequest) { - serverResponse = serverResponse && serverResponse.body - const bidResponses = []; - const bidsMap = bidRequest.bidsMap; - const priceType = bidRequest.data.pt; - - let errorMessage; - - if (!serverResponse) errorMessage = LOG_ERROR_MESS.emptyResponse; - else if (serverResponse.seatbid && !serverResponse.seatbid.length) { - errorMessage = LOG_ERROR_MESS.hasEmptySeatbidArray; - } - - if (!errorMessage && serverResponse.seatbid) { - serverResponse.seatbid.forEach(respItem => { - _addBidResponse(_getBidFromResponse(respItem), bidsMap, priceType, bidResponses); - }); - } - if (errorMessage) utils.logError(errorMessage); - return bidResponses; - }, - - getUserSyncs: function(syncOptions, serverResponses, gdprConsent) { - if (syncOptions.pixelEnabled) { - var query = []; - if (gdprConsent) { - if (gdprConsent.consentString) { - query.push('gdpr_consent=' + encodeURIComponent(gdprConsent.consentString)); - } - query.push('gdpr_applies=' + encodeURIComponent( - (typeof gdprConsent.gdprApplies === 'boolean') - ? Number(gdprConsent.gdprApplies) : 1)); - } - return [{ - type: 'image', - url: ADAPTER_SYNC_URL + (query.length ? '?' + query.join('&') : '') - }]; - } - } -} - -function _getBidFromResponse(respItem) { - if (!respItem) { - utils.logError(LOG_ERROR_MESS.emptySeatbid); - } else if (!respItem.bid) { - utils.logError(LOG_ERROR_MESS.hasNoArrayOfBids + JSON.stringify(respItem)); - } else if (!respItem.bid[0]) { - utils.logError(LOG_ERROR_MESS.noBid); - } - return respItem && respItem.bid && respItem.bid[0]; -} - -function _addBidResponse(serverBid, bidsMap, priceType, bidResponses) { - if (!serverBid) return; - let errorMessage; - if (!serverBid.auid) errorMessage = LOG_ERROR_MESS.noAuid + JSON.stringify(serverBid); - if (!serverBid.adm) errorMessage = LOG_ERROR_MESS.noAdm + JSON.stringify(serverBid); - else { - const awaitingBids = bidsMap[serverBid.auid]; - if (awaitingBids) { - awaitingBids.forEach(bid => { - const bidResponse = { - requestId: bid.bidId, // bid.bidderRequestId, - cpm: serverBid.price, - width: serverBid.w, - height: serverBid.h, - creativeId: serverBid.auid, // bid.bidId, - currency: 'USD', - netRevenue: priceType !== 'gross', - ttl: TIME_TO_LIVE, - ad: serverBid.adm, - dealId: serverBid.dealid - }; - bidResponses.push(bidResponse); - }); - } else { - errorMessage = LOG_ERROR_MESS.noPlacementCode + serverBid.auid; - } - } - if (errorMessage) { - utils.logError(errorMessage); - } -} - -registerBidder(spec); diff --git a/modules/datablocksBidAdapter.js b/modules/datablocksBidAdapter.js index 3e9bf219c756..cbad3ac910cd 100644 --- a/modules/datablocksBidAdapter.js +++ b/modules/datablocksBidAdapter.js @@ -232,7 +232,7 @@ export const spec = { Object.keys(sourceIds).forEach(sourceId => { let impObj = sourceIds[sourceId]; collection.push({ - url: `${impObj.protocol}${host}/${impObj.path}/?${impObj.idParam}=${sourceId}`, + url: `https://${host}/${impObj.path}/?${impObj.idParam}=${sourceId}`, body: { id: bidderRequest.auctionId, imp: impObj.imps, diff --git a/modules/decenteradsBidAdapter.js b/modules/decenteradsBidAdapter.js deleted file mode 100644 index 65d3032d3f87..000000000000 --- a/modules/decenteradsBidAdapter.js +++ /dev/null @@ -1,90 +0,0 @@ -import { registerBidder } from '../src/adapters/bidderFactory' -import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes' -import * as utils from '../src/utils' - -const BIDDER_CODE = 'decenterads' -const URL = '//supply.decenterads.com/?c=o&m=multi' -const URL_SYNC = '//supply.decenterads.com/?c=o&m=cookie' - -export const spec = { - code: BIDDER_CODE, - supportedMediaTypes: [BANNER, VIDEO, NATIVE], - - isBidRequestValid: function (opts) { - return Boolean(opts.bidId && opts.params && !isNaN(opts.params.placementId)) - }, - - buildRequests: function (validBidRequests) { - validBidRequests = validBidRequests || [] - let winTop = window - try { - window.top.location.toString() - winTop = window.top - } catch (e) { utils.logMessage(e) } - - const location = utils.getTopWindowLocation() - const placements = [] - - for (let i = 0; i < validBidRequests.length; i++) { - const p = validBidRequests[i] - - placements.push({ - placementId: p.params.placementId, - bidId: p.bidId, - traffic: p.params.traffic || BANNER - }) - } - - return { - method: 'POST', - url: URL, - data: { - deviceWidth: winTop.screen.width, - deviceHeight: winTop.screen.height, - language: (navigator && navigator.language) ? navigator.language : '', - secure: +(location.protocol === 'https:'), - host: location.host, - page: location.pathname, - placements: placements - } - } - }, - - interpretResponse: function (opts) { - const body = opts.body - const response = [] - - for (let i = 0; i < body.length; i++) { - const item = body[i] - if (isBidResponseValid(item)) { - delete item.mediaType - response.push(item) - } - } - - return response - }, - - getUserSyncs: function (syncOptions, serverResponses) { - return [{ type: 'image', url: URL_SYNC }] - } -} - -registerBidder(spec) - -function isBidResponseValid (bid) { - if (!bid.requestId || !bid.cpm || !bid.creativeId || - !bid.ttl || !bid.currency) { - return false - } - switch (bid['mediaType']) { - case BANNER: - return Boolean(bid.width && bid.height && bid.ad) - case VIDEO: - return Boolean(bid.vastUrl) - case NATIVE: - return Boolean(bid.title && bid.image && bid.impressionTrackers) - default: - return false - } -} diff --git a/modules/dgadsBidAdapter.js b/modules/dgadsBidAdapter.js deleted file mode 100644 index c8a97d86990f..000000000000 --- a/modules/dgadsBidAdapter.js +++ /dev/null @@ -1,103 +0,0 @@ -import {registerBidder} from '../src/adapters/bidderFactory'; -import * as utils from '../src/utils'; -import { BANNER, NATIVE } from '../src/mediaTypes'; - -const BIDDER_CODE = 'dgads'; -const UID_NAME = 'dgads_uid'; -const ENDPOINT = 'https://ads-tr.bigmining.com/ad/p/bid'; - -export const spec = { - code: BIDDER_CODE, - supportedMediaTypes: [ BANNER, NATIVE ], - isBidRequestValid: function(bid) { - const params = bid.params; - if (!/^\d+$/.test(params.location_id)) { - return false; - } - if (!/^\d+$/.test(params.site_id)) { - return false; - } - return true; - }, - buildRequests: function(bidRequests) { - if (bidRequests.length === 0) { - return {}; - } - - return bidRequests.map(bidRequest => { - const params = bidRequest.params; - const data = {}; - - data['_loc'] = params.location_id; - data['_medium'] = params.site_id; - data['transaction_id'] = bidRequest.transactionId; - data['bid_id'] = bidRequest.bidId; - data['referer'] = utils.getTopWindowUrl(); - data['_uid'] = getCookieUid(UID_NAME); - - return { - method: 'GET', - url: ENDPOINT, - data, - }; - }); - }, - interpretResponse: function(serverResponse, bidRequest) { - const bidResponses = []; - const responseObj = serverResponse.body; - const ads = responseObj.bids; - let bidResponse = {}; - if (utils.isEmpty(ads)) { - return []; - } - utils._each(ads, function(ad) { - bidResponse.requestId = ad.bidId; - bidResponse.bidderCode = BIDDER_CODE; - bidResponse.cpm = ad.cpm; - bidResponse.creativeId = ad.creativeId; - bidResponse.currency = 'JPY'; - bidResponse.netRevenue = true; - bidResponse.ttl = ad.ttl; - bidResponse.referrer = utils.getTopWindowUrl(); - if (ad.isNative == 1) { - bidResponse.mediaType = NATIVE; - bidResponse.native = setNativeResponse(ad); - } else { - bidResponse.width = parseInt(ad.w); - bidResponse.height = parseInt(ad.h); - bidResponse.ad = ad.ad; - } - bidResponses.push(bidResponse); - }); - return bidResponses; - } -}; -function setNativeResponse(ad) { - let nativeResponce = {}; - nativeResponce.image = { - url: ad.image, - width: parseInt(ad.w), - height: parseInt(ad.h) - } - nativeResponce.title = ad.title; - nativeResponce.body = ad.desc; - nativeResponce.sponsoredBy = ad.sponsoredBy; - nativeResponce.clickUrl = ad.clickUrl; - nativeResponce.clickTrackers = ad.clickTrackers || []; - nativeResponce.impressionTrackers = ad.impressionTrackers || []; - return nativeResponce; -} -export function getCookieUid(uidName) { - if (utils.cookiesAreEnabled()) { - let cookies = document.cookie.split(';'); - for (let i = 0; i < cookies.length; i++) { - let value = cookies[i].split('='); - if (value[0].indexOf(uidName) > -1) { - return value[1]; - } - } - } - return ''; -} - -registerBidder(spec); diff --git a/modules/djaxBidAdapter.js b/modules/djaxBidAdapter.js index 58f500d2a2b5..80975f0929a4 100644 --- a/modules/djaxBidAdapter.js +++ b/modules/djaxBidAdapter.js @@ -8,7 +8,7 @@ import {Renderer} from '../src/Renderer'; const SUPPORTED_AD_TYPES = [BANNER, VIDEO]; const BIDDER_CODE = 'djax'; const DOMAIN = 'https://demo.reviveadservermod.com/headerbidding_adminshare/'; -const RENDERER_URL = '//acdn.adnxs.com/video/outstream/ANOutstreamVideo.js'; +const RENDERER_URL = 'https://acdn.adnxs.com/video/outstream/ANOutstreamVideo.js'; function isBidRequestValid(bid) { return (typeof bid.params !== 'undefined' && parseInt(utils.getValue(bid.params, 'publisherId')) > 0); diff --git a/modules/dspxBidAdapter.js b/modules/dspxBidAdapter.js deleted file mode 100644 index a109bc612dbc..000000000000 --- a/modules/dspxBidAdapter.js +++ /dev/null @@ -1,96 +0,0 @@ -import * as utils from '../src/utils'; -import {config} from '../src/config'; -import {registerBidder} from '../src/adapters/bidderFactory'; - -const BIDDER_CODE = 'dspx'; -const ENDPOINT_URL = 'https://buyer.dspx.tv/request/'; - -export const spec = { - code: BIDDER_CODE, - aliases: ['dspx'], - isBidRequestValid: function(bid) { - return !!(bid.params.placement); - }, - buildRequests: function(validBidRequests, bidderRequest) { - return validBidRequests.map(bidRequest => { - const params = bidRequest.params; - const sizes = utils.parseSizesInput(bidRequest.sizes)[0]; - const width = sizes.split('x')[0]; - const height = sizes.split('x')[1]; - const placementId = params.placement; - - const rnd = Math.floor(Math.random() * 99999999999); - const referrer = bidderRequest.refererInfo.referer; - const bidId = bidRequest.bidId; - const payload = { - _f: 'html', - alternative: 'prebid_js', - inventory_item_id: placementId, - srw: width, - srh: height, - idt: 100, - rnd: rnd, - ref: referrer, - bid_id: bidId, - }; - if (params.pfilter !== undefined) { - payload.pfilter = params.pfilter; - } - if (params.bcat !== undefined) { - payload.bcat = params.bcat; - } - if (params.dvt !== undefined) { - payload.dvt = params.dvt; - } - return { - method: 'GET', - url: ENDPOINT_URL, - data: objectToQueryString(payload), - } - }); - }, - interpretResponse: function(serverResponse, bidRequest) { - const bidResponses = []; - const response = serverResponse.body; - const crid = response.crid || 0; - const cpm = response.cpm / 1000000 || 0; - if (cpm !== 0 && crid !== 0) { - const dealId = response.dealid || ''; - const currency = response.currency || 'EUR'; - const netRevenue = (response.netRevenue === undefined) ? true : response.netRevenue; - const referrer = utils.getTopWindowUrl(); - const bidResponse = { - requestId: response.bid_id, - cpm: cpm, - width: response.width, - height: response.height, - creativeId: crid, - dealId: dealId, - currency: currency, - netRevenue: netRevenue, - ttl: config.getConfig('_bidderTimeout'), - referrer: referrer, - ad: response.adTag - }; - bidResponses.push(bidResponse); - } - return bidResponses; - } -} - -function objectToQueryString(obj, prefix) { - let str = []; - let p; - for (p in obj) { - if (obj.hasOwnProperty(p)) { - let k = prefix ? prefix + '[' + p + ']' : p; - let v = obj[p]; - str.push((v !== null && typeof v === 'object') - ? objectToQueryString(v, k) - : encodeURIComponent(k) + '=' + encodeURIComponent(v)); - } - } - return str.join('&'); -} - -registerBidder(spec); diff --git a/modules/ebdrBidAdapter.js b/modules/ebdrBidAdapter.js index 79bf4bb10047..d8af215f96a9 100644 --- a/modules/ebdrBidAdapter.js +++ b/modules/ebdrBidAdapter.js @@ -57,7 +57,7 @@ export const spec = { }; return { method: 'GET', - url: '//' + rtbServerDomain + '/hb?' + '&zoneid=' + zoneid + '&br=' + encodeURIComponent(JSON.stringify(ebdrBidReq)), + url: 'https://' + rtbServerDomain + '/hb?' + '&zoneid=' + zoneid + '&br=' + encodeURIComponent(JSON.stringify(ebdrBidReq)), bids: ebdrReq }; }, diff --git a/modules/emx_digitalBidAdapter.js b/modules/emx_digitalBidAdapter.js deleted file mode 100644 index 0768c8386fb0..000000000000 --- a/modules/emx_digitalBidAdapter.js +++ /dev/null @@ -1,287 +0,0 @@ -import * as utils from '../src/utils'; -import { registerBidder } from '../src/adapters/bidderFactory'; -import { BANNER, VIDEO } from '../src/mediaTypes'; -import { Renderer } from '../src/Renderer'; -import includes from 'core-js/library/fn/array/includes'; - -const BIDDER_CODE = 'emx_digital'; -const ENDPOINT = 'hb.emxdgt.com'; -const RENDERER_URL = '//js.brealtime.com/outstream/1.30.0/bundle.js'; -const ADAPTER_VERSION = '1.41.2'; -const DEFAULT_CUR = 'USD'; - -export const emxAdapter = { - validateSizes: (sizes) => { - if (!utils.isArray(sizes) || typeof sizes[0] === 'undefined') { - utils.logWarn(BIDDER_CODE + ': Sizes should be an array'); - return false; - } - return sizes.every(size => utils.isArray(size) && size.length === 2); - }, - checkVideoContext: (bid) => { - return ((bid && bid.mediaTypes && bid.mediaTypes.video && bid.mediaTypes.video.context) && ((bid.mediaTypes.video.context === 'instream') || (bid.mediaTypes.video.context === 'outstream'))); - }, - buildBanner: (bid) => { - let sizes = []; - bid.mediaTypes && bid.mediaTypes.banner && bid.mediaTypes.banner.sizes ? sizes = bid.mediaTypes.banner.sizes : sizes = bid.sizes; - if (!emxAdapter.validateSizes(sizes)) { - utils.logWarn(BIDDER_CODE + ': could not detect mediaType banner sizes. Assigning to bid sizes instead'); - sizes = bid.sizes - } - return { - format: sizes.map((size) => { - return { - w: size[0], - h: size[1] - }; - }), - w: sizes[0][0], - h: sizes[0][1] - }; - }, - formatVideoResponse: (bidResponse, emxBid, bidRequest) => { - bidResponse.vastXml = emxBid.adm; - if (bidRequest.bidRequest && bidRequest.bidRequest.mediaTypes && bidRequest.bidRequest.mediaTypes.video && bidRequest.bidRequest.mediaTypes.video.context === 'outstream') { - bidResponse.renderer = emxAdapter.createRenderer(bidResponse, { - id: emxBid.id, - url: RENDERER_URL - }); - } - return bidResponse; - }, - isMobile: () => { - return (/(ios|ipod|ipad|iphone|android)/i).test(navigator.userAgent); - }, - isConnectedTV: () => { - return (/(smart[-]?tv|hbbtv|appletv|googletv|hdmi|netcast\.tv|viera|nettv|roku|\bdtv\b|sonydtv|inettvbrowser|\btv\b)/i).test(navigator.userAgent); - }, - getDevice: () => { - return { - ua: navigator.userAgent, - js: 1, - dnt: (navigator.doNotTrack === 'yes' || navigator.doNotTrack === '1' || navigator.msDoNotTrack === '1') ? 1 : 0, - h: screen.height, - w: screen.width, - devicetype: emxAdapter.isMobile() ? 1 : emxAdapter.isConnectedTV() ? 3 : 2, - language: (navigator.language || navigator.browserLanguage || navigator.userLanguage || navigator.systemLanguage), - }; - }, - cleanProtocols: (video) => { - if (video.protocols && includes(video.protocols, 7)) { - // not supporting VAST protocol 7 (VAST 4.0); - utils.logWarn(BIDDER_CODE + ': VAST 4.0 is currently not supported. This protocol has been filtered out of the request.'); - video.protocols = video.protocols.filter(protocol => protocol !== 7); - } - return video; - }, - outstreamRender: (bid) => { - bid.renderer.push(function () { - let params = (bid && bid.params && bid.params[0] && bid.params[0].video) ? bid.params[0].video : {}; - window.emxVideoQueue = window.emxVideoQueue || []; - window.queueEmxVideo({ - id: bid.adUnitCode, - adsResponses: bid.vastXml, - options: params - }); - if (window.emxVideoReady && window.videojs) { - window.emxVideoReady(); - } - }); - }, - createRenderer: (bid, rendererParams) => { - const renderer = Renderer.install({ - id: rendererParams.id, - url: RENDERER_URL, - loaded: false - }); - try { - renderer.setRender(emxAdapter.outstreamRender); - } catch (err) { - utils.logWarn('Prebid Error calling setRender on renderer', err); - } - - return renderer; - }, - buildVideo: (bid) => { - let videoObj = Object.assign(bid.mediaTypes.video, bid.params.video); - - if (utils.isArray(bid.mediaTypes.video.playerSize[0])) { - videoObj['w'] = bid.mediaTypes.video.playerSize[0][0]; - videoObj['h'] = bid.mediaTypes.video.playerSize[0][1]; - } else { - videoObj['w'] = bid.mediaTypes.video.playerSize[0]; - videoObj['h'] = bid.mediaTypes.video.playerSize[1]; - } - return emxAdapter.cleanProtocols(videoObj); - }, - parseResponse: (bidResponseAdm) => { - try { - return decodeURIComponent(bidResponseAdm.replace(/%(?![0-9][0-9a-fA-F]+)/g, '%25')); - } catch (err) { - utils.logError('emx_digitalBidAdapter', 'error', err); - } - }, - getReferrer: () => { - try { - return window.top.document.referrer; - } catch (err) { - return document.referrer; - } - }, - getGdpr: (bidRequests, emxData) => { - if (bidRequests.gdprConsent) { - emxData.regs = { - ext: { - gdpr: bidRequests.gdprConsent.gdprApplies === true ? 1 : 0 - } - }; - } - if (bidRequests.gdprConsent && bidRequests.gdprConsent.gdprApplies) { - emxData.user = { - ext: { - consent: bidRequests.gdprConsent.consentString - } - }; - } - - return emxData; - } -}; - -export const spec = { - code: BIDDER_CODE, - supportedMediaTypes: [BANNER, VIDEO], - isBidRequestValid: function (bid) { - if (!bid || !bid.params) { - utils.logWarn(BIDDER_CODE + ': Missing bid or bid params.'); - return false; - } - - if (bid.bidder !== BIDDER_CODE) { - utils.logWarn(BIDDER_CODE + ': Must use "emx_digital" as bidder code.'); - return false; - } - - if (!bid.params.tagid || !utils.isStr(bid.params.tagid)) { - utils.logWarn(BIDDER_CODE + ': Missing tagid param or tagid present and not type String.'); - return false; - } - - if (bid.mediaTypes && bid.mediaTypes.banner) { - let sizes; - bid.mediaTypes.banner.sizes ? sizes = bid.mediaTypes.banner.sizes : sizes = bid.sizes; - if (!emxAdapter.validateSizes(sizes)) { - utils.logWarn(BIDDER_CODE + ': Missing sizes in bid'); - return false; - } - } else if (bid.mediaTypes && bid.mediaTypes.video) { - if (!emxAdapter.checkVideoContext(bid)) { - utils.logWarn(BIDDER_CODE + ': Missing video context: instream or outstream'); - return false; - } - - if (!bid.mediaTypes.video.playerSize) { - utils.logWarn(BIDDER_CODE + ': Missing video playerSize'); - return false; - } - } - - return true; - }, - buildRequests: function (validBidRequests, bidRequest) { - const emxImps = []; - const timeout = bidRequest.timeout || ''; - const timestamp = Date.now(); - const url = location.protocol + '//' + ENDPOINT + ('?t=' + timeout + '&ts=' + timestamp + '&src=pbjs'); - const secure = location.protocol.indexOf('https') > -1 ? 1 : 0; - const domain = utils.getTopWindowLocation().hostname; - const page = bidRequest.refererInfo.referer; - const device = emxAdapter.getDevice(); - const ref = emxAdapter.getReferrer(); - - utils._each(validBidRequests, function (bid) { - let tagid = utils.getBidIdParameter('tagid', bid.params); - let bidfloor = parseFloat(utils.getBidIdParameter('bidfloor', bid.params)) || 0; - let isVideo = !!bid.mediaTypes.video; - let data = { - id: bid.bidId, - tid: bid.transactionId, - tagid, - secure - }; - let typeSpecifics = isVideo ? { video: emxAdapter.buildVideo(bid) } : { banner: emxAdapter.buildBanner(bid) }; - let bidfloorObj = bidfloor > 0 ? { bidfloor, bidfloorcur: DEFAULT_CUR } : {}; - let emxBid = Object.assign(data, typeSpecifics, bidfloorObj); - - emxImps.push(emxBid); - }); - - let emxData = { - id: bidRequest.auctionId, - imp: emxImps, - device, - site: { - domain, - page, - ref - }, - cur: DEFAULT_CUR, - version: ADAPTER_VERSION - }; - - emxData = emxAdapter.getGdpr(bidRequest, Object.assign({}, emxData)); - if (bidRequest && bidRequest.uspConsent) { - emxData.us_privacy = bidRequest.uspConsent - } - return { - method: 'POST', - url: url, - data: JSON.stringify(emxData), - options: { - withCredentials: true - }, - bidRequest - }; - }, - interpretResponse: function (serverResponse, bidRequest) { - let emxBidResponses = []; - let response = serverResponse.body || {}; - if (response.seatbid && response.seatbid.length > 0 && response.seatbid[0].bid) { - response.seatbid.forEach(function (emxBid) { - emxBid = emxBid.bid[0]; - let isVideo = false; - let adm = emxAdapter.parseResponse(emxBid.adm) || ''; - let bidResponse = { - requestId: emxBid.id, - cpm: emxBid.price, - width: emxBid.w, - height: emxBid.h, - creativeId: emxBid.crid || emxBid.id, - dealId: emxBid.dealid || null, - currency: 'USD', - netRevenue: true, - ttl: emxBid.ttl, - ad: adm - }; - if (emxBid.adm && emxBid.adm.indexOf(' -1) { - isVideo = true; - bidResponse = emxAdapter.formatVideoResponse(bidResponse, Object.assign({}, emxBid), bidRequest); - } - bidResponse.mediaType = (isVideo ? VIDEO : BANNER); - emxBidResponses.push(bidResponse); - }); - } - return emxBidResponses; - }, - getUserSyncs: function (syncOptions) { - const syncs = []; - if (syncOptions.iframeEnabled) { - syncs.push({ - type: 'iframe', - url: '//biddr.brealtime.com/check.html' - }); - } - return syncs; - } -}; -registerBidder(spec); diff --git a/modules/eplanningBidAdapter.js b/modules/eplanningBidAdapter.js deleted file mode 100644 index d9e145544836..000000000000 --- a/modules/eplanningBidAdapter.js +++ /dev/null @@ -1,395 +0,0 @@ -import * as utils from '../src/utils'; -import { registerBidder } from '../src/adapters/bidderFactory'; - -const BIDDER_CODE = 'eplanning'; -const rnd = Math.random(); -const DEFAULT_SV = 'ads.us.e-planning.net'; -const DEFAULT_ISV = 'i.e-planning.net'; -const PARAMS = ['ci', 'sv', 't']; -const DOLLARS = 'USD'; -const NET_REVENUE = true; -const TTL = 120; -const NULL_SIZE = '1x1'; -const FILE = 'file'; -const STORAGE_RENDER_PREFIX = 'pbsr_'; -const STORAGE_VIEW_PREFIX = 'pbvi_'; - -export const spec = { - code: BIDDER_CODE, - - isBidRequestValid: function(bid) { - return Boolean(bid.params.ci) || Boolean(bid.params.t); - }, - - buildRequests: function(bidRequests) { - const method = 'GET'; - const dfpClientId = '1'; - const sec = 'ROS'; - let url; - let params; - const urlConfig = getUrlConfig(bidRequests); - const pcrs = getCharset(); - const spaces = getSpaces(bidRequests); - if (urlConfig.t) { - url = urlConfig.isv + '/layers/t_pbjs_2.json'; - params = {}; - } else { - url = '//' + (urlConfig.sv || DEFAULT_SV) + '/hb/1/' + urlConfig.ci + '/' + dfpClientId + '/' + (utils.getTopWindowLocation().hostname || FILE) + '/' + sec; - const referrerUrl = utils.getTopWindowReferrer(); - - if (utils.hasLocalStorage()) { - registerViewabilityAllBids(bidRequests); - } - - params = { - rnd: rnd, - e: spaces.str, - ur: utils.getTopWindowUrl() || FILE, - r: 'pbjs', - pbv: '$prebid.version$', - ncb: '1', - vs: spaces.vs - }; - - if (pcrs) { - params.crs = pcrs; - } - - if (referrerUrl) { - params.fr = referrerUrl; - } - } - - return { - method: method, - url: url, - data: params, - adUnitToBidId: spaces.map, - }; - }, - interpretResponse: function(serverResponse, request) { - const response = serverResponse.body; - let bidResponses = []; - - if (response && !utils.isEmpty(response.sp)) { - response.sp.forEach(space => { - if (!utils.isEmpty(space.a)) { - space.a.forEach(ad => { - const bidResponse = { - requestId: request.adUnitToBidId[space.k], - cpm: ad.pr, - width: ad.w, - height: ad.h, - ad: ad.adm, - ttl: TTL, - creativeId: ad.crid, - netRevenue: NET_REVENUE, - currency: DOLLARS, - }; - bidResponses.push(bidResponse); - }); - } - }); - } - - return bidResponses; - }, - getUserSyncs: function(syncOptions, serverResponses) { - const syncs = []; - const response = !utils.isEmpty(serverResponses) && serverResponses[0].body; - - if (response && !utils.isEmpty(response.cs)) { - const responseSyncs = response.cs; - responseSyncs.forEach(sync => { - if (typeof sync === 'string' && syncOptions.pixelEnabled) { - syncs.push({ - type: 'image', - url: sync, - }); - } else if (typeof sync === 'object' && sync.ifr && syncOptions.iframeEnabled) { - syncs.push({ - type: 'iframe', - url: sync.u, - }) - } - }); - } - - return syncs; - }, -} - -function getUrlConfig(bidRequests) { - if (isTestRequest(bidRequests)) { - return getTestConfig(bidRequests.filter(br => br.params.t)); - } - - let config = {}; - bidRequests.forEach(bid => { - PARAMS.forEach(param => { - if (bid.params[param] && !config[param]) { - config[param] = bid.params[param]; - } - }); - }); - - if (config.sv) { - config.sv = '//' + config.sv; - } - - return config; -} -function isTestRequest(bidRequests) { - for (let i = 0; i < bidRequests.length; i++) { - if (bidRequests[i].params.t) { - return true; - } - } - return false; -} -function getTestConfig(bidRequests) { - let isv; - bidRequests.forEach(br => isv = isv || br.params.isv); - return { - t: true, - isv: '//' + (isv || DEFAULT_ISV) - }; -} - -function getSize(bid, first) { - return bid.sizes && bid.sizes.length ? utils.parseSizesInput(first ? bid.sizes[0] : bid.sizes).join(',') : NULL_SIZE; -} - -function getSpacesStruct(bids) { - let e = {}; - bids.forEach(bid => { - let size = getSize(bid, true); - e[size] = e[size] ? e[size] : []; - e[size].push(bid); - }); - - return e; -} - -function getSpaces(bidRequests) { - let spacesStruct = getSpacesStruct(bidRequests); - let es = {str: '', vs: '', map: {}}; - es.str = Object.keys(spacesStruct).map(size => spacesStruct[size].map((bid, i) => { - es.vs += getVs(bid); - let name = getSize(bid, true) + '_' + i; - es.map[name] = bid.bidId; - return name + ':' + getSize(bid); - }).join('+')).join('+'); - return es; -} - -function getVs(bid) { - let s; - let vs = ''; - if (utils.hasLocalStorage()) { - s = getViewabilityData(bid); - vs += s.render >= 4 ? s.ratio.toString(16) : 'F'; - } else { - vs += 'F'; - } - return vs; -} - -function getViewabilityData(bid) { - let r = utils.getDataFromLocalStorage(STORAGE_RENDER_PREFIX + bid.adUnitCode) || 0; - let v = utils.getDataFromLocalStorage(STORAGE_VIEW_PREFIX + bid.adUnitCode) || 0; - let ratio = r > 0 ? (v / r) : 0; - return { - render: r, - ratio: window.parseInt(ratio * 10, 10) - }; -} -function getCharset() { - try { - return window.top.document.charset || window.top.document.characterSet; - } catch (e) { - return document.charset || document.characterSet; - } -} - -function waitForElementsPresent(elements) { - const observer = new MutationObserver(function (mutationList, observer) { - if (mutationList && Array.isArray(mutationList)) { - mutationList.forEach(mr => { - if (mr && mr.addedNodes && Array.isArray(mr.addedNodes)) { - mr.addedNodes.forEach(ad => { - let index = elements.indexOf(ad.id); - if (index >= 0) { - registerViewability(ad); - elements.splice(index, 1); - if (!elements.length) { - observer.disconnect(); - } - } - }); - } - }); - } - }); - const config = {childList: true, subtree: true, characterData: true, attributes: true, attributeOldValue: true}; - observer.observe(document.body, config); -} - -function registerViewability(div) { - visibilityHandler({ - name: div.id, - div: div - }); -} - -function registerViewabilityAllBids(bids) { - let elementsNotPresent = []; - bids.forEach(bid => { - let div = document.getElementById(bid.adUnitCode); - if (div) { - registerViewability(div); - } else { - elementsNotPresent.push(bid.adUnitCode); - } - }); - if (elementsNotPresent.length) { - waitForElementsPresent(elementsNotPresent); - } -} - -function getViewabilityTracker() { - let TIME_PARTITIONS = 5; - let VIEWABILITY_TIME = 1000; - let VIEWABILITY_MIN_RATIO = 0.5; - let publicApi; - let context; - - function segmentIsOutsideTheVisibleRange(visibleRangeEnd, p1, p2) { - return p1 > visibleRangeEnd || p2 < 0; - } - - function segmentBeginsBeforeTheVisibleRange(p1) { - return p1 < 0; - } - - function segmentEndsAfterTheVisibleRange(visibleRangeEnd, p2) { - return p2 < visibleRangeEnd; - } - - function axialVisibilityRatio(visibleRangeEnd, p1, p2) { - let visibilityRatio = 0; - if (!segmentIsOutsideTheVisibleRange(visibleRangeEnd, p1, p2)) { - if (segmentBeginsBeforeTheVisibleRange(p1)) { - visibilityRatio = p2 / (p2 - p1); - } else { - visibilityRatio = segmentEndsAfterTheVisibleRange(visibleRangeEnd, p2) ? 1 : (visibleRangeEnd - p1) / (p2 - p1); - } - } - return visibilityRatio; - } - - function isNotHiddenByNonFriendlyIframe() { - return (window === window.top) || window.frameElement; - } - - function defineContext(e) { - context = e && window.document.body.contains(e) ? window : (window.top.document.body.contains(e) ? top : undefined); - return context; - } - - function getContext(e) { - return context; - } - - function verticalVisibilityRatio(position) { - return axialVisibilityRatio(getContext().innerHeight, position.top, position.bottom); - } - - function horizontalVisibilityRatio(position) { - return axialVisibilityRatio(getContext().innerWidth, position.left, position.right); - } - - function itIsNotHiddenByBannerAreaPosition(e) { - let position = e.getBoundingClientRect(); - return (verticalVisibilityRatio(position) * horizontalVisibilityRatio(position)) > VIEWABILITY_MIN_RATIO; - } - - function itIsNotHiddenByDisplayStyleCascade(e) { - return e.offsetHeight > 0 && e.offsetWidth > 0; - } - - function itIsNotHiddenByOpacityStyleCascade(e) { - let s = e.style; - let p = e.parentNode; - return !(s && parseFloat(s.opacity) === 0) && (!p || itIsNotHiddenByOpacityStyleCascade(p)); - } - - function itIsNotHiddenByVisibilityStyleCascade(e) { - return getContext().getComputedStyle(e).visibility !== 'hidden'; - } - - function itIsNotHiddenByTabFocus() { - return getContext().top.document.hasFocus(); - } - - function isDefined(e) { - return (e !== null) && (typeof e !== 'undefined'); - } - - function itIsNotHiddenByOrphanBranch() { - return isDefined(getContext()); - } - - function isContextInAnIframe() { - return isDefined(getContext().frameElement); - } - - function processIntervalVisibilityStatus(elapsedVisibleIntervals, element, callback) { - let visibleIntervals = isVisible(element) ? (elapsedVisibleIntervals + 1) : 0; - if (visibleIntervals === TIME_PARTITIONS) { - callback(); - } else { - setTimeout(processIntervalVisibilityStatus.bind(this, visibleIntervals, element, callback), VIEWABILITY_TIME / TIME_PARTITIONS); - } - } - - function isVisible(element) { - defineContext(element); - return isNotHiddenByNonFriendlyIframe() && - itIsNotHiddenByOrphanBranch() && - itIsNotHiddenByTabFocus() && - itIsNotHiddenByDisplayStyleCascade(element) && - itIsNotHiddenByVisibilityStyleCascade(element) && - itIsNotHiddenByOpacityStyleCascade(element) && - itIsNotHiddenByBannerAreaPosition(element) && - (!isContextInAnIframe() || isVisible(getContext().frameElement)); - } - - publicApi = { - isVisible: isVisible, - onView: processIntervalVisibilityStatus.bind(this, 0) - }; - - return publicApi; -}; - -function visibilityHandler(obj) { - if (obj.div) { - registerAuction(STORAGE_RENDER_PREFIX + obj.name); - getViewabilityTracker().onView(obj.div, registerAuction.bind(undefined, STORAGE_VIEW_PREFIX + obj.name)); - } -} - -function registerAuction(storageID) { - let value; - try { - value = utils.getDataFromLocalStorage(storageID); - value = value ? window.parseInt(value, 10) + 1 : 1; - utils.setDataInLocalStorage(storageID, value); - } catch (exc) { - return false; - } - - return true; -} -registerBidder(spec); diff --git a/modules/etargetBidAdapter.js b/modules/etargetBidAdapter.js index bdf07742497c..ad341a136b1a 100644 --- a/modules/etargetBidAdapter.js +++ b/modules/etargetBidAdapter.js @@ -39,7 +39,7 @@ export const spec = { request.push(formRequestUrl(reqParams)); } - request.unshift('//' + lastCountry + '.search.etargetnet.com/hb/?hbget=1'); + request.unshift('https://' + lastCountry + '.search.etargetnet.com/hb/?hbget=1'); netRevenue = 'net'; if (bidderRequest && bidderRequest.gdprConsent && bidderRequest.gdprConsent.gdprApplies) { diff --git a/modules/eywamediaBidAdapter.js b/modules/eywamediaBidAdapter.js deleted file mode 100644 index 543775dc3aab..000000000000 --- a/modules/eywamediaBidAdapter.js +++ /dev/null @@ -1,181 +0,0 @@ -import * as utils from '../src/utils'; -import { registerBidder } from '../src/adapters/bidderFactory'; - -const BIDDER_CODE = 'eywamedia'; -const CURRENCY = 'USD'; -const VERSION = '1.0.0'; -const TIME_TO_LIVE = 360; -const NET_REVENUE = true; -const COOKIE_NAME = 'emaduuid'; -const UUID_LEN = 36; -const SERVER_ENDPOINT = 'https://adtarbostg.eywamedia.com/auctions/prebidjs/3000'; -const localWindow = getTopWindow(); - -export const spec = { - code: BIDDER_CODE, - supportedMediaTypes: ['banner'], - /** - * Determines whether or not the given bid request is valid. - * @param {object} bid, bid to validate - * @return boolean, true if valid, otherwise false - */ - isBidRequestValid: function(bid) { - return !!(bid.params.publisherId); - }, - /** - * Make a server request from the list of BidRequests. - * - * @param {BidRequest[]} bidRequests A non-empty list of bid requests which should be sent to the Server. - * @return requestPayload Info describing the request to the server. - */ - buildRequests: function(bidRequests, bidRequest) { - const device = getDeviceInfo(); - const site = getSiteInfo(); - const user = getUserInfo(); - - let requestPayload = { - id: utils.generateUUID(), - publisherId: bidRequests[0].params.publisherId, - device: device, - site: site, - user: user, - bidPayload: bidRequests, - cacheBust: new Date().getTime().toString(), - adapterVersion: VERSION, - tmax: bidRequest.timeout - }; - - return { - method: 'POST', - url: SERVER_ENDPOINT, - options: { - contentType: 'application/json' - }, - data: requestPayload - } - }, - - /** - * Makes Eywamedia Ad Server response compatible to Prebid specs - * @param serverResponse successful response from Ad Server - * @param bidderRequest original bidRequest - * @return {Bid[]} an array of bids - */ - interpretResponse: function (serverResponse, bidRequest) { - var bidObject, response; - var bidRespones = []; - var responses = serverResponse.body; - for (var i = 0; i < responses.length; i++) { - response = responses[i]; - bidObject = { - requestId: response.bidId, - cpm: response.cpm, - width: parseInt(response.width), - height: parseInt(response.height), - creativeId: response.bidId, - currency: CURRENCY, - netRevenue: NET_REVENUE, - ttl: TIME_TO_LIVE, - ad: response.ad, - bidderCode: BIDDER_CODE, - transactionId: response.transactionId, - mediaType: response.respType, - }; - bidRespones.push(bidObject); - } - return bidRespones; - } -} -registerBidder(spec); - -/*************************************** - * Helper Functions - ***************************************/ - -/** - * get device type - */ -function getDeviceType() { - let ua = navigator.userAgent; - // Tablets must be checked before phones. - if ((/(tablet|ipad|playbook|silk)|(android(?!.*mobi))/i).test(ua)) { - return 5; // "Tablet" - } - if ((/Mobile|iP(hone|od|ad)|Android|BlackBerry|IEMobile|Kindle|NetFront|Silk-Accelerated|(hpw|web)OS|Fennec|Minimo|Opera M(obi|ini)|Blazer|Dolfin|Dolphin|Skyfire|Zune/).test(ua)) { - return 4; // "Phone" - } - return 2; // Personal Computers -}; - -/** - * get device info - */ -function getDeviceInfo() { - const language = navigator.language; - return { - ua: navigator.userAgent, - language: navigator[language], - devicetype: getDeviceType(), - dnt: utils.getDNT(), - geo: {}, - js: 1 - }; -}; - -/** - * get site info - */ -function getSiteInfo() { - const topLocation = utils.getTopWindowLocation(); - return { - domain: topLocation.hostname, - page: topLocation.href, - referrer: utils.getTopWindowReferrer(), - desc: getPageDescription(), - title: localWindow.document.title, - }; -}; - -/** - * get user info - */ -function getUserInfo() { - return { - id: getUserID(), - }; -}; - -/** - * get user Id - */ -const getUserID = () => { - const i = document.cookie.indexOf(COOKIE_NAME); - - if (i === -1) { - const uuid = utils.generateUUID(); - document.cookie = `${COOKIE_NAME}=${uuid}; path=/`; - return uuid; - } - - const j = i + COOKIE_NAME.length + 1; - return document.cookie.substring(j, j + UUID_LEN); -}; - -/** - * get page description - */ -function getPageDescription() { - if (document.querySelector('meta[name="description"]')) { - return document.querySelector('meta[name="description"]').getAttribute('content'); // Value of the description metadata from the publisher's page. - } else { - return ''; - } -}; - -function getTopWindow() { - try { - return window.top; - } catch (e) { - return window; - } -}; diff --git a/modules/fairtradeBidAdapter.js b/modules/fairtradeBidAdapter.js deleted file mode 100644 index 55f24ab89068..000000000000 --- a/modules/fairtradeBidAdapter.js +++ /dev/null @@ -1,150 +0,0 @@ -import * as utils from '../src/utils'; -import {registerBidder} from '../src/adapters/bidderFactory'; -const BIDDER_CODE = 'fairtrade'; -const ENDPOINT_URL = '//pool.fair-trademedia.com/hb'; -const TIME_TO_LIVE = 360; -const ADAPTER_SYNC_URL = '//pool.fair-trademedia.com/push_sync'; -const LOG_ERROR_MESS = { - noAuid: 'Bid from response has no auid parameter - ', - noAdm: 'Bid from response has no adm parameter - ', - noBid: 'Array of bid objects is empty', - noPlacementCode: 'Can\'t find in requested bids the bid with auid - ', - emptyUids: 'Uids should be not empty', - emptySeatbid: 'Seatbid array from response has empty item', - emptyResponse: 'Response is empty', - hasEmptySeatbidArray: 'Response has empty seatbid array', - hasNoArrayOfBids: 'Seatbid from response has no array of bid objects - ' -}; -export const spec = { - code: BIDDER_CODE, - /** - * Determines whether or not the given bid request is valid. - * - * @param {BidRequest} bid The bid params to validate. - * @return boolean True if this is a valid bid, and false otherwise. - */ - isBidRequestValid: function(bid) { - return !!bid.params.uid; - }, - /** - * Make a server request from the list of BidRequests. - * - * @param {BidRequest[]} validBidRequests - an array of bids - * @return ServerRequest Info describing the request to the server. - */ - buildRequests: function(validBidRequests) { - const auids = []; - const bidsMap = {}; - const bids = validBidRequests || []; - let priceType = 'net'; - let reqId; - - bids.forEach(bid => { - if (bid.params.priceType === 'gross') { - priceType = 'gross'; - } - reqId = bid.bidderRequestId; - if (!bidsMap[bid.params.uid]) { - bidsMap[bid.params.uid] = [bid]; - auids.push(bid.params.uid); - } else { - bidsMap[bid.params.uid].push(bid); - } - }); - - const payload = { - u: utils.getTopWindowUrl(), - pt: priceType, - auids: auids.join(','), - r: reqId - }; - - return { - method: 'GET', - url: ENDPOINT_URL, - data: payload, - bidsMap: bidsMap, - }; - }, - /** - * Unpack the response from the server into a list of bids. - * - * @param {*} serverResponse A successful response from the server. - * @param {*} bidRequest - * @return {Bid[]} An array of bids which were nested inside the server. - */ - interpretResponse: function(serverResponse, bidRequest) { - serverResponse = serverResponse && serverResponse.body - const bidResponses = []; - const bidsMap = bidRequest.bidsMap; - const priceType = bidRequest.data.pt; - - let errorMessage; - - if (!serverResponse) errorMessage = LOG_ERROR_MESS.emptyResponse; - else if (serverResponse.seatbid && !serverResponse.seatbid.length) { - errorMessage = LOG_ERROR_MESS.hasEmptySeatbidArray; - } - - if (!errorMessage && serverResponse.seatbid) { - serverResponse.seatbid.forEach(respItem => { - _addBidResponse(_getBidFromResponse(respItem), bidsMap, priceType, bidResponses); - }); - } - if (errorMessage) utils.logError(errorMessage); - return bidResponses; - }, - getUserSyncs: function(syncOptions) { - if (syncOptions.pixelEnabled) { - return [{ - type: 'image', - url: ADAPTER_SYNC_URL - }]; - } - } -} - -function _getBidFromResponse(respItem) { - if (!respItem) { - utils.logError(LOG_ERROR_MESS.emptySeatbid); - } else if (!respItem.bid) { - utils.logError(LOG_ERROR_MESS.hasNoArrayOfBids + JSON.stringify(respItem)); - } else if (!respItem.bid[0]) { - utils.logError(LOG_ERROR_MESS.noBid); - } - return respItem && respItem.bid && respItem.bid[0]; -} - -function _addBidResponse(serverBid, bidsMap, priceType, bidResponses) { - if (!serverBid) return; - let errorMessage; - if (!serverBid.auid) errorMessage = LOG_ERROR_MESS.noAuid + JSON.stringify(serverBid); - if (!serverBid.adm) errorMessage = LOG_ERROR_MESS.noAdm + JSON.stringify(serverBid); - else { - const awaitingBids = bidsMap[serverBid.auid]; - if (awaitingBids) { - awaitingBids.forEach(bid => { - const bidResponse = { - requestId: bid.bidId, // bid.bidderRequestId, - cpm: serverBid.price, - width: serverBid.w, - height: serverBid.h, - creativeId: serverBid.auid, // bid.bidId, - currency: 'USD', - netRevenue: priceType !== 'gross', - ttl: TIME_TO_LIVE, - ad: serverBid.adm, - dealId: serverBid.dealid - }; - bidResponses.push(bidResponse); - }); - } else { - errorMessage = LOG_ERROR_MESS.noPlacementCode + serverBid.auid; - } - } - if (errorMessage) { - utils.logError(errorMessage); - } -} - -registerBidder(spec); diff --git a/modules/fidelityBidAdapter.js b/modules/fidelityBidAdapter.js deleted file mode 100644 index 078e9d2fcce3..000000000000 --- a/modules/fidelityBidAdapter.js +++ /dev/null @@ -1,109 +0,0 @@ -import * as utils from '../src/utils'; -import {registerBidder} from '../src/adapters/bidderFactory'; - -const BIDDER_CODE = 'fidelity'; -const BIDDER_SERVER = 'x.fidelity-media.com'; -const FIDELITY_VENDOR_ID = 408; -export const spec = { - code: BIDDER_CODE, - isBidRequestValid: function(bid) { - return !!(bid && bid.params && bid.params.zoneid); - }, - buildRequests: function(validBidRequests, bidderRequest) { - return validBidRequests.map(bidRequest => { - var server = bidRequest.params.server || BIDDER_SERVER; - - const payload = { - from: 'hb', - v: '1.0', - requestid: bidRequest.bidderRequestId, - impid: bidRequest.bidId, - zoneid: bidRequest.params.zoneid, - floor: parseFloat(bidRequest.params.floor) > 0 ? bidRequest.params.floor : 0, - charset: document.charSet || document.characterSet, - subid: 'hb', - flashver: getFlashVersion(), - tmax: bidderRequest.timeout, - defloc: utils.getTopWindowUrl(), - referrer: utils.getTopWindowReferrer(), - }; - setConsentParams(bidderRequest.gdprConsent, payload); - - return { - method: 'GET', - url: '//' + server + '/delivery/hb.php', - data: payload - }; - }); - }, - interpretResponse: function(serverResponse) { - serverResponse = serverResponse.body; - const bidResponses = []; - if (serverResponse && serverResponse.seatbid) { - serverResponse.seatbid.forEach(seatBid => seatBid.bid.forEach(bid => { - const bidResponse = { - requestId: bid.impid, - creativeId: bid.impid, - cpm: bid.price, - width: bid.width, - height: bid.height, - ad: bid.adm, - netRevenue: bid.netRevenue, - currency: bid.cur, - ttl: bid.ttl, - }; - - bidResponses.push(bidResponse); - })); - } - return bidResponses; - }, - getUserSyncs: function getUserSyncs(syncOptions, serverResponses, gdprConsent) { - if (syncOptions.iframeEnabled) { - var url = '//' + BIDDER_SERVER + '/delivery/matches.php'; - var payload = { - type: 'iframe' - }; - setConsentParams(gdprConsent, payload); - - return [{ - type: 'iframe', - url: url + '?' + utils.parseQueryStringParameters(payload).replace(/\&$/, '') - }]; - } - } -} - -function getFlashVersion() { - var plugins, plugin, result; - - if (navigator.plugins && navigator.plugins.length > 0) { - plugins = navigator.plugins; - for (var i = 0; i < plugins.length && !result; i++) { - plugin = plugins[i]; - if (plugin.name.indexOf('Shockwave Flash') > -1) { - result = plugin.description.split('Shockwave Flash ')[1]; - } - } - } - return result || ''; -} - -function setConsentParams(gdprConsent, payload) { - if (gdprConsent) { - payload.gdpr = 0; - payload.consent_str = ''; - payload.consent_given = 0; - if (typeof gdprConsent.gdprApplies !== 'undefined') { - payload.gdpr = gdprConsent.gdprApplies ? 1 : 0; - } - if (typeof gdprConsent.consentString !== 'undefined') { - payload.consent_str = gdprConsent.consentString; - } - if (gdprConsent.vendorData && gdprConsent.vendorData.vendorConsents && typeof gdprConsent.vendorData.vendorConsents[FIDELITY_VENDOR_ID.toString(10)] !== 'undefined') { - payload.consent_given = gdprConsent.vendorData.vendorConsents[FIDELITY_VENDOR_ID.toString(10)] ? 1 : 0; - } - } -} - -registerBidder(spec); diff --git a/modules/freewheel-sspBidAdapter.js b/modules/freewheel-sspBidAdapter.js deleted file mode 100644 index 3e52ba2cbe9a..000000000000 --- a/modules/freewheel-sspBidAdapter.js +++ /dev/null @@ -1,360 +0,0 @@ -import * as utils from '../src/utils'; -import { registerBidder } from '../src/adapters/bidderFactory'; -// import { config } from '../src/config'; - -const BIDDER_CODE = 'freewheel-ssp'; - -const PROTOCOL = getProtocol(); -const FREEWHEEL_ADSSETUP = PROTOCOL + '://ads.stickyadstv.com/www/delivery/swfIndex.php'; -const MUSTANG_URL = PROTOCOL + '://cdn.stickyadstv.com/mustang/mustang.min.js'; -const PRIMETIME_URL = PROTOCOL + '://cdn.stickyadstv.com/prime-time/'; -const USER_SYNC_URL = PROTOCOL + '://ads.stickyadstv.com/auto-user-sync'; - -function getProtocol() { - if (location.protocol && location.protocol.indexOf('https') === 0) { - return 'https'; - } else { - return 'http'; - } -} - -function isValidUrl(str) { - if (!str) { - return false; - } - - // regExp for url validation - var pattern = /^(https?|ftp|file):\/\/([a-zA-Z0-9.-]+(:[a-zA-Z0-9.&%$-]+)*@)*((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])){3}|([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+\.(com|edu|gov|int|mil|net|org|biz|arpa|info|name|pro|aero|coop|museum|[a-zA-Z]{2}))(:[0-9]+)*(\/($|[a-zA-Z0-9.,?'\\+&%$#=~_-]+))*$/; - return pattern.test(str); -} - -function getBiggerSize(array) { - var result = [0, 0]; - for (var i = 0; i < array.length; i++) { - if (array[i][0] * array[i][1] > result[0] * result[1]) { - result = array[i]; - } - } - return result; -} - -/* -* read the pricing extension with this format: 1.0000 -* @return {object} pricing data in format: {currency: "EUR", price:"1.000"} -*/ -function getPricing(xmlNode) { - var pricingExtNode; - var princingData = {}; - - var extensions = xmlNode.querySelectorAll('Extension'); - // Nodelist.forEach is not supported in IE and Edge - // Workaround given here https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/10638731/ - Array.prototype.forEach.call(extensions, function(node) { - if (node.getAttribute('type') === 'StickyPricing') { - pricingExtNode = node; - } - }); - - if (pricingExtNode) { - var priceNode = pricingExtNode.querySelector('Price'); - princingData = { - currency: priceNode.getAttribute('currency'), - price: priceNode.textContent || priceNode.innerText - }; - } else { - utils.logWarn('PREBID - ' + BIDDER_CODE + ': Can\'t get pricing data. Is price awareness enabled?'); - } - - return princingData; -} - -function hashcode(inputString) { - var hash = 0; - var char; - if (inputString.length == 0) return hash; - for (var i = 0; i < inputString.length; i++) { - char = inputString.charCodeAt(i); - hash = ((hash << 5) - hash) + char; - hash = hash & hash; // Convert to 32bit integer - } - return hash; -} - -function getCreativeId(xmlNode) { - var creaId = ''; - var adNodes = xmlNode.querySelectorAll('Ad'); - // Nodelist.forEach is not supported in IE and Edge - // Workaround given here https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/10638731/ - Array.prototype.forEach.call(adNodes, function(el) { - creaId += '[' + el.getAttribute('id') + ']'; - }); - - return creaId; -} - -/** -* returns the top most accessible window -*/ -function getTopMostWindow() { - var res = window; - - try { - while (top !== res) { - if (res.parent.location.href.length) { res = res.parent; } - } - } catch (e) {} - - return res; -} - -function getComponentId(inputFormat) { - var component = 'mustang'; // default component id - - if (inputFormat && inputFormat !== 'inbanner') { - // format identifiers are equals to their component ids. - component = inputFormat; - } - - return component; -} - -function getAPIName(componentId) { - componentId = componentId || ''; - - // remove dash in componentId to get API name - return componentId.replace('-', ''); -} - -function formatAdHTML(bid, size) { - var integrationType = bid.params.format; - - var divHtml = '
'; - - var script = ''; - var libUrl = ''; - if (integrationType && integrationType !== 'inbanner') { - libUrl = PRIMETIME_URL + getComponentId(bid.params.format) + '.min.js'; - script = getOutstreamScript(bid, size); - } else { - libUrl = MUSTANG_URL; - script = getInBannerScript(bid, size); - } - - return divHtml + - ''; -} - -var getInBannerScript = function(bid, size) { - return 'var config = {' + - ' preloadedVast:vast,' + - ' autoPlay:true' + - ' };' + - ' var ad = new window.com.stickyadstv.vpaid.Ad(document.getElementById("freewheelssp_prebid_target"),config);' + - ' (new window.com.stickyadstv.tools.ASLoader(' + bid.params.zoneId + ', \'' + getComponentId(bid.params.format) + '\')).registerEvents(ad);' + - ' ad.initAd(' + size[0] + ',' + size[1] + ',"",0,"","");'; -}; - -var getOutstreamScript = function(bid) { - var config = bid.params; - - // default placement if no placement is set - if (!config.hasOwnProperty('domId') && !config.hasOwnProperty('auto') && !config.hasOwnProperty('p') && !config.hasOwnProperty('article')) { - if (config.format === 'intext-roll') { - config.iframeMode = 'dfp'; - } else { - config.domId = 'freewheelssp_prebid_target'; - } - } - - var script = 'var config = {' + - ' preloadedVast:vast,' + - ' ASLoader:new window.com.stickyadstv.tools.ASLoader(' + bid.params.zoneId + ', \'' + getComponentId(bid.params.format) + '\')'; - - for (var key in config) { - // dont' send format parameter - // neither zone nor vastUrlParams value as Vast is already loaded - if (config.hasOwnProperty(key) && key !== 'format' && key !== 'zone' && key !== 'zoneId' && key !== 'vastUrlParams') { - script += ',' + key + ':"' + config[key] + '"'; - } - } - script += '};' + - - 'window.com.stickyadstv.' + getAPIName(bid.params.format) + '.start(config);'; - - return script; -}; - -export const spec = { - code: BIDDER_CODE, - supportedMediaTypes: ['banner', 'video'], - aliases: ['stickyadstv'], // former name for freewheel-ssp - /** - * Determines whether or not the given bid request is valid. - * - * @param {object} bid The bid to validate. - * @return boolean True if this is a valid bid, and false otherwise. - */ - isBidRequestValid: function(bid) { - return !!(bid.params.zoneId); - }, - - /** - * Make a server request from the list of BidRequests. - * - * @param {BidRequest[]} bidRequests A non-empty list of bid requests which should be sent to the Server. - * @return ServerRequest Info describing the request to the server. - */ - buildRequests: function(bidRequests, bidderRequest) { - // var currency = config.getConfig(currency); - - var currentBidRequest = bidRequests[0]; - if (bidRequests.length > 1) { - utils.logMessage('Prebid.JS - freewheel bid adapter: only one ad unit is required.'); - } - - var zone = currentBidRequest.params.zoneId; - var timeInMillis = new Date().getTime(); - var keyCode = hashcode(zone + '' + timeInMillis); - - var requestParams = { - reqType: 'AdsSetup', - protocolVersion: '2.0', - zoneId: zone, - componentId: getComponentId(currentBidRequest.params.format), - timestamp: timeInMillis, - pKey: keyCode - }; - - // Add GDPR flag and consent string - if (bidderRequest.gdprConsent) { - requestParams._fw_gdpr_consent = bidderRequest.gdprConsent.consentString; - - if (typeof bidderRequest.gdprConsent.gdprApplies === 'boolean') { - requestParams._fw_gdpr = bidderRequest.gdprConsent.gdprApplies; - } - } - - if (currentBidRequest.params.gdpr_consented_providers) { - requestParams._fw_gdpr_consented_providers = currentBidRequest.params.gdpr_consented_providers; - } - - var vastParams = currentBidRequest.params.vastUrlParams; - if (typeof vastParams === 'object') { - for (var key in vastParams) { - if (vastParams.hasOwnProperty(key)) { - requestParams[key] = vastParams[key]; - } - } - } - - var location = utils.getTopWindowUrl(); - if (isValidUrl(location)) { - requestParams.loc = location; - } - - var playerSize = getBiggerSize(currentBidRequest.sizes); - if (playerSize[0] > 0 || playerSize[1] > 0) { - requestParams.playerSize = playerSize[0] + 'x' + playerSize[1]; - } - - return { - method: 'GET', - url: FREEWHEEL_ADSSETUP, - data: requestParams, - bidRequest: currentBidRequest - }; - }, - - /** - * Unpack the response from the server into a list of bids. - * - * @param {*} serverResponse A successful response from the server. - * @param {object} request: the built request object containing the initial bidRequest. - * @return {Bid[]} An array of bids which were nested inside the server. - */ - interpretResponse: function(serverResponse, request) { - var bidrequest = request.bidRequest; - var playerSize = getBiggerSize(bidrequest.sizes); - - if (typeof serverResponse == 'object' && typeof serverResponse.body == 'string') { - serverResponse = serverResponse.body; - } - - var xmlDoc; - try { - var parser = new DOMParser(); - xmlDoc = parser.parseFromString(serverResponse, 'application/xml'); - } catch (err) { - utils.logWarn('Prebid.js - ' + BIDDER_CODE + ' : ' + err); - return; - } - - const princingData = getPricing(xmlDoc); - const creativeId = getCreativeId(xmlDoc); - - const topWin = getTopMostWindow(); - if (!topWin.freewheelssp_cache) { - topWin.freewheelssp_cache = {}; - } - topWin.freewheelssp_cache[bidrequest.adUnitCode] = serverResponse; - - const bidResponses = []; - - if (princingData.price) { - const bidResponse = { - requestId: bidrequest.bidId, - cpm: princingData.price, - width: playerSize[0], - height: playerSize[1], - creativeId: creativeId, - currency: princingData.currency, - netRevenue: true, - ttl: 360 - }; - - var mediaTypes = bidrequest.mediaTypes || {}; - if (mediaTypes.video) { - // bidResponse.vastXml = serverResponse; - bidResponse.mediaType = 'video'; - - var blob = new Blob([serverResponse], {type: 'application/xml'}); - bidResponse.vastUrl = window.URL.createObjectURL(blob); - } else { - bidResponse.ad = formatAdHTML(bidrequest, playerSize); - } - - bidResponses.push(bidResponse); - } - - return bidResponses; - }, - - getUserSyncs: function(syncOptions) { - if (syncOptions.pixelEnabled) { - return [{ - type: 'image', - url: USER_SYNC_URL - }]; - } - }, - -} -registerBidder(spec); diff --git a/modules/fyberBidAdapter.js b/modules/fyberBidAdapter.js deleted file mode 100644 index 3586d0775ace..000000000000 --- a/modules/fyberBidAdapter.js +++ /dev/null @@ -1,378 +0,0 @@ -import {logError, getTopWindowUrl, getTopWindowReferrer, getTopWindowLocation, createTrackPixelHtml} from '../src/utils'; -import { registerBidder } from '../src/adapters/bidderFactory'; -import { formatQS } from '../src/url'; -import { config } from '../src/config'; - -/** - * @type {{CODE: string, V: string, RECTANGLE_SIZE: {W: number, H: number}, SPOT_TYPES: {INTERSTITIAL: string, RECTANGLE: string, FLOATING: string, BANNER: string}, DISPLAY_AD: number, ENDPOINT_URL: string, EVENTS_ENDPOINT_URL: string, RESPONSE_HEADERS_NAME: {PRICING_VALUE: string, AD_H: string, AD_W: string}}} - */ -const CONSTANTS = { - CODE: 'fyber', - V: 'FY-JS-HB-PBJS-1.0', - RECTANGLE_SIZE: {W: 300, H: 250}, - - SPOT_TYPES: { - INTERSTITIAL: 'interstitial', - RECTANGLE: 'rectangle', - FLOATING: 'floating', - BANNER: 'banner' - }, - - DISPLAY_AD: 20, - ENDPOINT_URL: '//ad-tag.inner-active.mobi/simpleM2M/requestJsonAd', - EVENTS_ENDPOINT_URL: '//vast-events.inner-active.mobi/Event', - RESPONSE_HEADERS_NAME: { - PRICING_VALUE: 'X-IA-Pricing-Value', - AD_H: 'X-IA-Ad-Height', - AD_W: 'X-IA-Ad-Width', - CREATIVE_ID: 'X-IA-Creative-ID', - CURRENCY: 'X-IA-Pricing-Currency', - TIMEOUT: 'X-IA-SESSION-TIMEOUT' - } -}; - -/** - * gloable util functions - * @type {{defaultsQsParams: {v: (string|string), page: string, mw: boolean, hb: string}, stringToCamel: (function(*)), objectToCamel: (function(*=))}} - */ -const Helpers = { - defaultsQsParams: {v: CONSTANTS.V, page: encodeURIComponent(getTopWindowUrl()), mw: true, hb: 'prebidjs'}, - /** - * Returns the ad HTML template - * @param adHtml: string {ad server creative} - * @param tracking: object {impressions, clicks} - * @param bidParams: object - * @returns {string}: create template - */ - getAd(adHtml, tracking, bidParams) { - let impressionsHtml = ''; - if (tracking && Array.isArray(tracking.impressions)) { - let impressions = tracking.impressions; - impressions.push(Reporter.getEventUrl('HBPreBidImpression', bidParams, false)); - impressions.forEach(impression => impression && (impressionsHtml += createTrackPixelHtml(impression))); - } - adHtml = impressionsHtml + adHtml.replace(/ - - - - -
${adHtml}
- - - `; - return adTemplate; - }, - - /** - * Change string format from underscore to camelcase (e.g., APP_ID to appId) - * @param {string} str - * @return string - */ - stringToCamel(str) { - if (str.indexOf('_') === -1) { - const first = str.charAt(0); - if (first !== first.toLowerCase()) { - str = str.toLowerCase(); - } - return str; - } - - str = str.toLowerCase(); - return str.replace(/(\_[a-z])/g, $1 => $1.toUpperCase().replace('_', '')); - }, - - /** - * Change all object keys string format from underscore to camelcase (e.g., {'APP_ID' : ...} to {'appId' : ...}) - * @param params: object - * @returns object - */ - objectToCamel(params) { - Object.keys(params).forEach(key => { - const keyCamelCase = this.stringToCamel(key); - if (keyCamelCase !== key) { - params[keyCamelCase] = params[key]; - delete params[key]; - } - }); - return params; - }, - - /** - * @param {Object} params - * @return {string} url - */ - getEndpointUrl(params) { - return (params && params.qa && params.qa.url) || (Reporter.getPageProtocol() + CONSTANTS.ENDPOINT_URL); - }, - - /** - * Adjust bid params to fyber-ad-server params - * @param {Object} bid - * @return {Object} bid - */ - toBidParams(bid) { - const bidParamsWithCustomParams = Object.assign({}, bid.params, bid.params.customParams); - delete bidParamsWithCustomParams.customParams; - bid.params = this.objectToCamel(bidParamsWithCustomParams); - return bid; - }, - - /** - * Validate if response is valid - * @param responseAsJson : object - * @param headersData: {} - * @returns {boolean} - * @private - */ - isValidBidResponse(responseAsJson, headersData) { - return (responseAsJson && responseAsJson.ad && responseAsJson.ad.html && headersData && headersData[CONSTANTS.RESPONSE_HEADERS_NAME.PRICING_VALUE] > 0); - } -}; - -/** - * Url generator - generates a request URL - * @type {{defaultsParams: *, serverParamNameBySettingParamName: {referrer: string, keywords: string, appId: string, portal: string, age: string, gender: string, isSecured: (boolean|null)}, toServerParams: (function(*)), unwantedValues: *[], getUrlParams: (function(*=))}} - */ -const Url = { - defaultsParams: Object.assign({}, Helpers.defaultsQsParams, {f: CONSTANTS.DISPLAY_AD, fs: false, ref: getTopWindowReferrer()}), - serverParamNameBySettingParamName: { - referrer: 'ref', - keywords: 'k', - appId: 'aid', - portal: 'po', - age: 'a', - gender: 'g', - gdprPrivacyConsent: 'gdpr_privacy_consent', - consentString: 'consent_string', - gdprConsentData: 'gdpr_consent_data' - }, - unwantedValues: ['', null, undefined], - - /** - * Maps publisher params to server params - * @param params: object {k:v} - * @returns object {k:v} - */ - toServerParams(params) { - const serverParams = {}; - for (const paramName in params) { - if (params.hasOwnProperty(paramName) && this.serverParamNameBySettingParamName.hasOwnProperty(paramName)) { - serverParams[this.serverParamNameBySettingParamName[paramName]] = params[paramName]; - } else { - serverParams[paramName] = params[paramName]; - } - } - - serverParams.isSecured = Reporter.getPageProtocol() === 'https:' || null; - return serverParams; - }, - - handleGDPR(params) { - if (params.hasOwnProperty('gdprPrivacyConsent')) { - if (['true', true, '1', 1].indexOf(params.gdprPrivacyConsent) !== -1) { - params.gdprPrivacyConsent = 1; - } else { - params.gdprPrivacyConsent = 0; - } - } - }, - - /** - * Prepare querty string to ad server - * @param params: object {k:v} - * @returns : object {k:v} - */ - getUrlParams(params) { - this.handleGDPR(params); - const serverParams = this.toServerParams(params); - const toQueryString = Object.assign({}, this.defaultsParams, serverParams); - for (const paramName in toQueryString) { - if (toQueryString.hasOwnProperty(paramName) && this.unwantedValues.indexOf(toQueryString[paramName]) !== -1) { - delete toQueryString[paramName]; - } - } - toQueryString.fs = params.spotType === CONSTANTS.SPOT_TYPES.INTERSTITIAL; - - if (params.spotType === CONSTANTS.SPOT_TYPES.RECTANGLE) { - toQueryString.rw = CONSTANTS.RECTANGLE_SIZE.W; - toQueryString.rh = CONSTANTS.RECTANGLE_SIZE.H; - } - toQueryString.bco = config.getConfig('cbTimeout') || config.getConfig('bidderTimeout'); - toQueryString.timestamp = Date.now(); - delete toQueryString.qa; - return toQueryString; - } -}; - -/** - * Analytics - * @type {{errorEventName: string, pageProtocol: string, getPageProtocol: (function(): string), getEventUrl: (function(*, *=)), defaults: {v: (string|string), page: string, mw: boolean, hb: string}, eventQueryStringParams: (function(Object): string)}} - */ -const Reporter = { - /** - * @private - */ - errorEventName: 'HBPreBidError', - pageProtocol: '', - defaults: Helpers.defaultsQsParams, - - /** - * Gets the page protocol based on the document.location.protocol - * The returned string is either http:// or https:// - * @return {string} - */ - getPageProtocol() { - if (!this.pageProtocol) { - this.pageProtocol = (getTopWindowLocation().protocol === 'http:' ? 'http:' : 'https:'); - } - return this.pageProtocol; - }, - - getEventUrl(evtName, extraDetails) { - let eventsEndpoint = CONSTANTS.EVENTS_ENDPOINT_URL + '?table=' + ((evtName === this.errorEventName) ? 'mbwError' : 'mbwEvent'); - let queryStringParams = this.eventQueryStringParams(extraDetails); - const appId = extraDetails && extraDetails.appId; - let queryStringParamsWithAID = `${queryStringParams}&aid=${appId}_${evtName}_other&evtName=${evtName}`; - return eventsEndpoint + '&' + queryStringParamsWithAID; - }, - - /** - * Fyber Event Reporting Query String Parameters, not including App Id. - * @param {object} extraDetails - e.g., a JS exception JSON object. - * @return {string} Fyber event contcatenated queryString parameters. - */ - eventQueryStringParams(extraDetails) { - const toQS = Object.assign({}, this.defaults, {realAppId: extraDetails && extraDetails.appId, timestamp: Date.now()}); - Url.handleGDPR(toQS); - return formatQS(toQS); - } -}; -const {PRICING_VALUE, AD_W, AD_H, CREATIVE_ID, CURRENCY, TIMEOUT} = CONSTANTS.RESPONSE_HEADERS_NAME; -/** - * Http helper to extract metadata - * @type {{headers: *[], getBidHeaders: (function(*))}} - */ -const Http = { - headerNames: [PRICING_VALUE, AD_W, AD_H, CREATIVE_ID, CURRENCY, TIMEOUT], - - /** - * Extract headers data - * @param responseHeaders: XMLHttpRequest - * @return {} - */ - getBidHeaders(responseHeaders) { - const headersData = {}; - this.headerNames.forEach(headerName => headersData[headerName] = responseHeaders.get(headerName)); - return headersData; - } -}; - -const bidByBidId = {}; -class FyberBid { - constructor(headersData, response, bid) { - this.handleGDPR(response.config.tracking, bid.params); - const [w, h] = bid.sizes[0]; - this.cpm = ((bid.params.qa && bid.params.qa.cpm) || headersData[PRICING_VALUE]) * 1000; - this.requestId = bid.bidId; - this.width = parseFloat(headersData[AD_W]) || w; - this.ad = Helpers.getAd(response.ad.html, response.config.tracking, bid.params); - this.height = parseFloat(headersData[AD_H]) || h; - this.creativeId = headersData[CREATIVE_ID]; - this.currency = headersData[CURRENCY] || 'USD'; - this.netRevenue = true; - this.ttl = 60 * (headersData[TIMEOUT] || 20); - this.dealId = null; - } - - handleGDPR(tracking, params) { - if (params.hasOwnProperty('gdprPrivacyConsent')) { - if (['true', true, '1', 1].indexOf(params.gdprPrivacyConsent) !== -1) { - params.gdprPrivacyConsent = 1; - } else { - params.gdprPrivacyConsent = 0; - } - Object.keys(tracking).forEach((trackName) => { - if (Array.isArray(tracking[trackName])) { - tracking[trackName].forEach((url, index) => { - if (url) { - if (url.indexOf('?') === -1) { - url += '?'; - } - url += '&gdpr_privacy_consent=' + params.gdprPrivacyConsent; - tracking[trackName][index] = url; - } - }); - } - }); - } - } -} - -export const spec = { - code: CONSTANTS.CODE, - - /** - * Determines whether or not the given bid request is valid. - * Valid bid request must have appId and spotType - * @param {BidRequest} bid The bid params to validate. - * @return boolean True if this is a valid bid, and false otherwise. - */ - isBidRequestValid(bid) { - const {appId, spotType} = Helpers.objectToCamel(bid.params); - const isValid = !!(appId && spotType); - if (!isValid) { - logError(`bid requires appId = ${appId} , spotType = ${spotType}`); - } - return isValid; - }, - - buildRequests(bidRequests) { - let requests = []; - bidRequests.forEach((bid) => { - bid = Helpers.toBidParams(bid); - bidByBidId[bid.bidId] = bid; - requests.push({ - method: 'GET', - url: Helpers.getEndpointUrl(bid.params), - data: Url.getUrlParams(bid.params), - bidId: bid.bidId - }); - }); - return requests; - }, - - interpretResponse(response, request) { - const isValid = response.body && response.body.ad; - const headersData = (isValid && Http.getBidHeaders(response.headers)) || {}; - const bid = bidByBidId[request.bidId]; - const bidResponse = []; - if (!isValid || !Helpers.isValidBidResponse(response.body, headersData)) { - logError(`response failed for ${CONSTANTS.CODE} adapter`); - return bidResponse; - } - bidResponse.push(new FyberBid(headersData, response.body, bid)); - return bidResponse; - } -}; -registerBidder(spec); diff --git a/modules/gammaBidAdapter.js b/modules/gammaBidAdapter.js deleted file mode 100644 index 926dae147902..000000000000 --- a/modules/gammaBidAdapter.js +++ /dev/null @@ -1,100 +0,0 @@ -import * as utils from '../src/utils'; -import { registerBidder } from '../src/adapters/bidderFactory'; - -const ENDPOINT = 'hb.gammaplatform.com'; -const BIDDER_CODE = 'gamma'; - -export const spec = { - code: BIDDER_CODE, - aliases: ['gamma'], - supportedMediaTypes: ['banner', 'video'], - - /** - * Determines whether or not the given bid request is valid. - * - * @param {object} bid The bid to validate. - * @return boolean True if this is a valid bid, and false otherwise. - */ - isBidRequestValid: function(bid) { - return !!(bid.params.siteId || bid.params.zoneId); - }, - - /** - * Make a server request from the list of BidRequests. - * - * @param {BidRequest[]} bidRequests A non-empty list of bid requests which should be sent to the Server. - * @return ServerRequest Info describing the request to the server. - */ - buildRequests: function(bidRequests) { - const serverRequests = []; - for (var i = 0, len = bidRequests.length; i < len; i++) { - const gaxObjParams = bidRequests[i]; - serverRequests.push({ - method: 'GET', - url: '//' + ENDPOINT + '/adx/request?wid=' + gaxObjParams.params.siteId + '&zid=' + gaxObjParams.params.zoneId + '&hb=pbjs&bidid=' + gaxObjParams.bidId + '&urf=' + encodeURIComponent(utils.getTopWindowUrl()) - }); - } - return serverRequests; - }, - - /** - * Unpack the response from the server into a list of bids. - * - * @param {*} serverResponse A successful response from the server. - * @return {Bid[]} An array of bids which were nested inside the server. - */ - interpretResponse: function(serverResponse) { - serverResponse = serverResponse.body; - - const bids = []; - - if (serverResponse.id) { - const bid = newBid(serverResponse); - bids.push(bid); - } - - return bids; - }, - - getUserSyncs: function(syncOptions) { - if (syncOptions.iframeEnabled) { - return [{ - type: 'iframe', - url: '//' + ENDPOINT + '/adx/usersync' - }]; - } - } -} - -/** - * Unpack the Server's Bid into a Prebid-compatible one. - * @param serverBid - * @return Bid - */ -function newBid(serverBid) { - const bid = { - ad: serverBid.seatbid[0].bid[0].adm, - cpm: serverBid.seatbid[0].bid[0].price, - creativeId: serverBid.seatbid[0].bid[0].adid, - currency: serverBid.cur, - dealId: serverBid.seatbid[0].bid[0].dealid, - width: serverBid.seatbid[0].bid[0].w, - height: serverBid.seatbid[0].bid[0].h, - mediaType: serverBid.type, - netRevenue: true, - requestId: serverBid.id, - ttl: serverBid.seatbid[0].bid[0].ttl || 300 - }; - - if (serverBid.type == 'video') { - Object.assign(bid, { - vastXml: serverBid.seatbid[0].bid[0].vastXml, - vastUrl: serverBid.seatbid[0].bid[0].vastUrl, - ttl: 3600 - }); - } - - return bid; -} - -registerBidder(spec); diff --git a/modules/gamoshiBidAdapter.js b/modules/gamoshiBidAdapter.js deleted file mode 100644 index 89ffde51889f..000000000000 --- a/modules/gamoshiBidAdapter.js +++ /dev/null @@ -1,279 +0,0 @@ -import * as utils from '../src/utils'; -import {registerBidder} from '../src/adapters/bidderFactory'; -import {config} from '../src/config'; -import {Renderer} from '../src/Renderer'; -import {BANNER, VIDEO} from '../src/mediaTypes'; - -const ENDPOINTS = { - 'gamoshi': 'https://rtb.gamoshi.io' -}; - -const DEFAULT_TTL = 360; - -export const helper = { - getTopFrame: function () { - try { - return window.top === window ? 1 : 0; - } catch (e) { - } - return 0; - }, - startsWith: function (str, search) { - return str.substr(0, search.length) === search; - }, - getTopWindowDomain: function (url) { - const domainStart = url.indexOf('://') + '://'.length; - return url.substring(domainStart, url.indexOf('/', domainStart) < 0 ? url.length : url.indexOf('/', domainStart)); - }, - - getMediaType: function (bid) { - if (bid.ext) { - if (bid.ext.media_type) { - return bid.ext.media_type.toLowerCase(); - } else if (bid.ext.vast_url) { - return VIDEO; - } else { - return BANNER; - } - } - return BANNER; - } -}; - -export const spec = { - code: 'gamoshi', - aliases: ['gambid', 'cleanmedia', '9MediaOnline'], - supportedMediaTypes: ['banner', 'video'], - - isBidRequestValid: function (bid) { - return !!bid.params.supplyPartnerId && utils.isStr(bid.params.supplyPartnerId) && - (!bid.params['rtbEndpoint'] || utils.isStr(bid.params['rtbEndpoint'])) && - (!bid.params.bidfloor || utils.isNumber(bid.params.bidfloor)) && - (!bid.params['adpos'] || utils.isNumber(bid.params['adpos'])) && - (!bid.params['protocols'] || Array.isArray(bid.params['protocols'])) && - (!bid.params.instl || bid.params.instl === 0 || bid.params.instl === 1); - }, - - buildRequests: function (validBidRequests, bidderRequest) { - return validBidRequests.map(bidRequest => { - const {adUnitCode, auctionId, mediaTypes, params, sizes, transactionId} = bidRequest; - const baseEndpoint = params['rtbEndpoint'] || ENDPOINTS['gamoshi']; - const rtbEndpoint = `${baseEndpoint}/r/${params.supplyPartnerId}/bidr?rformat=open_rtb&reqformat=rtb_json&bidder=prebid` + (params.query ? '&' + params.query : ''); - let url = config.getConfig('pageUrl') || bidderRequest.refererInfo.referer; - - const rtbBidRequest = { - 'id': auctionId, - 'site': { - 'domain': helper.getTopWindowDomain(url), - 'page': url, - 'ref': bidderRequest.refererInfo.referer - }, - 'device': { - 'ua': navigator.userAgent - }, - 'imp': [], - 'ext': {}, - 'user': { - 'ext': {} - } - }; - const gdprConsent = bidderRequest.gdprConsent; - - if (gdprConsent && gdprConsent.consentString && gdprConsent.gdprApplies) { - rtbBidRequest.ext.gdpr_consent = { - consent_string: gdprConsent.consentString, - consent_required: gdprConsent.gdprApplies - }; - rtbBidRequest.regs = { - ext: { - gdpr: gdprConsent.gdprApplies === true ? 1 : 0 - } - }; - rtbBidRequest.user = { - ext: { - consent: gdprConsent.consentString - } - } - } - const imp = { - 'id': transactionId, - 'instl': params.instl === 1 ? 1 : 0, - 'tagid': adUnitCode, - 'bidfloor': params.bidfloor || 0, - 'bidfloorcur': 'USD', - 'secure': helper.startsWith(utils.getTopWindowUrl().toLowerCase(), 'http://') ? 0 : 1 - }; - - const hasFavoredMediaType = - params.favoredMediaType && this.supportedMediaTypes.includes(params.favoredMediaType); - - if ((!mediaTypes || mediaTypes.banner)) { - if (!hasFavoredMediaType || params.favoredMediaType === BANNER) { - const bannerImp = Object.assign({}, imp, { - banner: { - w: sizes.length ? sizes[0][0] : 300, - h: sizes.length ? sizes[0][1] : 250, - pos: params.pos || 0, - topframe: helper.getTopFrame() - } - }); - rtbBidRequest.imp.push(bannerImp); - } - } - - if (mediaTypes && mediaTypes.video) { - if (!hasFavoredMediaType || params.favoredMediaType === VIDEO) { - const playerSize = mediaTypes.video.playerSize || sizes; - const videoImp = Object.assign({}, imp, { - video: { - w: playerSize ? playerSize[0][0] : 300, - h: playerSize ? playerSize[0][1] : 250, - protocols: params.protocols || [1, 2, 3, 4, 5, 6], - pos: params.pos || 0, - ext: { - context: mediaTypes.video.context - } - } - }); - rtbBidRequest.imp.push(videoImp); - } - } - - let eids = []; - if (bidRequest && bidRequest.userId) { - addExternalUserId(eids, utils.deepAccess(bidRequest, `userId.id5id`), 'id5-sync.com', 'ID5ID'); - addExternalUserId(eids, utils.deepAccess(bidRequest, `userId.tdid`), 'adserver.org', 'TDID'); - } - if (eids.length > 0) { - rtbBidRequest.user.ext.eids = eids; - } - - if (rtbBidRequest.imp.length === 0) { - return; - } - - return {method: 'POST', url: rtbEndpoint, data: rtbBidRequest, bidRequest}; - }); - }, - - interpretResponse: function (serverResponse, bidRequest) { - const response = serverResponse && serverResponse.body; - if (!response) { - utils.logError('empty response'); - return []; - } - - const bids = response.seatbid.reduce((acc, seatBid) => acc.concat(seatBid.bid), []); - let outBids = []; - - bids.forEach(bid => { - const outBid = { - requestId: bidRequest.bidRequest.bidId, - cpm: bid.price, - width: bid.w, - height: bid.h, - ttl: DEFAULT_TTL, - creativeId: bid.crid || bid.adid, - netRevenue: true, - currency: bid.cur || response.cur, - mediaType: helper.getMediaType(bid) - }; - - if (utils.deepAccess(bidRequest.bidRequest, 'mediaTypes.' + outBid.mediaType)) { - if (outBid.mediaType === BANNER) { - outBids.push(Object.assign({}, outBid, {ad: bid.adm})); - } else if (outBid.mediaType === VIDEO) { - const context = utils.deepAccess(bidRequest.bidRequest, 'mediaTypes.video.context'); - outBids.push(Object.assign({}, outBid, { - vastUrl: bid.ext.vast_url, - vastXml: bid.adm, - renderer: context === 'outstream' ? newRenderer(bidRequest.bidRequest, bid) : undefined - })); - } - } - }); - return outBids; - }, - - getUserSyncs: function (syncOptions, serverResponses, gdprConsent) { - const syncs = []; - const gdprApplies = gdprConsent && (typeof gdprConsent.gdprApplies === 'boolean') ? gdprConsent.gdprApplies : false; - const suffix = gdprApplies ? 'gc=' + encodeURIComponent(gdprConsent.consentString) : 'gc=missing'; - serverResponses.forEach(resp => { - if (resp.body) { - const bidResponse = resp.body; - if (bidResponse.ext && Array.isArray(bidResponse.ext['utrk'])) { - bidResponse.ext['utrk'].forEach(pixel => { - const url = pixel.url + (pixel.url.indexOf('?') > 0 ? '&' + suffix : '?' + suffix); - return syncs.push({type: pixel.type, url}); - }); - } - if (Array.isArray(bidResponse.seatbid)) { - bidResponse.seatbid.forEach(seatBid => { - if (Array.isArray(seatBid.bid)) { - seatBid.bid.forEach(bid => { - if (bid.ext && Array.isArray(bid.ext['utrk'])) { - bid.ext['utrk'].forEach(pixel => { - const url = pixel.url + (pixel.url.indexOf('?') > 0 ? '&' + suffix : '?' + suffix); - return syncs.push({type: pixel.type, url}); - }); - } - }); - } - }); - } - } - }); - return syncs; - } -}; - -function newRenderer(bidRequest, bid, rendererOptions = {}) { - const renderer = Renderer.install({ - url: (bidRequest.params && bidRequest.params.rendererUrl) || (bid.ext && bid.ext.renderer_url) || '//s.wlplayer.com/video/latest/renderer.js', - config: rendererOptions, - loaded: false, - }); - try { - renderer.setRender(renderOutstream); - } catch (err) { - utils.logWarn('Prebid Error calling setRender on renderer', err); - } - return renderer; -} - -function renderOutstream(bid) { - bid.renderer.push(() => { - const unitId = bid.adUnitCode + '/' + bid.adId; - window['GamoshiPlayer'].renderAd({ - id: unitId, - debug: window.location.href.indexOf('pbjsDebug') >= 0, - placement: document.getElementById(bid.adUnitCode), - width: bid.width, - height: bid.height, - events: { - ALL_ADS_COMPLETED: () => window.setTimeout(() => { - window['GamoshiPlayer'].removeAd(unitId); - }, 300) - }, - vastUrl: bid.vastUrl, - vastXml: bid.vastXml - }); - }); -} - -function addExternalUserId(eids, value, source, rtiPartner) { - if (utils.isStr(value)) { - eids.push({ - source, - uids: [{ - id: value, - ext: { - rtiPartner - } - }] - }); - } -} - -registerBidder(spec); diff --git a/modules/getintentBidAdapter.js b/modules/getintentBidAdapter.js index bc2ed0936658..e1652602951b 100644 --- a/modules/getintentBidAdapter.js +++ b/modules/getintentBidAdapter.js @@ -83,7 +83,7 @@ export const spec = { } function buildUrl(bid) { - return '//' + BID_HOST + (bid.is_video ? BID_VIDEO_PATH : BID_BANNER_PATH); + return 'https://' + BID_HOST + (bid.is_video ? BID_VIDEO_PATH : BID_BANNER_PATH); } /** diff --git a/modules/giantsBidAdapter.js b/modules/giantsBidAdapter.js deleted file mode 100644 index e2693392578d..000000000000 --- a/modules/giantsBidAdapter.js +++ /dev/null @@ -1,343 +0,0 @@ -import * as utils from '../src/utils'; -import { registerBidder } from '../src/adapters/bidderFactory'; -import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes'; -import includes from 'core-js/library/fn/array/includes'; - -const BIDDER_CODE = 'giants'; -const URL = '//d.admp.io/hb'; -const VIDEO_TARGETING = ['id', 'mimes', 'minduration', 'maxduration', - 'startdelay', 'skippable', 'playback_method', 'frameworks']; -const NATIVE_MAPPING = { - body: 'description', - cta: 'ctatext', - image: { - serverName: 'main_image', - requiredParams: { required: true }, - minimumParams: { sizes: [{}] }, - }, - icon: { - serverName: 'icon', - requiredParams: { required: true }, - minimumParams: { sizes: [{}] }, - }, - sponsoredBy: 'sponsored_by', -}; -const SOURCE = 'pbjs'; - -export const spec = { - code: BIDDER_CODE, - aliases: [], - supportedMediaTypes: [BANNER, VIDEO, NATIVE], - - /** - * Determines whether or not the given bid request is valid. - * - * @param {object} bid The bid to validate. - * @return boolean True if this is a valid bid, and false otherwise. - */ - isBidRequestValid: function(bid) { - return !!(bid.params.zoneId); - }, - - /** - * Make a server request from the list of BidRequests. - * - * @param {BidRequest[]} bidRequests A non-empty list of bid requests which should be sent to the Server. - * @return ServerRequest Info describing the request to the server. - */ - buildRequests: function(bidRequests, bidderRequest) { - const tags = bidRequests.map(bidToTag); - // const zoneIds = bidRequests.map(bidToZoneId); - // var firstBid = bidRequests[0]; - var ref = utils.getTopWindowUrl(); - const url = URL + '/multi?url=' + ref; - // + '&callback=window.$$PREBID_GLOBAL$$.giantsResponse&callback_uid=' + bid.bidId; - - const payload = { - tags: [...tags], - // user: userObj, - sdk: { - source: SOURCE, - version: '$prebid.version$' - } - }; - // if (member > 0) { - // payload.member_id = member; - // } - - if (bidderRequest && bidderRequest.gdprConsent) { - // note - objects for impbus use underscore instead of camelCase - payload.gdpr_consent = { - consent_string: bidderRequest.gdprConsent.consentString, - consent_required: bidderRequest.gdprConsent.gdprApplies - }; - } - - const payloadString = JSON.stringify(payload); - - return { - method: 'POST', - // url: URL, - url: url, - data: payloadString, - bidderRequest - }; - }, - - /** - * Unpack the response from the server into a list of bids. - * - * @param {*} serverResponse A successful response from the server. - * @return {Bid[]} An array of bids which were nested inside the server. - */ - interpretResponse: function(serverResponse, {bidderRequest}) { - serverResponse = serverResponse.body; - const bids = []; - if (!serverResponse || serverResponse.error) { - let errorMessage = `in response for ${bidderRequest.bidderCode} adapter`; - if (serverResponse && serverResponse.error) { errorMessage += `: ${serverResponse.error}`; } - utils.logError(errorMessage); - return bids; - } - if (serverResponse.tags) { - serverResponse.tags.forEach(serverBid => { - if (serverBid.cpm && serverBid.cpm !== 0) { - const bid = newBid(serverBid, bidderRequest); - bid.mediaType = BANNER; - bids.push(bid); - } - }); - } - return bids; - }, - - getUserSyncs: function(syncOptions) { - if (syncOptions.iframeEnabled) { - return [{ - type: 'iframe', - url: '//d.admp.io/ping' - }]; - } - } -} - -/* Turn keywords parameter into ut-compatible format */ -function getKeywords(keywords) { - let arrs = []; - - utils._each(keywords, (v, k) => { - if (utils.isArray(v)) { - let values = []; - utils._each(v, (val) => { - val = utils.getValueString('keywords.' + k, val); - if (val) { values.push(val); } - }); - v = values; - } else { - v = utils.getValueString('keywords.' + k, v); - if (utils.isStr(v)) { - v = [v]; - } else { - return; - } // unsuported types - don't send a key - } - arrs.push({key: k, value: v}); - }); - - return arrs; -} - -/** - * Unpack the Server's Bid into a Prebid-compatible one. - * @param serverBid - * @param rtbBid - * @param bidderRequest - * @return Bid - */ -function newBid(serverBid, bidderRequest) { - const bid = { - requestId: serverBid.uuid, - cpm: serverBid.cpm, - creativeId: serverBid.creative_id, - // dealId: rtbBid.deal_id, - currency: 'USD', - netRevenue: true, - ttl: 300 - }; - - Object.assign(bid, { - width: serverBid.width, - height: serverBid.height, - // ad: serverBid.ad - ad: _renderCreative(serverBid.adUrl, serverBid.width, serverBid.height) - }); - // try { - // const url = rtbBid.rtb.trackers[0].impression_urls[0]; - // const tracker = utils.createTrackPixelHtml(url); - // bid.ad += tracker; - // } catch (error) { - // utils.logError('Error appending tracking pixel', error); - // } - - return bid; -} - -function bidToTag(bid) { - const tag = {}; - tag.sizes = transformSizes(bid.sizes); - tag.primary_size = tag.sizes[0]; - tag.ad_types = []; - tag.uuid = bid.bidId; - if (bid.params.zoneId) { - tag.id = bid.params.zoneId; - } else { - tag.code = bid.params.invCode; - } - tag.allow_smaller_sizes = bid.params.allowSmallerSizes || false; - tag.use_pmt_rule = bid.params.usePaymentRule || false - tag.prebid = true; - tag.disable_psa = true; - if (bid.params.reserve) { - tag.reserve = bid.params.reserve; - } - if (bid.params.position) { - tag.position = {'above': 1, 'below': 2}[bid.params.position] || 0; - } - if (bid.params.trafficSourceCode) { - tag.traffic_source_code = bid.params.trafficSourceCode; - } - if (bid.params.privateSizes) { - tag.private_sizes = transformSizes(bid.params.privateSizes); - } - if (bid.params.supplyType) { - tag.supply_type = bid.params.supplyType; - } - if (bid.params.pubClick) { - tag.pubclick = bid.params.pubClick; - } - if (bid.params.extInvCode) { - tag.ext_inv_code = bid.params.extInvCode; - } - if (bid.params.externalImpId) { - tag.external_imp_id = bid.params.externalImpId; - } - if (!utils.isEmpty(bid.params.keywords)) { - tag.keywords = getKeywords(bid.params.keywords); - } - - if (bid.mediaType === NATIVE || utils.deepAccess(bid, `mediaTypes.${NATIVE}`)) { - tag.ad_types.push(NATIVE); - - if (bid.nativeParams) { - const nativeRequest = buildNativeRequest(bid.nativeParams); - tag[NATIVE] = {layouts: [nativeRequest]}; - } - } - - const videoMediaType = utils.deepAccess(bid, `mediaTypes.${VIDEO}`); - const context = utils.deepAccess(bid, 'mediaTypes.video.context'); - - if (bid.mediaType === VIDEO || videoMediaType) { - tag.ad_types.push(VIDEO); - } - - // instream gets vastUrl, outstream gets vastXml - if (bid.mediaType === VIDEO || (videoMediaType && context !== 'outstream')) { - tag.require_asset_url = true; - } - - if (bid.params.video) { - tag.video = {}; - // place any valid video params on the tag - Object.keys(bid.params.video) - .filter(param => includes(VIDEO_TARGETING, param)) - .forEach(param => tag.video[param] = bid.params.video[param]); - } - - if ( - (utils.isEmpty(bid.mediaType) && utils.isEmpty(bid.mediaTypes)) || - (bid.mediaType === BANNER || (bid.mediaTypes && bid.mediaTypes[BANNER])) - ) { - tag.ad_types.push(BANNER); - } - - return tag; -} - -// function bidToZoneId(bid) { -// return bid.params.zoneId; -// } - -/* Turn bid request sizes into ut-compatible format */ -function transformSizes(requestSizes) { - let sizes = []; - let sizeObj = {}; - - if (utils.isArray(requestSizes) && requestSizes.length === 2 && - !utils.isArray(requestSizes[0])) { - sizeObj.width = parseInt(requestSizes[0], 10); - sizeObj.height = parseInt(requestSizes[1], 10); - sizes.push(sizeObj); - } else if (typeof requestSizes === 'object') { - for (let i = 0; i < requestSizes.length; i++) { - let size = requestSizes[i]; - sizeObj = {}; - sizeObj.width = parseInt(size[0], 10); - sizeObj.height = parseInt(size[1], 10); - sizes.push(sizeObj); - } - } - - return sizes; -} - -function buildNativeRequest(params) { - const request = {}; - - // map standard prebid native asset identifier to /ut parameters - // e.g., tag specifies `body` but /ut only knows `description`. - // mapping may be in form {tag: ''} or - // {tag: {serverName: '', requiredParams: {...}}} - Object.keys(params).forEach(key => { - // check if one of the forms is used, otherwise - // a mapping wasn't specified so pass the key straight through - const requestKey = - (NATIVE_MAPPING[key] && NATIVE_MAPPING[key].serverName) || - NATIVE_MAPPING[key] || - key; - - // required params are always passed on request - const requiredParams = NATIVE_MAPPING[key] && NATIVE_MAPPING[key].requiredParams; - request[requestKey] = Object.assign({}, requiredParams, params[key]); - - // minimum params are passed if no non-required params given on adunit - const minimumParams = NATIVE_MAPPING[key] && NATIVE_MAPPING[key].minimumParams; - - if (requiredParams && minimumParams) { - // subtract required keys from adunit keys - const adunitKeys = Object.keys(params[key]); - const requiredKeys = Object.keys(requiredParams); - const remaining = adunitKeys.filter(key => !includes(requiredKeys, key)); - - // if none are left over, the minimum params needs to be sent - if (remaining.length === 0) { - request[requestKey] = Object.assign({}, request[requestKey], minimumParams); - } - } - }); - - return request; -} - -function _renderCreative(adUrl, width, height) { - return ` - - - - '}, + {ad: '
'}, ] }, native: { diff --git a/test/spec/modules/adkernelAdnAnalyticsAdapter_spec.js b/test/spec/modules/adkernelAdnAnalyticsAdapter_spec.js deleted file mode 100644 index 26fd13afd1ff..000000000000 --- a/test/spec/modules/adkernelAdnAnalyticsAdapter_spec.js +++ /dev/null @@ -1,268 +0,0 @@ -import analyticsAdapter, {ExpiringQueue, getUmtSource, storage} from 'modules/adkernelAdnAnalyticsAdapter'; -import {expect} from 'chai'; -import adapterManager from 'src/adapterManager'; -import CONSTANTS from 'src/constants.json'; - -const events = require('../../../src/events'); - -const DIRECT = { - source: '(direct)', - medium: '(direct)', - campaign: '(direct)' -}; -const REFERRER = { - source: 'lander.com', - medium: '(referral)', - campaign: '(referral)', - content: '/lander.html' -}; -const GOOGLE_ORGANIC = { - source: 'google', - medium: '(organic)', - campaign: '(organic)' -}; -const CAMPAIGN = { - source: 'adkernel', - medium: 'email', - campaign: 'new_campaign', - c1: '1', - c2: '2', - c3: '3', - c4: '4', - c5: '5' - -}; -describe('', function () { - let sandbox; - - before(function () { - sandbox = sinon.sandbox.create(); - }); - - after(function () { - sandbox.restore(); - analyticsAdapter.disableAnalytics(); - }); - - describe('UTM source parser', function () { - let stubSetItem; - let stubGetItem; - - before(function () { - stubSetItem = sandbox.stub(storage, 'setItem'); - stubGetItem = sandbox.stub(storage, 'getItem'); - }); - - afterEach(function () { - sandbox.reset(); - }); - - it('should parse first direct visit as (direct)', function () { - stubGetItem.withArgs('adk_dpt_analytics').returns(undefined); - stubSetItem.returns(undefined); - let source = getUmtSource('http://example.com'); - expect(source).to.be.eql(DIRECT); - }); - - it('should respect past campaign visits before direct', function () { - stubGetItem.withArgs('adk_dpt_analytics').returns(JSON.stringify(CAMPAIGN)); - stubSetItem.returns(undefined); - let source = getUmtSource('http://example.com'); - expect(source).to.be.eql(CAMPAIGN); - }); - - it('should parse visit from google as organic', function () { - stubGetItem.withArgs('adk_dpt_analytics').returns(undefined); - stubSetItem.returns(undefined); - let source = getUmtSource('http://example.com', 'https://www.google.com/search?q=pikachu'); - expect(source).to.be.eql(GOOGLE_ORGANIC); - }); - - it('should respect previous campaign visit before organic', function () { - stubGetItem.withArgs('adk_dpt_analytics').returns(JSON.stringify(CAMPAIGN)); - stubSetItem.returns(undefined); - let source = getUmtSource('http://example.com', 'https://www.google.com/search?q=pikachu'); - expect(source).to.be.eql(CAMPAIGN); - }); - - it('should parse referral visit', function () { - stubGetItem.withArgs('adk_dpt_analytics').returns(undefined); - stubSetItem.returns(undefined); - let source = getUmtSource('http://example.com', 'http://lander.com/lander.html'); - expect(source).to.be.eql(REFERRER); - }); - - it('should respect previous campaign visit before referral', function () { - stubGetItem.withArgs('adk_dpt_analytics').returns(JSON.stringify(CAMPAIGN)); - stubSetItem.returns(undefined); - let source = getUmtSource('http://example.com', 'https://www.google.com/search?q=pikachu'); - expect(source).to.be.eql(CAMPAIGN); - }); - - it('should parse referral visit from same domain as direct', function () { - stubGetItem.withArgs('adk_dpt_analytics').returns(undefined); - stubSetItem.returns(undefined); - let source = getUmtSource('http://lander.com/news.html', 'http://lander.com/lander.html'); - expect(source).to.be.eql(DIRECT); - }); - - it('should parse campaign visit', function () { - stubGetItem.withArgs('adk_dpt_analytics').returns(undefined); - stubSetItem.returns(undefined); - let source = getUmtSource('http://lander.com/index.html?utm_campaign=new_campaign&utm_source=adkernel&utm_medium=email&utm_c1=1&utm_c2=2&utm_c3=3&utm_c4=4&utm_c5=5'); - expect(source).to.be.eql(CAMPAIGN); - }); - }); - - describe('ExpiringQueue', function () { - let timer; - before(function () { - timer = sandbox.useFakeTimers(0); - }); - after(function () { - timer.restore(); - }); - - it('should notify after timeout period', (done) => { - let queue = new ExpiringQueue(() => { - let elements = queue.popAll(); - expect(elements).to.be.eql([1, 2, 3, 4]); - elements = queue.popAll(); - expect(elements).to.have.lengthOf(0); - expect(Date.now()).to.be.equal(200); - done(); - }, 100); - - queue.push(1); - setTimeout(() => { - queue.push([2, 3]); - timer.tick(50); - }, 50); - setTimeout(() => { - queue.push([4]); - timer.tick(100); - }, 100); - timer.tick(50); - }); - }); - - const REQUEST = { - bidderCode: 'adapter', - auctionId: '5018eb39-f900-4370-b71e-3bb5b48d324f', - bidderRequestId: '1a6fc81528d0f6', - bids: [{ - bidder: 'adapter', - params: {}, - adUnitCode: 'container-1', - transactionId: 'de90df62-7fd0-4fbc-8787-92d133a7dc06', - sizes: [[300, 250]], - bidId: '208750227436c1', - bidderRequestId: '1a6fc81528d0f6', - auctionId: '5018eb39-f900-4370-b71e-3bb5b48d324f' - }], - auctionStart: 1509369418387, - timeout: 3000, - start: 1509369418389 - }; - - const RESPONSE = { - bidderCode: 'adapter', - width: 300, - height: 250, - statusMessage: 'Bid available', - adId: '208750227436c1', - mediaType: 'banner', - cpm: 0.015, - ad: '', - auctionId: '5018eb39-f900-4370-b71e-3bb5b48d324f', - responseTimestamp: 1509369418832, - requestTimestamp: 1509369418389, - bidder: 'adapter', - adUnitCode: 'container-1', - timeToRespond: 443, - size: '300x250' - }; - - describe('Analytics adapter', function () { - let ajaxStub; - let timer; - - before(function () { - ajaxStub = sandbox.stub(analyticsAdapter, 'ajaxCall'); - timer = sandbox.useFakeTimers(0); - }); - - beforeEach(function () { - sandbox.stub(events, 'getEvents').callsFake(() => { - return [] - }); - }); - - afterEach(function () { - events.getEvents.restore(); - }); - - it('should be configurable', function () { - adapterManager.registerAnalyticsAdapter({ - code: 'adkernelAdn', - adapter: analyticsAdapter - }); - - adapterManager.enableAnalytics({ - provider: 'adkernelAdn', - options: { - pubId: 777, - queueTimeout: 1000 - } - }); - - expect(analyticsAdapter.context).to.have.property('host', 'tag.adkernel.com'); - expect(analyticsAdapter.context).to.have.property('pubId', 777); - }); - - it('should handle auction init event', function () { - events.emit(CONSTANTS.EVENTS.AUCTION_INIT, {config: {}, timeout: 3000}); - const ev = analyticsAdapter.context.queue.peekAll(); - expect(ev).to.have.length(1); - expect(ev[0]).to.be.eql({event: 'auctionInit'}); - }); - - it('should handle bid request event', function () { - events.emit(CONSTANTS.EVENTS.BID_REQUESTED, REQUEST); - const ev = analyticsAdapter.context.queue.peekAll(); - expect(ev).to.have.length(2); - expect(ev[1]).to.be.eql({event: 'bidRequested', adapter: 'adapter', tagid: 'container-1'}); - }); - - it('should handle bid response event', function () { - events.emit(CONSTANTS.EVENTS.BID_RESPONSE, RESPONSE); - const ev = analyticsAdapter.context.queue.peekAll(); - expect(ev).to.have.length(3); - expect(ev[2]).to.be.eql({ - event: 'bidResponse', - adapter: 'adapter', - tagid: 'container-1', - val: 0.015, - time: 0.443 - }); - }); - - it('should handle auction end event', function () { - timer.tick(447); - events.emit(CONSTANTS.EVENTS.AUCTION_END, RESPONSE); - let ev = analyticsAdapter.context.queue.peekAll(); - expect(ev).to.have.length(0); - expect(ajaxStub.calledOnce).to.be.equal(true); - ev = JSON.parse(ajaxStub.firstCall.args[0]).hb_ev; - expect(ev[3]).to.be.eql({event: 'auctionEnd', time: 0.447}); - }); - - it('should handle winning bid', function () { - events.emit(CONSTANTS.EVENTS.BID_WON, RESPONSE); - timer.tick(4500); - expect(ajaxStub.calledTwice).to.be.equal(true); - let ev = JSON.parse(ajaxStub.secondCall.args[0]).hb_ev; - expect(ev[0]).to.be.eql({event: 'bidWon', adapter: 'adapter', tagid: 'container-1', val: 0.015}); - }); - }); -}); diff --git a/test/spec/modules/adkernelAdnBidAdapter_spec.js b/test/spec/modules/adkernelAdnBidAdapter_spec.js index 277faf2a351f..98e3f6b34085 100644 --- a/test/spec/modules/adkernelAdnBidAdapter_spec.js +++ b/test/spec/modules/adkernelAdnBidAdapter_spec.js @@ -120,7 +120,7 @@ describe('AdkernelAdn adapter', function () { impid: '57d602ad1c9545', crid: '108_158802', bid: 10.0, - vast_url: 'http://vast.com/vast.xml' + vast_url: 'https://vast.com/vast.xml' }], syncpages: ['https://dsp.adkernel.com/sync'] }, usersyncOnlyResponse = { @@ -323,8 +323,8 @@ describe('AdkernelAdn adapter', function () { it('should issue a request for each host', function () { let [pbRequests, tagRequests] = buildRequest([bid1_pub1, bid1_pub2]); expect(pbRequests).to.have.length(2); - expect(pbRequests[0].url).to.have.string('//tag.adkernel.com/tag'); - expect(pbRequests[1].url).to.have.string(`//${bid1_pub2.params.host}/tag`); + expect(pbRequests[0].url).to.have.string('https://tag.adkernel.com/tag'); + expect(pbRequests[1].url).to.have.string(`https://${bid1_pub2.params.host}/tag`); expect(tagRequests[0].imp).to.have.length(1); expect(tagRequests[1].imp).to.have.length(1); }); @@ -365,7 +365,7 @@ describe('AdkernelAdn adapter', function () { expect(resp).to.have.property('currency'); expect(resp).to.have.property('ttl'); expect(resp).to.have.property('mediaType', 'video'); - expect(resp).to.have.property('vastUrl', 'http://vast.com/vast.xml'); + expect(resp).to.have.property('vastUrl', 'https://vast.com/vast.xml'); expect(resp).to.not.have.property('ad'); }); diff --git a/test/spec/modules/adkernelBidAdapter_spec.js b/test/spec/modules/adkernelBidAdapter_spec.js index 5b3d76ef0713..294aba72a6b1 100644 --- a/test/spec/modules/adkernelBidAdapter_spec.js +++ b/test/spec/modules/adkernelBidAdapter_spec.js @@ -123,7 +123,7 @@ describe('Adkernel adapter', function () { }], cur: 'USD', ext: { - adk_usersync: ['http://adk.sync.com/sync'] + adk_usersync: ['https://adk.sync.com/sync'] } }, bidResponse2 = { id: 'bid2', @@ -156,7 +156,7 @@ describe('Adkernel adapter', function () { }, usersyncOnlyResponse = { id: 'nobid1', ext: { - adk_usersync: ['http://adk.sync.com/sync'] + adk_usersync: ['https://adk.sync.com/sync'] } }; @@ -246,7 +246,7 @@ describe('Adkernel adapter', function () { it('should contain gdpr-related information if consent is configured', function () { let [_, bidRequests] = buildRequest([bid1_zone1], - buildBidderRequest('http://example.com/index.html', + buildBidderRequest('https://example.com/index.html', {gdprConsent: {gdprApplies: true, consentString: 'test-consent-string', vendorData: {}}})); let bidRequest = bidRequests[0]; expect(bidRequest).to.have.property('regs'); @@ -320,8 +320,8 @@ describe('Adkernel adapter', function () { it('should issue a request for each host', function () { let [pbRequests, _] = buildRequest([bid1_zone1, bid3_host2]); expect(pbRequests).to.have.length(2); - expect(pbRequests[0].url).to.have.string(`//${bid1_zone1.params.host}/`); - expect(pbRequests[1].url).to.have.string(`//${bid3_host2.params.host}/`); + expect(pbRequests[0].url).to.have.string(`https://${bid1_zone1.params.host}/`); + expect(pbRequests[1].url).to.have.string(`https://${bid3_host2.params.host}/`); }); it('should issue a request for each zone', function () { @@ -378,7 +378,7 @@ describe('Adkernel adapter', function () { syncs = spec.getUserSyncs({iframeEnabled: true}, [{body: bidResponse1}]); expect(syncs).to.have.length(1); expect(syncs[0]).to.have.property('type', 'iframe'); - expect(syncs[0]).to.have.property('url', 'http://adk.sync.com/sync'); + expect(syncs[0]).to.have.property('url', 'https://adk.sync.com/sync'); }); }); diff --git a/test/spec/modules/admanBidAdapter_spec.js b/test/spec/modules/admanBidAdapter_spec.js deleted file mode 100644 index 37a097427d53..000000000000 --- a/test/spec/modules/admanBidAdapter_spec.js +++ /dev/null @@ -1,215 +0,0 @@ -import {expect} from 'chai'; -import {spec} from 'modules/admanBidAdapter'; -import {newBidder} from 'src/adapters/bidderFactory'; - -const ENDPOINT = '//bidtor.admanmedia.com/prebid'; -const BANNER = '"'; -const VAST = ''; -const USER_SYNC_IFRAME_URL = '//cs.admanmedia.com/sync_tag/html'; - -describe('admanBidAdapter', function() { - const adapter = newBidder(spec); - - describe('inherited functions', function() { - it('exists and is a function', function() { - expect(adapter.callBids).to.exist.and.to.be.a('function'); - }); - }); - - describe('isBidRequestValid', function() { - let bid = { - 'bidder': 'adman', - 'params': { - 'id': '1234asdf' - }, - 'adUnitCode': 'adunit-code', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - 'creativeId': 'er2ee' - }; - - it('should return true when required params found', function() { - expect(spec.isBidRequestValid(bid)).to.equal(true); - }); - - it('should return false when id is not valid (not string)', function() { - let bid = Object.assign({}, bid); - delete bid.params; - bid.params = { - 'id': 1234 - }; - - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - - it('should return false when required params are not passed', function() { - let bid = Object.assign({}, bid); - delete bid.params; - - bid.params = {}; - - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - }); - - describe('buildRequests', function() { - let bidRequests = [ - { - 'bidder': 'adman', - 'bidId': '51ef8751f9aead', - 'params': { - 'id': '1234asdf' - }, - 'adUnitCode': 'div-gpt-ad-1460505748561-0', - 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', - 'sizes': [[320, 50], [300, 250], [300, 600]], - 'bidderRequestId': '418b37f85e772c', - 'auctionId': '18fd8b8b0bd757', - 'bidRequestsCount': 1 - } - ]; - - it('sends a valid bid request to ENDPOINT via POST', function() { - const request = spec.buildRequests(bidRequests, { - gdprConsent: { - consentString: 'BOZcQl_ObPFjWAeABAESCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NohBgA', - gdprApplies: true - } - }); - - expect(request.url).to.equal(ENDPOINT); - expect(request.method).to.equal('POST'); - - const payload = JSON.parse(request.data); - expect(payload.gdpr).to.exist; - - expect(payload.bids).to.exist.and.to.be.an('array').and.to.have.lengthOf(1); - expect(payload.referer).to.exist; - - const bid = payload.bids[0]; - expect(bid).to.exist; - expect(bid.params).to.exist; - expect(bid.params.id).to.exist; - expect(bid.params.bidId).to.exist; - expect(bid.sizes).to.exist.and.to.be.an('array').and.to.have.lengthOf(3); - bid.sizes.forEach(size => { - expect(size).to.be.an('array').and.to.have.lengthOf(2); - expect(size[0]).to.be.a('number'); - expect(size[1]).to.be.a('number'); - }) - }); - - it('should send GDPR to endpoint and honor gdprApplies value', function() { - let consentString = 'bogusConsent'; - let bidderRequest = { - 'gdprConsent': { - 'consentString': consentString, - 'gdprApplies': true - } - }; - - const request = spec.buildRequests(bidRequests, bidderRequest); - const payload = JSON.parse(request.data); - expect(payload.gdpr).to.exist; - expect(payload.gdpr.consent).to.equal(consentString); - expect(payload.gdpr.applies).to.equal(true); - - let bidderRequest2 = { - 'gdprConsent': { - 'consentString': consentString, - 'gdprApplies': false - } - }; - - const request2 = spec.buildRequests(bidRequests, bidderRequest2); - const payload2 = JSON.parse(request2.data); - - expect(payload2.gdpr).to.exist; - expect(payload2.gdpr.consent).to.equal(consentString); - expect(payload2.gdpr.applies).to.equal(false); - }); - }); - - describe('interpretResponse', function() { - let bids = { - 'body': { - 'bids': [{ - 'ad': BANNER, - 'height': 250, - 'cpm': 0.5, - 'currency': 'USD', - 'netRevenue': true, - 'requestId': '3ede2a3fa0db94', - 'ttl': 3599, - 'width': 300, - 'creativeId': 'er2ee' - }, - { - 'vastXml': VAST, - 'cpm': 0.5, - 'currency': 'USD', - 'height': 250, - 'netRevenue': true, - 'requestId': '3ede2a3fa0db95', - 'ttl': 3599, - 'width': 300, - 'creativeId': 'er2ef' - }] - } - }; - - it('should get correct bid response', function() { - let expectedResponse = [{ - 'ad': BANNER, - 'cpm': 0.5, - 'creativeId': 'er2ee', - 'currency': 'USD', - 'height': 250, - 'netRevenue': true, - 'requestId': '3ede2a3fa0db94', - 'ttl': 3599, - 'width': 300, - }, - { - 'vastXml': VAST, - 'cpm': 0.5, - 'creativeId': 'er2ef', - 'currency': 'USD', - 'height': 250, - 'netRevenue': true, - 'requestId': '3ede2a3fa0db95', - 'ttl': 3599, - 'width': 300, - }]; - // los bids vienen formateados de server - let result = spec.interpretResponse(bids); - - expect(result[0]).to.deep.equal(expectedResponse[0]); - expect(result[1]).to.deep.equal(expectedResponse[1]); - // expect(Object.keys(result[1])).to.deep.equal(Object.keys(bids[1])); - }); - - it('handles nobid responses', function() { - let bids = { - 'body': { - 'bids': [] - } - }; - - let result = spec.interpretResponse(bids); - expect(result.length).to.equal(0); - }); - }); - describe('getUserSyncs', () => { - it('should get correct user sync iframe url', function() { - expect(spec.getUserSyncs({ - iframeEnabled: true - }, [{}])).to.deep.equal([{ - type: 'iframe', - url: USER_SYNC_IFRAME_URL - }]); - }); - }); -}); diff --git a/test/spec/modules/admediaBidAdapter_spec.js b/test/spec/modules/admediaBidAdapter_spec.js index 2e14eee938c7..78228b85bfff 100644 --- a/test/spec/modules/admediaBidAdapter_spec.js +++ b/test/spec/modules/admediaBidAdapter_spec.js @@ -56,7 +56,7 @@ describe('admediaAdapterTests', function () { 'refererInfo': { 'numIframes': 0, 'reachedTop': true, - 'referer': 'http://test.com/index.html?pbjs_debug=true' + 'referer': 'https://test.com/index.html?pbjs_debug=true' } }; @@ -68,7 +68,7 @@ describe('admediaAdapterTests', function () { }); it('bidRequest url', function () { - expect(request.url).to.equal('//prebid.admedia.com/bidder/'); + expect(request.url).to.equal('https://prebid.admedia.com/bidder/'); }); it('bidRequest data', function () { diff --git a/test/spec/modules/admixerBidAdapter_spec.js b/test/spec/modules/admixerBidAdapter_spec.js deleted file mode 100644 index 54d0dbee6e46..000000000000 --- a/test/spec/modules/admixerBidAdapter_spec.js +++ /dev/null @@ -1,117 +0,0 @@ -import {expect} from 'chai'; -import {spec} from 'modules/admixerBidAdapter'; -import {newBidder} from 'src/adapters/bidderFactory'; - -const BIDDER_CODE = 'admixer'; -const ENDPOINT_URL = '//inv-nets.admixer.net/prebid.1.0.aspx'; -const ZONE_ID = '2eb6bd58-865c-47ce-af7f-a918108c3fd2'; - -describe('AdmixerAdapter', function () { - const adapter = newBidder(spec); - - describe('inherited functions', function () { - it('exists and is a function', function () { - expect(adapter.callBids).to.be.exist.and.to.be.a('function'); - }); - }); - - describe('isBidRequestValid', function () { - let bid = { - 'bidder': BIDDER_CODE, - 'params': { - 'zone': ZONE_ID - }, - 'adUnitCode': 'adunit-code', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - }; - - it('should return true when required params found', function () { - expect(spec.isBidRequestValid(bid)).to.equal(true); - }); - - it('should return false when required params are not passed', function () { - let bid = Object.assign({}, bid); - delete bid.params; - bid.params = { - 'placementId': 0 - }; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - }); - - describe('buildRequests', function () { - let bidRequests = [ - { - 'bidder': BIDDER_CODE, - 'params': { - 'zone': ZONE_ID - }, - 'adUnitCode': 'adunit-code', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - } - ]; - - it('should add referrer and imp to be equal bidRequest', function () { - const request = spec.buildRequests(bidRequests); - const payload = JSON.parse(request.data.substr(5)); - expect(payload.referrer).to.not.be.undefined; - expect(payload.imps[0]).to.deep.equal(bidRequests[0]); - }); - - it('sends bid request to ENDPOINT via GET', function () { - const request = spec.buildRequests(bidRequests); - expect(request.url).to.equal(ENDPOINT_URL); - expect(request.method).to.equal('GET'); - }); - }); - - describe('interpretResponse', function () { - let response = { - body: [{ - 'currency': 'USD', - 'cpm': 6.210000, - 'ad': '
ad
', - 'width': 300, - 'height': 600, - 'creativeId': 'ccca3e5e-0c54-4761-9667-771322fbdffc', - 'ttl': 360, - 'netRevenue': false, - 'bidId': '5e4e763b6bc60b' - }] - }; - - it('should get correct bid response', function () { - const body = response.body; - let expectedResponse = [ - { - 'requestId': body[0].bidId, - 'cpm': body[0].cpm, - 'creativeId': body[0].creativeId, - 'width': body[0].width, - 'height': body[0].height, - 'ad': body[0].ad, - 'vastUrl': undefined, - 'currency': body[0].currency, - 'netRevenue': body[0].netRevenue, - 'ttl': body[0].ttl, - } - ]; - - let result = spec.interpretResponse(response); - expect(result[0]).to.deep.equal(expectedResponse[0]); - }); - - it('handles nobid responses', function () { - let response = []; - - let result = spec.interpretResponse(response); - expect(result.length).to.equal(0); - }); - }); -}); diff --git a/test/spec/modules/adpod_spec.js b/test/spec/modules/adpod_spec.js index f8c5387b6ce5..6137d641cdfb 100644 --- a/test/spec/modules/adpod_spec.js +++ b/test/spec/modules/adpod_spec.js @@ -697,19 +697,16 @@ describe('adpod.js', function () { const customConfigObject = { 'buckets': [{ 'precision': 2, // default is 2 if omitted - means 2.1234 rounded to 2 decimal places = 2.12 - 'min': 0, 'max': 5, 'increment': 0.01 // from $0 to $5, 1-cent increments }, { 'precision': 2, - 'min': 5, 'max': 8, 'increment': 0.05 // from $5 to $8, round down to the previous 5-cent increment }, { 'precision': 2, - 'min': 8, 'max': 40, 'increment': 0.5 // from $8 to $40, round down to the previous 50-cent increment }] diff --git a/test/spec/modules/adponeBidAdapter_spec.js b/test/spec/modules/adponeBidAdapter_spec.js index da685a563945..e1535f8596be 100644 --- a/test/spec/modules/adponeBidAdapter_spec.js +++ b/test/spec/modules/adponeBidAdapter_spec.js @@ -126,11 +126,11 @@ describe('interpretResponse', function () { id: '613673EF-A07C-4486-8EE9-3FC71A7DC73D', impid: '2579e20c0bb89_0', price: 1, - adm: '
', + adm: '', adomain: [ 'www.addomain.com' ], - iurl: 'http://localhost11', + iurl: 'https://localhost11', crid: 'creative111', h: 250, w: 300, @@ -157,7 +157,7 @@ describe('interpretResponse', function () { expect(newResponse[0].currency).to.be.equal('USD'); expect(newResponse[0].netRevenue).to.be.equal(true); expect(newResponse[0].ttl).to.be.equal(300); - expect(newResponse[0].ad).to.be.equal(''); + expect(newResponse[0].ad).to.be.equal(''); }); it('should correctly reorder the server response', function () { @@ -173,7 +173,7 @@ describe('interpretResponse', function () { currency: 'USD', netRevenue: true, ttl: 300, - ad: '' + ad: '' }); }); diff --git a/test/spec/modules/adspiritBidAdapter_spec.js b/test/spec/modules/adspiritBidAdapter_spec.js deleted file mode 100644 index 7f9076123847..000000000000 --- a/test/spec/modules/adspiritBidAdapter_spec.js +++ /dev/null @@ -1,142 +0,0 @@ -import {expect} from 'chai'; -import {spec} from 'modules/adspiritBidAdapter'; - -describe('Adspirit adapter tests', function () { - let bidRequests, serverResponses; - - beforeEach(function () { - bidRequests = [ - // valid for adspirit - { - bidder: 'adspirit', - placementCode: 'ad-1', - params: { - placementId: '1', - host: 'test.adspirit.de' - }, - }, - // valid for xapadsmedia - { - bidder: 'xapadsmedia', - placementCode: 'ad-1', - params: { - placementId: '1' - }, - }, - // valid for connectad - { - bidder: 'connectad', - placementCode: 'ad-1', - params: { - placementId: '1' - }, - }, - // invalid 1 - { - bidder: 'adspirit', - placementCode: 'ad-1', - params: { - }, - }, - // invalid 2 - { - bidder: 'adspirit', - placementCode: 'ad-1', - params: { - host: 'test.adspirit.de' - }, - }, - // invalid 3 - { - bidder: '-', - placementCode: 'ad-1', - params: { - host: 'test.adspirit.de' - }, - } - ]; - serverResponses = [ - { - headers: {}, - body: { - cpm: 1.5, - w: 300, - h: 250, - placement_id: 1, - adm: '' - } - }, - { - headers: {}, - body: { - cpm: 0, - w: 0, - h: 0, - placement_id: 1, - adm: '' - } - }, - { - headers: {}, - body: { - cpm: 0, - w: 0, - h: 0, - placement_id: 0, - adm: '' - } - } - ] - }); - - describe('test bid request', function () { - it('with valid data 1', function () { - expect(spec.isBidRequestValid(bidRequests[0])).to.equal(true); - }); - it('with valid data 2', function () { - expect(spec.isBidRequestValid(bidRequests[1])).to.equal(true); - }); - it('with valid data 3', function () { - expect(spec.isBidRequestValid(bidRequests[2])).to.equal(true); - }); - it('with invalid data 1 (no host)', function () { - expect(spec.isBidRequestValid(bidRequests[3])).to.equal(false); - }); - it('with invalid data 2 (no placementId)', function () { - expect(spec.isBidRequestValid(bidRequests[4])).to.equal(false); - }); - it('with invalid data 3 (no bidder code)', function () { - expect(spec.isBidRequestValid(bidRequests[5])).to.equal(false); - }); - }); - - describe('test request build', function () { - it('normal', function () { - var requests = spec.buildRequests([bidRequests[0]]); - expect(requests).to.be.lengthOf(1); - }); - }); - - describe('test bid responses', function () { - it('success 1', function () { - var bids = spec.interpretResponse(serverResponses[0], {'bidRequest': bidRequests[0]}); - expect(bids).to.be.lengthOf(1); - expect(bids[0].cpm).to.equal(1.5); - expect(bids[0].width).to.equal(300); - expect(bids[0].height).to.equal(250); - expect(bids[0].ad).to.have.length.above(1); - }); - it('fail 1 (cpm=0)', function () { - var bids = spec.interpretResponse(serverResponses[1], {'bidRequest': bidRequests[0]}); - expect(bids).to.be.lengthOf(0); - }); - it('fail 2 (no response)', function () { - var bids = spec.interpretResponse([], {'bidRequest': bidRequests[0]}); - expect(bids).to.be.lengthOf(0); - }); - it('fail 3 (status fail)', function () { - var bids = spec.interpretResponse(serverResponses[2], {'bidRequest': bidRequests[0]}); - expect(bids).to.be.lengthOf(0); - }); - }); -}); diff --git a/test/spec/modules/adtelligentBidAdapter_spec.js b/test/spec/modules/adtelligentBidAdapter_spec.js deleted file mode 100644 index 28bb057dffea..000000000000 --- a/test/spec/modules/adtelligentBidAdapter_spec.js +++ /dev/null @@ -1,311 +0,0 @@ -import {expect} from 'chai'; -import {spec} from 'modules/adtelligentBidAdapter'; -import {newBidder} from 'src/adapters/bidderFactory'; - -const ENDPOINT = '//hb.adtelligent.com/auction/'; - -const DISPLAY_REQUEST = { - 'bidder': 'adtelligent', - 'params': { - 'aid': 12345 - }, - 'bidderRequestId': '7101db09af0db2', - 'auctionId': '2e41f65424c87c', - 'adUnitCode': 'adunit-code', - 'bidId': '84ab500420319d', - 'sizes': [300, 250] -}; - -const VIDEO_REQUEST = { - 'bidder': 'adtelligent', - 'mediaTypes': { - 'video': {} - }, - 'params': { - 'aid': 12345 - }, - 'bidderRequestId': '7101db09af0db2', - 'auctionId': '2e41f65424c87c', - 'adUnitCode': 'adunit-code', - 'bidId': '84ab500420319d', - 'sizes': [[480, 360], [640, 480]] -}; - -const SERVER_VIDEO_RESPONSE = { - 'source': {'aid': 12345, 'pubId': 54321}, - 'bids': [{ - 'vastUrl': 'http://rtb.adtelligent.com/vast/?adid=44F2AEB9BFC881B3', - 'requestId': '2e41f65424c87c', - 'url': '44F2AEB9BFC881B3', - 'creative_id': 342516, - 'cmpId': 342516, - 'height': 480, - 'cur': 'USD', - 'width': 640, - 'cpm': 0.9 - } - ] -}; - -const SERVER_DISPLAY_RESPONSE = { - 'source': {'aid': 12345, 'pubId': 54321}, - 'bids': [{ - 'ad': '', - 'requestId': '2e41f65424c87c', - 'creative_id': 342516, - 'cmpId': 342516, - 'height': 250, - 'cur': 'USD', - 'width': 300, - 'cpm': 0.9 - }], - 'cookieURLs': ['link1', 'link2'] -}; -const SERVER_DISPLAY_RESPONSE_WITH_MIXED_SYNCS = { - 'source': {'aid': 12345, 'pubId': 54321}, - 'bids': [{ - 'ad': '', - 'requestId': '2e41f65424c87c', - 'creative_id': 342516, - 'cmpId': 342516, - 'height': 250, - 'cur': 'USD', - 'width': 300, - 'cpm': 0.9 - }], - 'cookieURLs': ['link1', 'link2'], - 'cookieURLSTypes': ['image', 'iframe'] -}; - -const videoBidderRequest = { - bidderCode: 'bidderCode', - bids: [{mediaTypes: {video: {}}, bidId: '2e41f65424c87c'}] -}; - -const displayBidderRequest = { - bidderCode: 'bidderCode', - bids: [{bidId: '2e41f65424c87c'}] -}; - -const displayBidderRequestWithGdpr = { - bidderCode: 'bidderCode', - bids: [{bidId: '2e41f65424c87c'}], - gdprConsent: { - gdprApplies: true, - consentString: 'test' - } -}; - -const videoEqResponse = [{ - vastUrl: 'http://rtb.adtelligent.com/vast/?adid=44F2AEB9BFC881B3', - requestId: '2e41f65424c87c', - creativeId: 342516, - mediaType: 'video', - netRevenue: true, - currency: 'USD', - height: 480, - width: 640, - ttl: 3600, - cpm: 0.9 -}]; - -const displayEqResponse = [{ - requestId: '2e41f65424c87c', - creativeId: 342516, - mediaType: 'display', - netRevenue: true, - currency: 'USD', - ad: '', - height: 250, - width: 300, - ttl: 3600, - cpm: 0.9 -}]; - -describe('adtelligentBidAdapter', function () { // todo remove only - const adapter = newBidder(spec); - - describe('user syncs as image', function () { - it('should be returned if pixel enabled', function () { - const syncs = spec.getUserSyncs({pixelEnabled: true}, [{body: SERVER_DISPLAY_RESPONSE_WITH_MIXED_SYNCS}]); - - expect(syncs.map(s => s.url)).to.deep.equal([SERVER_DISPLAY_RESPONSE_WITH_MIXED_SYNCS.cookieURLs[0]]); - expect(syncs.map(s => s.type)).to.deep.equal(['image']); - }) - }) - - describe('user syncs as iframe', function () { - it('should be returned if iframe enabled', function () { - const syncs = spec.getUserSyncs({iframeEnabled: true}, [{body: SERVER_DISPLAY_RESPONSE_WITH_MIXED_SYNCS}]); - - expect(syncs.map(s => s.url)).to.deep.equal([SERVER_DISPLAY_RESPONSE_WITH_MIXED_SYNCS.cookieURLs[1]]); - expect(syncs.map(s => s.type)).to.deep.equal(['iframe']); - }) - }) - - describe('user syncs with both types', function () { - it('should be returned if pixel and iframe enabled', function () { - const syncs = spec.getUserSyncs({ - iframeEnabled: true, - pixelEnabled: true - }, [{body: SERVER_DISPLAY_RESPONSE_WITH_MIXED_SYNCS}]); - - expect(syncs.map(s => s.url)).to.deep.equal(SERVER_DISPLAY_RESPONSE_WITH_MIXED_SYNCS.cookieURLs); - expect(syncs.map(s => s.type)).to.deep.equal(SERVER_DISPLAY_RESPONSE_WITH_MIXED_SYNCS.cookieURLSTypes); - }) - }) - - describe('user syncs', function () { - it('should not be returned if pixel not set', function () { - const syncs = spec.getUserSyncs({}, [{body: SERVER_DISPLAY_RESPONSE_WITH_MIXED_SYNCS}]); - - expect(syncs).to.be.empty; - }) - }) - - describe('inherited functions', function () { - it('exists and is a function', function () { - expect(adapter.callBids).to.exist.and.to.be.a('function'); - }); - }); - - describe('isBidRequestValid', function () { - it('should return true when required params found', function () { - expect(spec.isBidRequestValid(VIDEO_REQUEST)).to.equal(12345); - }); - - it('should return false when required params are not passed', function () { - let bid = Object.assign({}, VIDEO_REQUEST); - delete bid.params; - expect(spec.isBidRequestValid(bid)).to.equal(undefined); - }); - }); - - describe('buildRequests', function () { - let videoBidRequests = [VIDEO_REQUEST]; - let displayBidRequests = [DISPLAY_REQUEST]; - let videoAndDisplayBidRequests = [DISPLAY_REQUEST, VIDEO_REQUEST]; - - const displayRequest = spec.buildRequests(displayBidRequests, {}); - const videoRequest = spec.buildRequests(videoBidRequests, {}); - const videoAndDisplayRequests = spec.buildRequests(videoAndDisplayBidRequests, {}); - - it('sends bid request to ENDPOINT via GET', function () { - expect(videoRequest.method).to.equal('GET'); - expect(displayRequest.method).to.equal('GET'); - expect(videoAndDisplayRequests.method).to.equal('GET'); - }); - - it('sends bid request to correct ENDPOINT', function () { - expect(videoRequest.url).to.equal(ENDPOINT); - expect(displayRequest.url).to.equal(ENDPOINT); - expect(videoAndDisplayRequests.url).to.equal(ENDPOINT); - }); - - it('sends correct video bid parameters', function () { - const bid = Object.assign({}, videoRequest.data); - delete bid.domain; - - const eq = { - callbackId: '84ab500420319d', - ad_type: 'video', - aid: 12345, - sizes: '480x360,640x480' - }; - - expect(bid).to.deep.equal(eq); - }); - - it('sends correct display bid parameters', function () { - const bid = Object.assign({}, displayRequest.data); - delete bid.domain; - - const eq = { - callbackId: '84ab500420319d', - ad_type: 'display', - aid: 12345, - sizes: '300x250' - }; - - expect(bid).to.deep.equal(eq); - }); - - it('sends correct video and display bid parameters', function () { - const bid = Object.assign({}, videoAndDisplayRequests.data); - delete bid.domain; - - const eq = { - callbackId: '84ab500420319d', - ad_type: 'display', - aid: 12345, - sizes: '300x250', - callbackId2: '84ab500420319d', - ad_type2: 'video', - aid2: 12345, - sizes2: '480x360,640x480' - }; - - expect(bid).to.deep.equal(eq); - }); - }); - - describe('interpretResponse', function () { - let serverResponse; - let bidderRequest; - let eqResponse; - - afterEach(function () { - serverResponse = null; - bidderRequest = null; - eqResponse = null; - }); - - it('should get correct video bid response', function () { - serverResponse = SERVER_VIDEO_RESPONSE; - bidderRequest = videoBidderRequest; - eqResponse = videoEqResponse; - - bidServerResponseCheck(); - }); - - it('should get correct display bid response', function () { - serverResponse = SERVER_DISPLAY_RESPONSE; - bidderRequest = displayBidderRequest; - eqResponse = displayEqResponse; - - bidServerResponseCheck(); - }); - - it('should set gdpr data correctly', function () { - const builtRequestData = spec.buildRequests([DISPLAY_REQUEST], displayBidderRequestWithGdpr); - - expect(builtRequestData.data.gdpr).to.be.equal(1); - expect(builtRequestData.data.gdpr_consent).to.be.equal(displayBidderRequestWithGdpr.gdprConsent.consentString); - }); - - function bidServerResponseCheck() { - const result = spec.interpretResponse({body: serverResponse}, {bidderRequest}); - - expect(result).to.deep.equal(eqResponse); - } - - function nobidServerResponseCheck() { - const noBidServerResponse = {bids: []}; - const noBidResult = spec.interpretResponse({body: noBidServerResponse}, {bidderRequest}); - - expect(noBidResult.length).to.equal(0); - } - - it('handles video nobid responses', function () { - bidderRequest = videoBidderRequest; - - nobidServerResponseCheck(); - }); - - it('handles display nobid responses', function () { - bidderRequest = displayBidderRequest; - - nobidServerResponseCheck(); - }); - }); -}); diff --git a/test/spec/modules/aduptechBidAdapter_spec.js b/test/spec/modules/aduptechBidAdapter_spec.js deleted file mode 100644 index da0b603ebfcc..000000000000 --- a/test/spec/modules/aduptechBidAdapter_spec.js +++ /dev/null @@ -1,261 +0,0 @@ -import { expect } from 'chai'; -import { BIDDER_CODE, PUBLISHER_PLACEHOLDER, ENDPOINT_URL, ENDPOINT_METHOD, spec } from 'modules/aduptechBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; -import * as utils from 'src/utils'; - -describe('AduptechBidAdapter', function () { - const adapter = newBidder(spec); - - describe('inherited functions', function () { - it('exists and is a function', function () { - expect(adapter.callBids).to.exist.and.to.be.a('function'); - }); - }); - - describe('isBidRequestValid', function () { - it('should return true when necessary information is given', function () { - expect(spec.isBidRequestValid({ - sizes: [[100, 200]], - params: { - publisher: 'test', - placement: '1234' - } - })).to.be.true; - }); - - it('should return false on empty bid', function () { - expect(spec.isBidRequestValid({})).to.be.false; - }); - - it('should return false on missing sizes', function () { - expect(spec.isBidRequestValid({ - params: { - publisher: 'test', - placement: '1234' - } - })).to.be.false; - }); - - it('should return false on empty sizes', function () { - expect(spec.isBidRequestValid({ - sizes: [], - params: { - publisher: 'test', - placement: '1234' - } - })).to.be.false; - }); - - it('should return false on missing params', function () { - expect(spec.isBidRequestValid({ - sizes: [[100, 200]], - })).to.be.false; - }); - - it('should return false on invalid params', function () { - expect(spec.isBidRequestValid({ - sizes: [[100, 200]], - params: 'bar' - })).to.be.false; - }); - - it('should return false on empty params', function () { - expect(spec.isBidRequestValid({ - sizes: [[100, 200]], - params: {} - })).to.be.false; - }); - - it('should return false on missing publisher', function () { - expect(spec.isBidRequestValid({ - sizes: [[100, 200]], - params: { - placement: '1234' - } - })).to.be.false; - }); - - it('should return false on missing placement', function () { - expect(spec.isBidRequestValid({ - sizes: [[100, 200]], - params: { - publisher: 'test' - } - })).to.be.false; - }); - }); - - describe('buildRequests', function () { - it('should send one bid request per ad unit to the endpoint via POST', function () { - const bidRequests = [ - { - bidder: BIDDER_CODE, - bidId: 'bidId1', - adUnitCode: 'adUnitCode1', - transactionId: 'transactionId1', - auctionId: 'auctionId1', - sizes: [[100, 200], [300, 400]], - params: { - publisher: 'publisher1', - placement: 'placement1' - } - }, - { - bidder: BIDDER_CODE, - bidId: 'bidId2', - adUnitCode: 'adUnitCode2', - transactionId: 'transactionId2', - auctionId: 'auctionId2', - sizes: [[500, 600]], - params: { - publisher: 'publisher2', - placement: 'placement2' - } - } - ]; - - const result = spec.buildRequests(bidRequests); - expect(result.length).to.equal(2); - - expect(result[0].url).to.equal(ENDPOINT_URL.replace(PUBLISHER_PLACEHOLDER, bidRequests[0].params.publisher)); - expect(result[0].method).to.equal(ENDPOINT_METHOD); - expect(result[0].data).to.deep.equal({ - pageUrl: utils.getTopWindowUrl(), - referrer: utils.getTopWindowReferrer(), - bidId: bidRequests[0].bidId, - auctionId: bidRequests[0].auctionId, - transactionId: bidRequests[0].transactionId, - adUnitCode: bidRequests[0].adUnitCode, - sizes: bidRequests[0].sizes, - params: bidRequests[0].params, - gdpr: null - }); - - expect(result[1].url).to.equal(ENDPOINT_URL.replace(PUBLISHER_PLACEHOLDER, bidRequests[1].params.publisher)); - expect(result[1].method).to.equal(ENDPOINT_METHOD); - expect(result[1].data).to.deep.equal({ - pageUrl: utils.getTopWindowUrl(), - referrer: utils.getTopWindowReferrer(), - bidId: bidRequests[1].bidId, - auctionId: bidRequests[1].auctionId, - transactionId: bidRequests[1].transactionId, - adUnitCode: bidRequests[1].adUnitCode, - sizes: bidRequests[1].sizes, - params: bidRequests[1].params, - gdpr: null - }); - }); - - it('should pass gdpr informations', function () { - const bidderRequest = { - gdprConsent: { - consentString: 'consentString', - gdprApplies: true - } - }; - const bidRequests = [ - { - bidder: BIDDER_CODE, - bidId: 'bidId3', - adUnitCode: 'adUnitCode3', - transactionId: 'transactionId3', - auctionId: 'auctionId3', - sizes: [[100, 200], [300, 400]], - params: { - publisher: 'publisher3', - placement: 'placement3' - } - } - ]; - - const result = spec.buildRequests(bidRequests, bidderRequest); - expect(result.length).to.equal(1); - expect(result[0].data.gdpr).to.exist; - expect(result[0].data.gdpr.consentRequired).to.exist.and.to.equal(bidderRequest.gdprConsent.gdprApplies); - expect(result[0].data.gdpr.consentString).to.exist.and.to.equal(bidderRequest.gdprConsent.consentString); - }); - - it('should encode publisher param in endpoint url', function () { - const bidRequests = [ - { - bidder: BIDDER_CODE, - bidId: 'bidId1', - adUnitCode: 'adUnitCode1', - transactionId: 'transactionId1', - auctionId: 'auctionId1', - sizes: [[100, 200]], - params: { - publisher: 'crazy publisher key äÖÜ', - placement: 'placement1' - } - }, - ]; - - const result = spec.buildRequests(bidRequests); - - expect(result[0].url).to.equal(ENDPOINT_URL.replace(PUBLISHER_PLACEHOLDER, encodeURIComponent(bidRequests[0].params.publisher))); - }); - - it('should handle empty bidRequests', function () { - expect(spec.buildRequests([])).to.deep.equal([]); - }); - }); - - describe('interpretResponse', function () { - it('should correctly interpret the server response', function () { - const serverResponse = { - body: { - bid: { - bidId: 'bidId1', - price: 0.12, - net: true, - currency: 'EUR', - ttl: 123 - }, - creative: { - id: 'creativeId1', - width: 100, - height: 200, - html: '
Hello World
' - } - } - }; - - const result = spec.interpretResponse(serverResponse); - - expect(result).to.deep.equal([ - { - requestId: serverResponse.body.bid.bidId, - cpm: serverResponse.body.bid.price, - netRevenue: serverResponse.body.bid.net, - currency: serverResponse.body.bid.currency, - ttl: serverResponse.body.bid.ttl, - creativeId: serverResponse.body.creative.id, - width: serverResponse.body.creative.width, - height: serverResponse.body.creative.height, - ad: serverResponse.body.creative.html - } - ]); - }); - - it('should handle empty serverResponse', function () { - expect(spec.interpretResponse({})).to.deep.equal([]); - }); - - it('should handle missing bid', function () { - expect(spec.interpretResponse({ - body: { - creative: {} - } - })).to.deep.equal([]); - }); - - it('should handle missing creative', function () { - expect(spec.interpretResponse({ - body: { - bid: {} - } - })).to.deep.equal([]); - }); - }); -}); diff --git a/test/spec/modules/advenueBidAdapter_spec.js b/test/spec/modules/advenueBidAdapter_spec.js index f6ffb277bf91..f00b9a9f6805 100644 --- a/test/spec/modules/advenueBidAdapter_spec.js +++ b/test/spec/modules/advenueBidAdapter_spec.js @@ -38,7 +38,7 @@ describe('AdvenueAdapter', function () { expect(serverRequest.method).to.equal('POST'); }); it('Returns valid URL', function () { - expect(serverRequest.url).to.equal('//ssp.advenuemedia.co.uk/?c=o&m=multi'); + expect(serverRequest.url).to.equal('https://ssp.advenuemedia.co.uk/?c=o&m=multi'); }); it('Returns valid data if array of bids is valid', function () { let data = serverRequest.data; diff --git a/test/spec/modules/adyoulikeBidAdapter_spec.js b/test/spec/modules/adyoulikeBidAdapter_spec.js index 7edb9416b038..a76468671c8f 100644 --- a/test/spec/modules/adyoulikeBidAdapter_spec.js +++ b/test/spec/modules/adyoulikeBidAdapter_spec.js @@ -5,7 +5,7 @@ import { spec } from 'modules/adyoulikeBidAdapter'; import { newBidder } from 'src/adapters/bidderFactory'; describe('Adyoulike Adapter', function () { - const canonicalUrl = 'http://canonical.url/?t=%26'; + const canonicalUrl = 'https://canonical.url/?t=%26'; const defaultDC = 'hb-api'; const bidRequestWithEmptyPlacement = [ { diff --git a/test/spec/modules/ajaBidAdapter_spec.js b/test/spec/modules/ajaBidAdapter_spec.js index 642ac2f0df4e..4b78711f46fb 100644 --- a/test/spec/modules/ajaBidAdapter_spec.js +++ b/test/spec/modules/ajaBidAdapter_spec.js @@ -1,7 +1,7 @@ import { spec } from 'modules/ajaBidAdapter'; import { newBidder } from 'src/adapters/bidderFactory'; -const ENDPOINT = '//ad.as.amanad.adtdp.com/v2/prebid'; +const ENDPOINT = 'https://ad.as.amanad.adtdp.com/v2/prebid'; describe('AjaAdapter', function () { const adapter = newBidder(spec); @@ -50,7 +50,7 @@ describe('AjaAdapter', function () { let bidderRequest = { refererInfo: { - referer: 'http://hoge.com' + referer: 'https://hoge.com' } }; @@ -58,7 +58,7 @@ describe('AjaAdapter', function () { const requests = spec.buildRequests(bidRequests, bidderRequest); expect(requests[0].url).to.equal(ENDPOINT); expect(requests[0].method).to.equal('GET'); - expect(requests[0].data).to.equal('asi=123456&skt=5&prebid_id=30b31c1838de1e&prebid_ver=$prebid.version$&page_url=http%3A%2F%2Fhoge.com&'); + expect(requests[0].data).to.equal('asi=123456&skt=5&prebid_id=30b31c1838de1e&prebid_ver=$prebid.version$&page_url=https%3A%2F%2Fhoge.com&'); }); }); @@ -77,7 +77,7 @@ describe('AjaAdapter', function () { 'h': 250, 'tag': '
', 'imps': [ - '//as.amanad.adtdp.com/v1/imp' + 'https://as.amanad.adtdp.com/v1/imp' ] } }, @@ -120,7 +120,7 @@ describe('AjaAdapter', function () { 'w': 300, 'h': 250, 'vtag': '', - 'purl': 'http://cdn/player', + 'purl': 'https://cdn/player', 'progress': true, 'loop': false, 'inread': false diff --git a/test/spec/modules/andbeyondBidAdapter_spec.js b/test/spec/modules/andbeyondBidAdapter_spec.js deleted file mode 100644 index f9b0758749b8..000000000000 --- a/test/spec/modules/andbeyondBidAdapter_spec.js +++ /dev/null @@ -1,208 +0,0 @@ -import {expect} from 'chai'; -import {spec} from 'modules/andbeyondBidAdapter'; -import * as utils from 'src/utils'; - -describe('andbeyond adapter', function () { - const bid1_zone1 = { - bidder: 'andbeyond', - bidId: 'Bid_01', - params: {zoneId: 1, host: 'rtb.andbeyond.com'}, - placementCode: 'ad-unit-1', - sizes: [[300, 250], [300, 200]] - }, bid2_zone2 = { - bidder: 'andbeyond', - bidId: 'Bid_02', - params: {zoneId: 2, host: 'rtb.andbeyond.com'}, - placementCode: 'ad-unit-2', - sizes: [[728, 90]] - }, bid3_host2 = { - bidder: 'andbeyond', - bidId: 'Bid_02', - params: {zoneId: 1, host: 'rtb-private.andbeyond.com'}, - placementCode: 'ad-unit-2', - sizes: [[728, 90]] - }, bid_without_zone = { - bidder: 'andbeyond', - bidId: 'Bid_W', - params: {host: 'rtb-private.andbeyond.com'}, - placementCode: 'ad-unit-1', - sizes: [[728, 90]] - }, bid_without_host = { - bidder: 'andbeyond', - bidId: 'Bid_W', - params: {zoneId: 1}, - placementCode: 'ad-unit-1', - sizes: [[728, 90]] - }, bid_with_wrong_zoneId = { - bidder: 'andbeyond', - bidId: 'Bid_02', - params: {zoneId: 'wrong id', host: 'rtb.andbeyond.com'}, - placementCode: 'ad-unit-2', - sizes: [[728, 90]] - }, usersyncOnlyResponse = { - id: 'nobid1', - ext: { - adk_usersync: ['http://adk.sync.com/sync'] - } - }; - - const bidResponse1 = { - id: 'bid1', - seatbid: [{ - bid: [{ - id: '1', - impid: 'Bid_01', - crid: '100_001', - price: 3.01, - nurl: 'https://rtb.com/win?i=ZjKoPYSFI3Y_0', - adm: '', - w: 300, - h: 250 - }] - }], - cur: 'USD', - ext: { - adk_usersync: ['http://adk.sync.com/sync'] - } - }, bidResponse2 = { - id: 'bid2', - seatbid: [{ - bid: [{ - id: '2', - impid: 'Bid_02', - crid: '100_002', - price: 1.31, - adm: '', - w: 300, - h: 250 - }] - }], - cur: 'USD' - }; - - describe('input parameters validation', function () { - it('empty request shouldn\'t generate exception', function () { - expect(spec.isBidRequestValid({ - bidderCode: 'andbeyond' - })).to.be.equal(false); - }); - - it('request without zone shouldn\'t issue a request', function () { - expect(spec.isBidRequestValid(bid_without_zone)).to.be.equal(false); - }); - - it('request without host shouldn\'t issue a request', function () { - expect(spec.isBidRequestValid(bid_without_host)).to.be.equal(false); - }); - - it('empty request shouldn\'t generate exception', function () { - expect(spec.isBidRequestValid(bid_with_wrong_zoneId)).to.be.equal(false); - }); - }); - - describe('banner request building', function () { - let bidRequest; - before(function () { - let wmock = sinon.stub(utils, 'getTopWindowLocation').callsFake(() => ({ - protocol: 'https:', - hostname: 'example.com', - host: 'example.com', - pathname: '/index.html', - href: 'https://example.com/index.html' - })); - let dntmock = sinon.stub(utils, 'getDNT').callsFake(() => true); - let request = spec.buildRequests([bid1_zone1])[0]; - bidRequest = JSON.parse(request.data.r); - wmock.restore(); - dntmock.restore(); - }); - - it('should be a first-price auction', function () { - expect(bidRequest).to.have.property('at', 1); - }); - - it('should have banner object', function () { - expect(bidRequest.imp[0]).to.have.property('banner'); - }); - - it('should have w/h', function () { - expect(bidRequest.imp[0].banner).to.have.property('format'); - expect(bidRequest.imp[0].banner.format).to.be.eql([{w: 300, h: 250}, {w: 300, h: 200}]); - }); - - it('should respect secure connection', function () { - expect(bidRequest.imp[0]).to.have.property('secure', 1); - }); - - it('should have tagid', function () { - expect(bidRequest.imp[0]).to.have.property('tagid', 'ad-unit-1'); - }); - - it('should create proper site block', function () { - expect(bidRequest.site).to.have.property('domain', 'example.com'); - expect(bidRequest.site).to.have.property('page', 'https://example.com/index.html'); - }); - - it('should fill device with caller macro', function () { - expect(bidRequest).to.have.property('device'); - expect(bidRequest.device).to.have.property('ip', 'caller'); - expect(bidRequest.device).to.have.property('ua', 'caller'); - expect(bidRequest.device).to.have.property('dnt', 1); - }); - }); - - describe('requests routing', function () { - it('should issue a request for each host', function () { - let pbRequests = spec.buildRequests([bid1_zone1, bid3_host2]); - expect(pbRequests).to.have.length(2); - expect(pbRequests[0].url).to.have.string(`//${bid1_zone1.params.host}/`); - expect(pbRequests[1].url).to.have.string(`//${bid3_host2.params.host}/`); - }); - - it('should issue a request for each zone', function () { - let pbRequests = spec.buildRequests([bid1_zone1, bid2_zone2]); - expect(pbRequests).to.have.length(2); - expect(pbRequests[0].data.zone).to.be.equal(bid1_zone1.params.zoneId); - expect(pbRequests[1].data.zone).to.be.equal(bid2_zone2.params.zoneId); - }); - }); - - describe('responses processing', function () { - it('should return fully-initialized banner bid-response', function () { - let request = spec.buildRequests([bid1_zone1])[0]; - let resp = spec.interpretResponse({body: bidResponse1}, request)[0]; - expect(resp).to.have.property('requestId', 'Bid_01'); - expect(resp).to.have.property('cpm', 3.01); - expect(resp).to.have.property('width', 300); - expect(resp).to.have.property('height', 250); - expect(resp).to.have.property('creativeId', '100_001'); - expect(resp).to.have.property('currency'); - expect(resp).to.have.property('ttl'); - expect(resp).to.have.property('mediaType', 'banner'); - expect(resp).to.have.property('ad'); - expect(resp.ad).to.have.string(''); - }); - - it('should add nurl as pixel for banner response', function () { - let request = spec.buildRequests([bid1_zone1])[0]; - let resp = spec.interpretResponse({body: bidResponse1}, request)[0]; - let expectedNurl = bidResponse1.seatbid[0].bid[0].nurl + '&px=1'; - expect(resp.ad).to.have.string(expectedNurl); - }); - - it('should handle bidresponse with user-sync only', function () { - let request = spec.buildRequests([bid1_zone1])[0]; - let resp = spec.interpretResponse({body: usersyncOnlyResponse}, request); - expect(resp).to.have.length(0); - }); - - it('should perform usersync', function () { - let syncs = spec.getUserSyncs({iframeEnabled: false}, [{body: bidResponse1}]); - expect(syncs).to.have.length(0); - syncs = spec.getUserSyncs({iframeEnabled: true}, [{body: bidResponse1}]); - expect(syncs).to.have.length(1); - expect(syncs[0]).to.have.property('type', 'iframe'); - expect(syncs[0]).to.have.property('url', 'http://adk.sync.com/sync'); - }); - }); -}); diff --git a/test/spec/modules/aniviewBidAdapter_spec.js b/test/spec/modules/aniviewBidAdapter_spec.js deleted file mode 100644 index ce8a34509c4b..000000000000 --- a/test/spec/modules/aniviewBidAdapter_spec.js +++ /dev/null @@ -1,183 +0,0 @@ -import { spec } from 'modules/aniviewBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; -const { expect } = require('chai'); - -describe('ANIVIEW Bid Adapter Test', function () { - const adapter = newBidder(spec); - - describe('inherited functions', function () { - it('exists and is a function', function () { - expect(adapter.callBids).to.exist.and.to.be.a('function'); - }); - }); - - describe('isBidRequestValid', function () { - let bid = { - 'bidder': 'aniview', - 'params': { - 'AV_PUBLISHERID': '123456', - 'AV_CHANNELID': '123456' - }, - 'adUnitCode': 'video1', - 'sizes': [[300, 250], [640, 480]], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'requestId': 'a09c66c3-53e3-4428-b296-38fc08e7cd2a', - 'transactionId': 'd6f6b392-54a9-454c-85fb-a2fd882c4a2d', - }; - - it('should return true when required params found', function () { - expect(spec.isBidRequestValid(bid)).to.equal(true); - }); - - it('should return false when required params are not passed', function () { - let bid = Object.assign({}, bid); - delete bid.params; - bid.params = { - something: 'is wrong' - }; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - }); - - describe('buildRequests', function () { - const ENDPOINT = 'https://v.lkqd.net/ad'; - let bid2Requests = [ - { - 'bidder': 'aniview', - 'params': { - 'AV_PUBLISHERID': '123456', - 'AV_CHANNELID': '123456' - }, - 'adUnitCode': 'test1', - 'sizes': [[300, 250], [640, 480]], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'requestId': 'a09c66c3-53e3-4428-b296-38fc08e7cd2a', - 'transactionId': 'd6f6b392-54a9-454c-85fb-a2fd882c4a2d', - } - ]; - let bid1Request = [ - { - 'bidder': 'aniview', - 'params': { - 'AV_PUBLISHERID': '123456', - 'AV_CHANNELID': '123456' - }, - 'adUnitCode': 'test1', - 'sizes': [640, 480], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'requestId': 'a09c66c3-53e3-4428-b296-38fc08e7cd2a', - 'transactionId': 'd6f6b392-54a9-454c-85fb-a2fd882c4a2d', - } - ]; - - it('Test 2 requests', function () { - const requests = spec.buildRequests(bid2Requests); - expect(requests.length).to.equal(2); - const r1 = requests[0]; - const d1 = requests[0].data; - expect(d1).to.have.property('AV_PUBLISHERID'); - expect(d1.AV_PUBLISHERID).to.equal('123456'); - expect(d1).to.have.property('AV_CHANNELID'); - expect(d1.AV_CHANNELID).to.equal('123456'); - expect(d1).to.have.property('AV_WIDTH'); - expect(d1.AV_WIDTH).to.equal(300); - expect(d1).to.have.property('AV_HEIGHT'); - expect(d1.AV_HEIGHT).to.equal(250); - expect(d1).to.have.property('AV_URL'); - expect(d1).to.have.property('cb'); - expect(d1).to.have.property('s2s'); - expect(d1.s2s).to.equal('1'); - expect(d1).to.have.property('pbjs'); - expect(d1.pbjs).to.equal(1); - expect(r1).to.have.property('url'); - expect(r1.url).to.contain('https://gov.aniview.com/api/adserver/vast3/'); - const r2 = requests[1]; - const d2 = requests[1].data; - expect(d2).to.have.property('AV_PUBLISHERID'); - expect(d2.AV_PUBLISHERID).to.equal('123456'); - expect(d2).to.have.property('AV_CHANNELID'); - expect(d2.AV_CHANNELID).to.equal('123456'); - expect(d2).to.have.property('AV_WIDTH'); - expect(d2.AV_WIDTH).to.equal(640); - expect(d2).to.have.property('AV_HEIGHT'); - expect(d2.AV_HEIGHT).to.equal(480); - expect(d2).to.have.property('AV_URL'); - expect(d2).to.have.property('cb'); - expect(d2).to.have.property('s2s'); - expect(d2.s2s).to.equal('1'); - expect(d2).to.have.property('pbjs'); - expect(d2.pbjs).to.equal(1); - expect(r2).to.have.property('url'); - expect(r2.url).to.contain('https://gov.aniview.com/api/adserver/vast3/'); - }); - - it('Test 1 request', function () { - const requests = spec.buildRequests(bid1Request); - expect(requests.length).to.equal(1); - const r = requests[0]; - const d = requests[0].data; - expect(d).to.have.property('AV_PUBLISHERID'); - expect(d.AV_PUBLISHERID).to.equal('123456'); - expect(d).to.have.property('AV_CHANNELID'); - expect(d.AV_CHANNELID).to.equal('123456'); - expect(d).to.have.property('AV_WIDTH'); - expect(d.AV_WIDTH).to.equal(640); - expect(d).to.have.property('AV_HEIGHT'); - expect(d.AV_HEIGHT).to.equal(480); - expect(d).to.have.property('AV_URL'); - expect(d).to.have.property('cb'); - expect(d).to.have.property('s2s'); - expect(d.s2s).to.equal('1'); - expect(d).to.have.property('pbjs'); - expect(d.pbjs).to.equal(1); - expect(r).to.have.property('url'); - expect(r.url).to.contain('https://gov.aniview.com/api/adserver/vast3/'); - }); - }); - - describe('interpretResponse', function () { - let bidRequest = { - 'url': 'https://gov.aniview.com/api/adserver/vast3/', - 'data': { - 'bidId': '253dcb69fb2577', - AV_PUBLISHERID: '55b78633181f4603178b4568', - AV_CHANNELID: '55b7904d181f46410f8b4568', - } - }; - let serverResponse = {}; - serverResponse.body = 'FORDFORD00:00:15'; - - it('Check bid interpretResponse', function () { - const BIDDER_CODE = 'aniview'; - let bidResponses = spec.interpretResponse(serverResponse, bidRequest); - expect(bidResponses.length).to.equal(1); - let bidResponse = bidResponses[0]; - expect(bidResponse.requestId).to.equal(bidRequest.data.bidId); - expect(bidResponse.bidderCode).to.equal(BIDDER_CODE); - expect(bidResponse.cpm).to.equal('2'); - expect(bidResponse.ttl).to.equal(600); - expect(bidResponse.currency).to.equal('USD'); - expect(bidResponse.netRevenue).to.equal(true); - expect(bidResponse.mediaType).to.equal('video'); - }); - - it('safely handles XML parsing failure from invalid bid response', function () { - let invalidServerResponse = {}; - invalidServerResponse.body = ''; - - let result = spec.interpretResponse(invalidServerResponse, bidRequest); - expect(result.length).to.equal(0); - }); - - it('handles nobid responses', function () { - let nobidResponse = {}; - nobidResponse.body = ''; - - let result = spec.interpretResponse(nobidResponse, bidRequest); - expect(result.length).to.equal(0); - }); - }); -}); diff --git a/test/spec/modules/aolBidAdapter_spec.js b/test/spec/modules/aolBidAdapter_spec.js index 0f99901bce41..dd624222d69f 100644 --- a/test/spec/modules/aolBidAdapter_spec.js +++ b/test/spec/modules/aolBidAdapter_spec.js @@ -227,11 +227,11 @@ describe('AolAdapter', function () { params: { placement: 1234567, network: '9599.1', - server: 'http://adserver-eu.adtech.advertising.com' + server: 'https://adserver-eu.adtech.advertising.com' } }); let [request] = spec.buildRequests(bidRequest.bids); - expect(request.url.indexOf('http://adserver-eu.adtech.advertising.com/pubapi/3.0/')) + expect(request.url.indexOf('https://adserver-eu.adtech.advertising.com/pubapi/3.0/')) .to.equal(0); }); @@ -240,7 +240,7 @@ describe('AolAdapter', function () { params: { placement: 1234567, network: '9599.1', - server: '//adserver-eu.adtech.advertising.com' + server: 'https://adserver-eu.adtech.advertising.com' } }); let [request] = spec.buildRequests(bidRequest.bids); @@ -386,13 +386,13 @@ describe('AolAdapter', function () { it('should return One Mobile url with different host when host option is present', function () { let bidParams = Object.assign({ - host: 'http://qa-hb.nexage.com' + host: 'https://qa-hb.nexage.com' }, getNexageGetBidParams()); let bidRequest = createCustomBidRequest({ params: bidParams }); let [request] = spec.buildRequests(bidRequest.bids); - expect(request.url).to.contain('http://qa-hb.nexage.com/bidRequest?'); + expect(request.url).to.contain('https://qa-hb.nexage.com/bidRequest?'); }); it('should return One Mobile url when One Mobile and Marketplace params are present', function () { diff --git a/test/spec/modules/appnexusBidAdapter_spec.js b/test/spec/modules/appnexusBidAdapter_spec.js index c1d307521a52..5365b0ac5297 100644 --- a/test/spec/modules/appnexusBidAdapter_spec.js +++ b/test/spec/modules/appnexusBidAdapter_spec.js @@ -6,7 +6,7 @@ import { auctionManager } from 'src/auctionManager'; import { deepClone } from 'src/utils'; import { config } from 'src/config'; -const ENDPOINT = '//ib.adnxs.com/ut/v3/prebid'; +const ENDPOINT = 'https://ib.adnxs.com/ut/v3/prebid'; describe('AppNexusAdapter', function () { const adapter = newBidder(spec); @@ -215,7 +215,7 @@ describe('AppNexusAdapter', function () { let bidRequest1 = deepClone(bidRequests[0]); bidRequest1 = Object.assign({}, bidRequest1, videoData, { renderer: { - url: 'http://test.renderer.url', + url: 'https://test.renderer.url', render: function () {} } }); @@ -656,13 +656,13 @@ describe('AppNexusAdapter', function () { const bidRequest = Object.assign({}, bidRequests[0]) const bidderRequest = { refererInfo: { - referer: 'http://example.com/page.html', + referer: 'https://example.com/page.html', reachedTop: true, numIframes: 2, stack: [ - 'http://example.com/page.html', - 'http://example.com/iframe1.html', - 'http://example.com/iframe2.html' + 'https://example.com/page.html', + 'https://example.com/iframe1.html', + 'https://example.com/iframe2.html' ] } } @@ -671,7 +671,7 @@ describe('AppNexusAdapter', function () { expect(payload.referrer_detection).to.exist; expect(payload.referrer_detection).to.deep.equal({ - rd_ref: 'http%3A%2F%2Fexample.com%2Fpage.html', + rd_ref: 'https%3A%2F%2Fexample.com%2Fpage.html', rd_top: true, rd_ifs: 2, rd_stk: bidderRequest.refererInfo.stack.map((url) => encodeURIComponent(url)).join(',') @@ -757,7 +757,7 @@ describe('AppNexusAdapter', function () { 'tag_id': 10433394, 'auction_id': '4534722592064951574', 'nobid': false, - 'no_ad_url': 'http://lax1-ib.adnxs.com/no-ad', + 'no_ad_url': 'https://lax1-ib.adnxs.com/no-ad', 'timeout_ms': 10000, 'ad_profile_id': 27079, 'ads': [ @@ -773,7 +773,7 @@ describe('AppNexusAdapter', function () { 'publisher_currency_code': '$', 'client_initiated_ad_counting': true, 'viewability': { - 'config': '' + 'config': '' }, 'rtb': { 'banner': { @@ -784,7 +784,7 @@ describe('AppNexusAdapter', function () { 'trackers': [ { 'impression_urls': [ - 'http://lax1-ib.adnxs.com/impression' + 'https://lax1-ib.adnxs.com/impression' ], 'video_events': {} } @@ -855,7 +855,7 @@ describe('AppNexusAdapter', function () { 'content': '' } }, - 'javascriptTrackers': '' + 'javascriptTrackers': '' }] }] }; @@ -887,10 +887,10 @@ describe('AppNexusAdapter', function () { 'notify_url': 'imptracker.com', 'rtb': { 'video': { - 'asset_url': 'http://sample.vastURL.com/here/vid' + 'asset_url': 'https://sample.vastURL.com/here/vid' } }, - 'javascriptTrackers': '' + 'javascriptTrackers': '' }] }] }; @@ -923,12 +923,12 @@ describe('AppNexusAdapter', function () { 'notify_url': 'imptracker.com', 'rtb': { 'video': { - 'asset_url': 'http://sample.vastURL.com/here/adpod', + 'asset_url': 'https://sample.vastURL.com/here/adpod', 'duration_ms': 30000, } }, 'viewability': { - 'config': '' + 'config': '' } }] }] @@ -965,29 +965,29 @@ describe('AppNexusAdapter', function () { 'icon': { 'width': 0, 'height': 0, - 'url': 'http://cdn.adnxs.com/icon.png' + 'url': 'https://cdn.adnxs.com/icon.png' }, 'main_img': { 'width': 2352, 'height': 1516, - 'url': 'http://cdn.adnxs.com/img.png' + 'url': 'https://cdn.adnxs.com/img.png' }, 'link': { 'url': 'https://www.appnexus.com', 'fallback_url': '', - 'click_trackers': ['http://nym1-ib.adnxs.com/click'] + 'click_trackers': ['https://nym1-ib.adnxs.com/click'] }, - 'impression_trackers': ['http://example.com'], + 'impression_trackers': ['https://example.com'], 'rating': '5', - 'displayurl': 'http://AppNexus.com/?url=display_url', + 'displayurl': 'https://AppNexus.com/?url=display_url', 'likes': '38908320', 'downloads': '874983', 'price': '9.99', 'saleprice': 'FREE', 'phone': '1234567890', 'address': '28 W 23rd St, New York, NY 10010', - 'privacy_link': 'http://appnexus.com/?url=privacy_url', - 'javascriptTrackers': '' + 'privacy_link': 'https://appnexus.com/?url=privacy_url', + 'javascriptTrackers': '' }; let bidderRequest = { bids: [{ @@ -1000,7 +1000,7 @@ describe('AppNexusAdapter', function () { expect(result[0].native.title).to.equal('Native Creative'); expect(result[0].native.body).to.equal('Cool description great stuff'); expect(result[0].native.cta).to.equal('Do it'); - expect(result[0].native.image.url).to.equal('http://cdn.adnxs.com/img.png'); + expect(result[0].native.image.url).to.equal('https://cdn.adnxs.com/img.png'); }); it('supports configuring outstream renderers', function () { diff --git a/test/spec/modules/arteebeeBidAdapter_spec.js b/test/spec/modules/arteebeeBidAdapter_spec.js deleted file mode 100644 index 013e1bd6c0c7..000000000000 --- a/test/spec/modules/arteebeeBidAdapter_spec.js +++ /dev/null @@ -1,156 +0,0 @@ -import {expect} from 'chai'; -import {spec} from 'modules/arteebeeBidAdapter'; - -describe('Arteebee adapater', function () { - describe('Test validate req', function () { - it('should accept minimum valid bid', function () { - let bid = { - bidder: 'arteebee', - params: { - pub: 'prebidtest', - source: 'prebidtest' - } - }; - const isValid = spec.isBidRequestValid(bid); - - expect(isValid).to.equal(true); - }); - - it('should reject missing pub', function () { - let bid = { - bidder: 'arteebee', - params: { - source: 'prebidtest' - } - }; - const isValid = spec.isBidRequestValid(bid); - - expect(isValid).to.equal(false); - }); - - it('should reject missing source', function () { - let bid = { - bidder: 'arteebee', - params: { - pub: 'prebidtest' - } - }; - const isValid = spec.isBidRequestValid(bid); - - expect(isValid).to.equal(false); - }); - }); - - describe('Test build request', function () { - it('minimum request', function () { - let bid = { - bidder: 'arteebee', - params: { - pub: 'prebidtest', - source: 'prebidtest' - }, - sizes: [[300, 250]] - }; - - const req = JSON.parse(spec.buildRequests([bid])[0].data); - - expect(req).to.not.have.property('reg'); - expect(req).to.not.have.property('test'); - expect(req.imp[0]).to.not.have.property('secure'); - }); - - it('make test request', function () { - let bid = { - bidder: 'arteebee', - params: { - pub: 'prebidtest', - source: 'prebidtest', - test: true - }, - sizes: [[300, 250]] - }; - - const req = JSON.parse(spec.buildRequests([bid])[0].data); - - expect(req).to.not.have.property('reg'); - expect(req).to.have.property('test', 1); - expect(req.imp[0]).to.not.have.property('secure'); - }); - - it('test coppa', function () { - let bid = { - bidder: 'arteebee', - params: { - pub: 'prebidtest', - source: 'prebidtest', - coppa: true - }, - sizes: [[300, 250]] - }; - - const req = JSON.parse(spec.buildRequests([bid])[0].data); - - expect(req.regs).to.have.property('coppa', 1); - expect(req).to.not.have.property('test'); - expect(req.imp[0]).to.not.have.property('secure'); - }); - - it('test gdpr', function () { - let bid = { - bidder: 'arteebee', - params: { - pub: 'prebidtest', - source: 'prebidtest' - }, - sizes: [[300, 250]] - }; - let consentString = 'ABCD'; - let bidderRequest = { - 'gdprConsent': { - consentString: consentString, - gdprApplies: true - } - }; - - const req = JSON.parse(spec.buildRequests([bid], bidderRequest)[0].data); - - expect(req.regs).to.exist; - expect(req.regs.ext).to.exist; - expect(req.regs.ext).to.have.property('gdpr', 1); - - expect(req.user).to.exist; - expect(req.user.ext).to.exist; - expect(req.user.ext).to.have.property('consent', consentString); - }); - }); - - describe('Test interpret response', function () { - it('General banner response', function () { - let resp = spec.interpretResponse({ - body: { - id: 'abcd', - seatbid: [{ - bid: [{ - id: 'abcd', - impid: 'banner-bid', - price: 0.3, - adm: 'hello', - crid: 'efgh', - w: 300, - h: 250, - exp: 5 - }] - }] - } - }, null)[0]; - - expect(resp).to.have.property('requestId', 'banner-bid'); - expect(resp).to.have.property('cpm', 0.3); - expect(resp).to.have.property('width', 300); - expect(resp).to.have.property('height', 250); - expect(resp).to.have.property('creativeId', 'efgh'); - expect(resp).to.have.property('ttl', 5); - expect(resp).to.have.property('ad', 'hello'); - }); - }); -}); diff --git a/test/spec/modules/atomxBidAdapter_spec.js b/test/spec/modules/atomxBidAdapter_spec.js index fdcdb55ec7f4..782619d04dba 100644 --- a/test/spec/modules/atomxBidAdapter_spec.js +++ b/test/spec/modules/atomxBidAdapter_spec.js @@ -96,7 +96,7 @@ describe('atomxAdapterTest', function () { 'cpm': 0.00009, 'width': 300, 'height': 250, - 'url': 'http://atomx.com', + 'url': 'https://atomx.com', 'creative_id': 456, 'code': '22aidtbx5eabd9', }, @@ -113,7 +113,7 @@ describe('atomxAdapterTest', function () { expect(result[0].creativeId).to.equal(456); expect(result[0].currency).to.equal('USD'); expect(result[0].ttl).to.equal(60); - expect(result[0].adUrl).to.equal('http://atomx.com'); + expect(result[0].adUrl).to.equal('https://atomx.com'); }); }); }); diff --git a/test/spec/modules/audienceNetworkBidAdapter_spec.js b/test/spec/modules/audienceNetworkBidAdapter_spec.js deleted file mode 100644 index a495b33438c8..000000000000 --- a/test/spec/modules/audienceNetworkBidAdapter_spec.js +++ /dev/null @@ -1,522 +0,0 @@ -/** - * @file Tests for AudienceNetwork adapter. - */ -import { expect } from 'chai'; - -import { spec } from 'modules/audienceNetworkBidAdapter'; -import * as utils from 'src/utils'; - -const { - code, - supportedMediaTypes, - isBidRequestValid, - buildRequests, - interpretResponse -} = spec; - -const bidder = 'audienceNetwork'; -const placementId = 'test-placement-id'; -const playerwidth = 320; -const playerheight = 180; -const requestId = 'test-request-id'; -const debug = 'adapterver=1.3.0&platform=241394079772386&platver=$prebid.version$&cb=test-uuid'; -const pageUrl = encodeURIComponent(utils.getTopWindowUrl()); - -describe('AudienceNetwork adapter', function () { - describe('Public API', function () { - it('code', function () { - expect(code).to.equal(bidder); - }); - it('supportedMediaTypes', function () { - expect(supportedMediaTypes).to.deep.equal(['banner', 'video']); - }); - it('isBidRequestValid', function () { - expect(isBidRequestValid).to.be.a('function'); - }); - it('buildRequests', function () { - expect(buildRequests).to.be.a('function'); - }); - it('interpretResponse', function () { - expect(interpretResponse).to.be.a('function'); - }); - }); - - describe('isBidRequestValid', function () { - it('missing placementId parameter', function () { - expect(isBidRequestValid({ - bidder, - sizes: [[300, 250]] - })).to.equal(false); - }); - - it('invalid sizes parameter', function () { - expect(isBidRequestValid({ - bidder, - sizes: ['', undefined, null, '300x100', [300, 100], [300], {}], - params: { placementId } - })).to.equal(false); - }); - - it('valid when at least one valid size', function () { - expect(isBidRequestValid({ - bidder, - sizes: [[1, 1], [300, 250]], - params: { placementId } - })).to.equal(true); - }); - - it('valid parameters', function () { - expect(isBidRequestValid({ - bidder, - sizes: [[300, 250], [320, 50]], - params: { placementId } - })).to.equal(true); - }); - - it('fullwidth', function () { - expect(isBidRequestValid({ - bidder, - sizes: [[300, 250], [336, 280]], - params: { - placementId, - format: 'fullwidth' - } - })).to.equal(true); - }); - - it('native', function () { - expect(isBidRequestValid({ - bidder, - sizes: [[300, 250]], - params: { - placementId, - format: 'native' - } - })).to.equal(true); - }); - - it('native with non-IAB size', function () { - expect(isBidRequestValid({ - bidder, - sizes: [[728, 90]], - params: { - placementId, - format: 'native' - } - })).to.equal(true); - }); - - it('video', function () { - expect(isBidRequestValid({ - bidder, - sizes: [[playerwidth, playerheight]], - params: { - placementId, - format: 'video' - } - })).to.equal(true); - }); - }); - - describe('buildRequests', function () { - before(function () { - sinon - .stub(utils, 'generateUUID') - .returns('test-uuid'); - }); - - after(function () { - utils.generateUUID.restore(); - }); - - it('can build URL for IAB unit', function () { - expect(buildRequests([{ - bidder, - bidId: requestId, - sizes: [[300, 50], [300, 250], [320, 50]], - params: { placementId } - }])).to.deep.equal([{ - adformats: ['300x250'], - method: 'GET', - requestIds: [requestId], - sizes: ['300x250'], - url: 'https://an.facebook.com/v2/placementbid.json', - data: `placementids[]=test-placement-id&adformats[]=300x250&testmode=false&pageurl=${pageUrl}&sdk[]=6.0.web&${debug}` - }]); - }); - - it('can build URL for video unit', function () { - expect(buildRequests([{ - bidder, - bidId: requestId, - sizes: [[640, 480]], - params: { - placementId, - format: 'video' - } - }])).to.deep.equal([{ - adformats: ['video'], - method: 'GET', - requestIds: [requestId], - sizes: ['640x480'], - url: 'https://an.facebook.com/v2/placementbid.json', - data: `placementids[]=test-placement-id&adformats[]=video&testmode=false&pageurl=${pageUrl}&sdk[]=&${debug}&playerwidth=640&playerheight=480` - }]); - }); - - it('can build URL for native unit in non-IAB size', function () { - expect(buildRequests([{ - bidder, - bidId: requestId, - sizes: [[728, 90]], - params: { - placementId, - format: 'native' - } - }])).to.deep.equal([{ - adformats: ['native'], - method: 'GET', - requestIds: [requestId], - sizes: ['728x90'], - url: 'https://an.facebook.com/v2/placementbid.json', - data: `placementids[]=test-placement-id&adformats[]=native&testmode=false&pageurl=${pageUrl}&sdk[]=6.0.web&${debug}` - }]); - }); - - it('can build URL for deprecated fullwidth unit, overriding platform', function () { - const platform = 'test-platform'; - const debugPlatform = debug.replace('241394079772386', platform); - - expect(buildRequests([{ - bidder, - bidId: requestId, - sizes: [[300, 250]], - params: { - placementId, - platform, - format: 'fullwidth' - } - }])).to.deep.equal([{ - adformats: ['300x250'], - method: 'GET', - requestIds: [requestId], - sizes: ['300x250'], - url: 'https://an.facebook.com/v2/placementbid.json', - data: `placementids[]=test-placement-id&adformats[]=300x250&testmode=false&pageurl=${pageUrl}&sdk[]=6.0.web&${debugPlatform}` - }]); - }); - }); - - describe('interpretResponse', function () { - it('error in response', function () { - expect(interpretResponse({ - body: { - errors: ['test-error-message'] - } - }, {})).to.deep.equal([]); - }); - - it('valid native bid in response', function () { - const [bidResponse] = interpretResponse({ - body: { - errors: [], - bids: { - [placementId]: [{ - placement_id: placementId, - bid_id: 'test-bid-id', - bid_price_cents: 123, - bid_price_currency: 'usd', - bid_price_model: 'cpm' - }] - } - } - }, { - adformats: ['native'], - requestIds: [requestId], - sizes: [[300, 250]] - }); - - expect(bidResponse.cpm).to.equal(1.23); - expect(bidResponse.requestId).to.equal(requestId); - expect(bidResponse.width).to.equal(300); - expect(bidResponse.height).to.equal(250); - expect(bidResponse.ad) - .to.contain(`placementid: '${placementId}',`) - .and.to.contain(`format: 'native',`) - .and.to.contain(`bidid: 'test-bid-id',`) - .and.to.contain('getElementsByTagName("style")', 'ad missing native styles') - .and.to.contain('
', 'ad missing native container'); - expect(bidResponse.ttl).to.equal(600); - expect(bidResponse.creativeId).to.equal(placementId); - expect(bidResponse.netRevenue).to.equal(true); - expect(bidResponse.currency).to.equal('USD'); - - expect(bidResponse.hb_bidder).to.equal('fan'); - expect(bidResponse.fb_bidid).to.equal('test-bid-id'); - expect(bidResponse.fb_format).to.equal('native'); - expect(bidResponse.fb_placementid).to.equal(placementId); - }); - - it('valid IAB bid in response', function () { - const [bidResponse] = interpretResponse({ - body: { - errors: [], - bids: { - [placementId]: [{ - placement_id: placementId, - bid_id: 'test-bid-id', - bid_price_cents: 123, - bid_price_currency: 'usd', - bid_price_model: 'cpm' - }] - } - } - }, { - adformats: ['300x250'], - requestIds: [requestId], - sizes: [[300, 250]] - }); - - expect(bidResponse.cpm).to.equal(1.23); - expect(bidResponse.requestId).to.equal(requestId); - expect(bidResponse.width).to.equal(300); - expect(bidResponse.height).to.equal(250); - expect(bidResponse.ad) - .to.contain(`placementid: '${placementId}',`) - .and.to.contain(`format: '300x250',`) - .and.to.contain(`bidid: 'test-bid-id',`) - .and.not.to.contain('getElementsByTagName("style")', 'ad should not contain native styles') - .and.not.to.contain('
', 'ad should not contain native container'); - expect(bidResponse.ttl).to.equal(600); - expect(bidResponse.creativeId).to.equal(placementId); - expect(bidResponse.netRevenue).to.equal(true); - expect(bidResponse.currency).to.equal('USD'); - expect(bidResponse.hb_bidder).to.equal('fan'); - expect(bidResponse.fb_bidid).to.equal('test-bid-id'); - expect(bidResponse.fb_format).to.equal('300x250'); - expect(bidResponse.fb_placementid).to.equal(placementId); - }); - - it('filters invalid slot sizes', function () { - const [bidResponse] = interpretResponse({ - body: { - errors: [], - bids: { - [placementId]: [{ - placement_id: placementId, - bid_id: 'test-bid-id', - bid_price_cents: 123, - bid_price_currency: 'usd', - bid_price_model: 'cpm' - }] - } - } - }, { - adformats: ['300x250'], - requestIds: [requestId], - sizes: [[300, 250]] - }); - - expect(bidResponse.cpm).to.equal(1.23); - expect(bidResponse.requestId).to.equal(requestId); - expect(bidResponse.width).to.equal(300); - expect(bidResponse.height).to.equal(250); - expect(bidResponse.ttl).to.equal(600); - expect(bidResponse.creativeId).to.equal(placementId); - expect(bidResponse.netRevenue).to.equal(true); - expect(bidResponse.currency).to.equal('USD'); - expect(bidResponse.hb_bidder).to.equal('fan'); - expect(bidResponse.fb_bidid).to.equal('test-bid-id'); - expect(bidResponse.fb_format).to.equal('300x250'); - expect(bidResponse.fb_placementid).to.equal(placementId); - }); - - it('valid multiple bids in response', function () { - const placementIdNative = 'test-placement-id-native'; - const placementIdIab = 'test-placement-id-iab'; - - const [bidResponseNative, bidResponseIab] = interpretResponse({ - body: { - errors: [], - bids: { - [placementIdNative]: [{ - placement_id: placementIdNative, - bid_id: 'test-bid-id-native', - bid_price_cents: 123, - bid_price_currency: 'usd', - bid_price_model: 'cpm' - }], - [placementIdIab]: [{ - placement_id: placementIdIab, - bid_id: 'test-bid-id-iab', - bid_price_cents: 456, - bid_price_currency: 'usd', - bid_price_model: 'cpm' - }] - } - } - }, { - adformats: ['native', '300x250'], - requestIds: [requestId, requestId], - sizes: ['300x250', [300, 250]] - }); - - expect(bidResponseNative.cpm).to.equal(1.23); - expect(bidResponseNative.requestId).to.equal(requestId); - expect(bidResponseNative.width).to.equal(300); - expect(bidResponseNative.height).to.equal(250); - expect(bidResponseNative.ad) - .to.contain(`placementid: '${placementIdNative}',`) - .and.to.contain(`format: 'native',`) - .and.to.contain(`bidid: 'test-bid-id-native',`); - expect(bidResponseNative.ttl).to.equal(600); - expect(bidResponseNative.creativeId).to.equal(placementIdNative); - expect(bidResponseNative.netRevenue).to.equal(true); - expect(bidResponseNative.currency).to.equal('USD'); - expect(bidResponseNative.hb_bidder).to.equal('fan'); - expect(bidResponseNative.fb_bidid).to.equal('test-bid-id-native'); - expect(bidResponseNative.fb_format).to.equal('native'); - expect(bidResponseNative.fb_placementid).to.equal(placementIdNative); - - expect(bidResponseIab.cpm).to.equal(4.56); - expect(bidResponseIab.requestId).to.equal(requestId); - expect(bidResponseIab.width).to.equal(300); - expect(bidResponseIab.height).to.equal(250); - expect(bidResponseIab.ad) - .to.contain(`placementid: '${placementIdIab}',`) - .and.to.contain(`format: '300x250',`) - .and.to.contain(`bidid: 'test-bid-id-iab',`); - expect(bidResponseIab.ttl).to.equal(600); - expect(bidResponseIab.creativeId).to.equal(placementIdIab); - expect(bidResponseIab.netRevenue).to.equal(true); - expect(bidResponseIab.currency).to.equal('USD'); - expect(bidResponseIab.hb_bidder).to.equal('fan'); - expect(bidResponseIab.fb_bidid).to.equal('test-bid-id-iab'); - expect(bidResponseIab.fb_format).to.equal('300x250'); - expect(bidResponseIab.fb_placementid).to.equal(placementIdIab); - }); - - it('valid video bid in response', function () { - const bidId = 'test-bid-id-video'; - - const [bidResponse] = interpretResponse({ - body: { - errors: [], - bids: { - [placementId]: [{ - placement_id: placementId, - bid_id: bidId, - bid_price_cents: 123, - bid_price_currency: 'usd', - bid_price_model: 'cpm' - }] - } - } - }, { - adformats: ['video'], - requestIds: [requestId], - sizes: [[playerwidth, playerheight]] - }); - - expect(bidResponse.cpm).to.equal(1.23); - expect(bidResponse.requestId).to.equal(requestId); - expect(bidResponse.ttl).to.equal(3600); - expect(bidResponse.mediaType).to.equal('video'); - expect(bidResponse.vastUrl).to.equal(`https://an.facebook.com/v1/instream/vast.xml?placementid=${placementId}&pageurl=${pageUrl}&playerwidth=${playerwidth}&playerheight=${playerheight}&bidid=${bidId}`); - expect(bidResponse.width).to.equal(playerwidth); - expect(bidResponse.height).to.equal(playerheight); - }); - - it('mixed video and native bids', function () { - const videoPlacementId = 'test-video-placement-id'; - const videoBidId = 'test-video-bid-id'; - const nativePlacementId = 'test-native-placement-id'; - const nativeBidId = 'test-native-bid-id'; - - const [bidResponseVideo, bidResponseNative] = interpretResponse({ - body: { - errors: [], - bids: { - [videoPlacementId]: [{ - placement_id: videoPlacementId, - bid_id: videoBidId, - bid_price_cents: 123, - bid_price_currency: 'usd', - bid_price_model: 'cpm' - }], - [nativePlacementId]: [{ - placement_id: nativePlacementId, - bid_id: nativeBidId, - bid_price_cents: 456, - bid_price_currency: 'usd', - bid_price_model: 'cpm' - }] - } - } - }, { - adformats: ['video', 'native'], - requestIds: [requestId, requestId], - sizes: [[playerwidth, playerheight], [300, 250]] - }); - - expect(bidResponseVideo.cpm).to.equal(1.23); - expect(bidResponseVideo.requestId).to.equal(requestId); - expect(bidResponseVideo.ttl).to.equal(3600); - expect(bidResponseVideo.mediaType).to.equal('video'); - expect(bidResponseVideo.vastUrl).to.equal(`https://an.facebook.com/v1/instream/vast.xml?placementid=${videoPlacementId}&pageurl=${pageUrl}&playerwidth=${playerwidth}&playerheight=${playerheight}&bidid=${videoBidId}`); - expect(bidResponseVideo.width).to.equal(playerwidth); - expect(bidResponseVideo.height).to.equal(playerheight); - - expect(bidResponseNative.cpm).to.equal(4.56); - expect(bidResponseNative.requestId).to.equal(requestId); - expect(bidResponseNative.ttl).to.equal(600); - expect(bidResponseNative.width).to.equal(300); - expect(bidResponseNative.height).to.equal(250); - expect(bidResponseNative.ad) - .to.contain(`placementid: '${nativePlacementId}',`) - .and.to.contain(`format: 'native',`) - .and.to.contain(`bidid: '${nativeBidId}',`); - }); - - it('mixture of valid native bid and error in response', function () { - const [bidResponse] = interpretResponse({ - body: { - errors: ['test-error-message'], - bids: { - [placementId]: [{ - placement_id: placementId, - bid_id: 'test-bid-id', - bid_price_cents: 123, - bid_price_currency: 'usd', - bid_price_model: 'cpm' - }] - } - } - }, { - adformats: ['native'], - requestIds: [requestId], - sizes: [[300, 250]] - }); - - expect(bidResponse.cpm).to.equal(1.23); - expect(bidResponse.requestId).to.equal(requestId); - expect(bidResponse.width).to.equal(300); - expect(bidResponse.height).to.equal(250); - expect(bidResponse.ad) - .to.contain(`placementid: '${placementId}',`) - .and.to.contain(`format: 'native',`) - .and.to.contain(`bidid: 'test-bid-id',`) - .and.to.contain('getElementsByTagName("style")', 'ad missing native styles') - .and.to.contain('
', 'ad missing native container'); - expect(bidResponse.ttl).to.equal(600); - expect(bidResponse.creativeId).to.equal(placementId); - expect(bidResponse.netRevenue).to.equal(true); - expect(bidResponse.currency).to.equal('USD'); - - expect(bidResponse.hb_bidder).to.equal('fan'); - expect(bidResponse.fb_bidid).to.equal('test-bid-id'); - expect(bidResponse.fb_format).to.equal('native'); - expect(bidResponse.fb_placementid).to.equal(placementId); - }); - }); -}); diff --git a/test/spec/modules/bidphysicsBidAdapter_spec.js b/test/spec/modules/bidphysicsBidAdapter_spec.js index ba93642ad810..8c46b8cefa6f 100644 --- a/test/spec/modules/bidphysicsBidAdapter_spec.js +++ b/test/spec/modules/bidphysicsBidAdapter_spec.js @@ -50,7 +50,7 @@ const RESPONSE = { 'adm': '', 'adid': '144762342', 'adomain': [ - 'http://dummydomain.com' + 'https://dummydomain.com' ], 'iurl': 'iurl', 'cid': '109', @@ -79,7 +79,7 @@ const RESPONSE = { 'adm': '', 'adid': '144762342', 'adomain': [ - 'http://dummydomain.com' + 'https://dummydomain.com' ], 'iurl': 'iurl', 'cid': '109', diff --git a/test/spec/modules/bizzclickBidAdapter_spec.js b/test/spec/modules/bizzclickBidAdapter_spec.js deleted file mode 100644 index 6f518f32ccf8..000000000000 --- a/test/spec/modules/bizzclickBidAdapter_spec.js +++ /dev/null @@ -1,117 +0,0 @@ -import {expect} from 'chai'; -import {spec} from '../../../modules/bizzclickBidAdapter'; - -describe('BizzclickBidAdapter', function () { - let bid = { - bidId: '67d581a232281d', - bidder: 'bizzclickBidAdapter', - bidderRequestId: 'a7837c9145e136', - params: { - placementId: 0, - type: 'banner' - }, - placementCode: 'placementId', - auctionId: 'bfe951372e62-a92d-4cf1-869f-d24029', - sizes: [[300, 250]], - transactionId: '3bb2f6da-87a6-4029-aeb0-1b244bbfb5' - }; - - describe('isBidRequestValid', function () { - it('Should return true when placement_id can be cast to a number', function () { - expect(spec.isBidRequestValid(bid)).to.be.true; - }); - it('Should return false when placement_id is not a number', function () { - bid.params.placementId = 'aaa'; - expect(spec.isBidRequestValid(bid)).to.be.false; - }); - }); - - describe('buildRequests', function () { - let serverRequest = spec.buildRequests([bid]); - it('Creates a ServerRequest object with method, URL and data', function () { - expect(serverRequest).to.exist; - expect(serverRequest.method).to.exist; - expect(serverRequest.url).to.exist; - expect(serverRequest.data).to.exist; - }); - it('Returns POST method', function () { - expect(serverRequest.method).to.equal('POST'); - }); - it('Returns valid URL', function () { - expect(serverRequest.url).to.equal('//supply.bizzclick.com/?c=o&m=multi'); - }); - it('Returns valid data if array of bids is valid', function () { - let data = serverRequest.data; - expect(data).to.be.an('object'); - expect(data).to.have.all.keys('deviceWidth', 'deviceHeight', 'secure', 'host', 'page', 'placements'); - expect(data.deviceWidth).to.be.a('number'); - expect(data.deviceHeight).to.be.a('number'); - expect(data.secure).to.be.within(0, 1); - expect(data.host).to.be.a('string'); - expect(data.page).to.be.a('string'); - let placements = data['placements']; - for (let i = 0; i < placements.length; i++) { - let placement = placements[i]; - expect(placement).to.have.all.keys('placementId', 'bidId', 'type', 'sizes'); - expect(placement.placementId).to.be.a('number'); - expect(placement.bidId).to.be.a('string'); - expect(placement.type).to.be.a('string'); - expect(placement.sizes).to.be.an('array'); - } - }); - it('Returns empty data if no valid requests are passed', function () { - serverRequest = spec.buildRequests([]); - let data = serverRequest.data; - expect(data.placements).to.be.an('array').that.is.empty; - }); - }); - describe('interpretResponse', function () { - let resObject = { - body: [ { - requestId: '123', - mediaType: 'banner', - cpm: 0.3, - width: 320, - height: 50, - ad: '

Hello ad

', - ttl: 1000, - creativeId: '123asd', - netRevenue: true, - currency: 'USD' - }] - }; - let serverResponses = spec.interpretResponse(resObject); - it('Returns an array of valid server responses if response object is valid', function () { - expect(serverResponses).to.be.an('array').that.is.not.empty; - for (let i = 0; i < serverResponses.length; i++) { - let dataItem = serverResponses[i]; - expect(dataItem).to.have.all.keys('requestId', 'cpm', 'width', 'height', 'ad', 'ttl', 'creativeId', 'netRevenue', 'currency', 'mediaType'); - expect(dataItem.requestId).to.be.a('string'); - expect(dataItem.cpm).to.be.a('number'); - expect(dataItem.width).to.be.a('number'); - expect(dataItem.height).to.be.a('number'); - expect(dataItem.ad).to.be.a('string'); - expect(dataItem.ttl).to.be.a('number'); - expect(dataItem.creativeId).to.be.a('string'); - expect(dataItem.netRevenue).to.be.a('boolean'); - expect(dataItem.currency).to.be.a('string'); - expect(dataItem.mediaType).to.be.a('string'); - } - it('Returns an empty array if invalid response is passed', function () { - serverResponses = spec.interpretResponse('invalid_response'); - expect(serverResponses).to.be.an('array').that.is.empty; - }); - }); - }); - - describe('getUserSyncs', function () { - let userSync = spec.getUserSyncs(); - it('Returns valid URL and type', function () { - expect(userSync).to.be.an('array').with.lengthOf(1); - expect(userSync[0].type).to.exist; - expect(userSync[0].url).to.exist; - expect(userSync[0].type).to.be.equal('image'); - expect(userSync[0].url).to.be.equal('//supply.bizzclick.com/?c=o&m=cookie'); - }); - }); -}); diff --git a/test/spec/modules/brainyBidAdapter_spec.js b/test/spec/modules/brainyBidAdapter_spec.js deleted file mode 100644 index a3ce90d927ae..000000000000 --- a/test/spec/modules/brainyBidAdapter_spec.js +++ /dev/null @@ -1,128 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/brainyBidAdapter'; - -const URL = '//proparm.jp/ssp/p/pbjs'; -const BIDDER_CODE = 'brainy'; - -const validBidReq = { - bidder: BIDDER_CODE, - params: { - accountID: '12345', - slotID: '12345' - } -}; - -const invalidBidReq = { - bidder: BIDDER_CODE, - params: { - accountID: '', - slotID: '' - } -}; - -const bidReq = [{ - bidder: BIDDER_CODE, - params: { - accountID: '12345', - slotID: '12345' - } -}]; - -const correctReq = { - accountID: '12345', - slotID: '12345' -}; - -const bidResponse = { - ad_id: '1036e9746c-d186-49ae-90cb-2796d0f9b223', - adm: '', - syncUrl: '//testparm.com/ssp-sync/p/sync?uid=2110180601155125000059&buyer=2&slot=34', - cpm: 100, - height: 250, - width: 300 -}; - -const bidSyncResponse = [{ - body: { - ad_id: '1036e9746c-d186-49ae-90cb-2796d0f9b223', - adm: '', - syncUrl: '//testparm.com/ssp-sync/p/sync?uid=2110180601155125000059&buyer=2&slot=34', - cpm: 100, - height: 250, - width: 300 - } -}]; - -const invalidSyncBidResponse = [{ - body: { - ad_id: '1036e9746c-d186-49ae-90cb-2796d0f9b223', - adm: '', - syncUrl: 'null', - cpm: 100, - height: 250, - width: 300 - } -}]; - -describe('brainy Adapter', function () { - describe('request', function () { - it('should validate bid request', function () { - expect(spec.isBidRequestValid(validBidReq)).to.equal(true); - }); - it('should not validate incorrect bid request', function () { - expect(spec.isBidRequestValid(invalidBidReq)).to.equal(false); - }); - }); - describe('build request', function () { - it('Verify bid request', function () { - const request = spec.buildRequests(bidReq); - expect(request[0].method).to.equal('GET'); - expect(request[0].url).to.equal(URL); - expect(request[0].data).to.match(new RegExp(`${correctReq.accountID}`)); - expect(request[0].data).to.match(new RegExp(`${correctReq.slotID}`)); - }); - }); - - describe('interpretResponse', function () { - it('should build bid array', function () { - const request = spec.buildRequests(bidReq); - const result = spec.interpretResponse({body: bidResponse}, request[0]); - expect(result.length).to.equal(1); - }); - - it('should have all relevant fields', function () { - const request = spec.buildRequests(bidReq); - const result = spec.interpretResponse({body: bidResponse}, request[0]); - const bid = result[0]; - - expect(bid.cpm).to.equal(bidResponse.cpm); - expect(bid.width).to.equal(bidResponse.width); - expect(bid.height).to.equal(bidResponse.height); - }); - }); - - describe('spec.getUserSyncs', function () { - let syncOptions - beforeEach(function () { - syncOptions = { - enabledBidders: ['brainy'], - pixelEnabled: true - } - }); - it('sucess with usersync url', function () { - const result = []; - result.push({type: 'image', url: '//testparm.com/ssp-sync/p/sync?uid=2110180601155125000059&buyer=2&slot=34'}); - expect(spec.getUserSyncs(syncOptions, bidSyncResponse)).to.deep.equal(result); - }); - - it('sucess without usersync url', function () { - const result = []; - expect(spec.getUserSyncs(syncOptions, invalidSyncBidResponse)).to.deep.equal(result); - }); - it('empty response', function () { - const serverResponse = [{body: {}}]; - const result = []; - expect(spec.getUserSyncs(syncOptions, serverResponse)).to.deep.equal(result); - }); - }); -}); diff --git a/test/spec/modules/bridgewellBidAdapter_spec.js b/test/spec/modules/bridgewellBidAdapter_spec.js deleted file mode 100644 index 6ca9675a1bbd..000000000000 --- a/test/spec/modules/bridgewellBidAdapter_spec.js +++ /dev/null @@ -1,1164 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/bridgewellBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; -import * as utils from 'src/utils'; - -describe('bridgewellBidAdapter', function () { - let bidRequests = [ - { - 'bidder': 'bridgewell', - 'params': { - 'ChannelID': 'CLJgEAYYvxUiBXBlbm55KgkIrAIQ-gEaATk' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - }, - { - 'bidder': 'bridgewell', - 'params': { - 'ChannelID': 'CgUxMjMzOBIBNiIGcGVubnkzKggI2AUQWhoBOQ' - }, - 'adUnitCode': 'adunit-code-2', - 'sizes': [[728, 90]], - 'bidId': '3150ccb55da321', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - }, - { - 'bidder': 'bridgewell', - 'params': { - 'ChannelID': 'CgUxMjMzOBIBNiIFcGVubnkqCQisAhD6ARoBOQ' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250]], - 'bidId': '42dbe3a7168a6a', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - }, - { - 'bidder': 'bridgewell', - 'params': { - 'ChannelID': 'CgUxMjMzOBIBNiIFcGVubnkqCQisAhD6ARoBOQ', - 'cpmWeight': 0.5 - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250]], - 'bidId': '42dbe3a7168a6a', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - }, - { - 'bidder': 'bridgewell', - 'params': { - 'ChannelID': 'CgUxMjMzOBIBNiIGcGVubnkzKggI2AUQWhoBOQ', - 'cpmWeight': -0.5 - }, - 'adUnitCode': 'adunit-code-2', - 'sizes': [[728, 90]], - 'bidId': '3150ccb55da321', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - }, - { - 'bidder': 'bridgewell', - 'params': { - 'ChannelID': 'CgUxMjMzOBIBNiIGcGVubnkzKggI2AUQWhoBOQ', - }, - 'adUnitCode': 'adunit-code-2', - 'sizes': [728, 90], - 'bidId': '3150ccb55da321', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - }, - { - 'bidder': 'bridgewell', - 'params': { - 'ChannelID': 'CgUxMjMzOBIBNiIGcGVubnkzKggI2AUQWhoBOQ', - }, - 'adUnitCode': 'adunit-code-2', - 'mediaTypes': { - 'banner': { - 'sizes': [728, 90] - } - }, - 'bidId': '3150ccb55da321', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - }, - { - 'bidder': 'bridgewell', - 'params': { - 'ChannelID': 'CgUxMjMzOBIBNiIGcGVubnkzKggI2AUQWhoBOQ', - }, - 'adUnitCode': 'adunit-code-2', - 'sizes': [1, 1], - 'mediaTypes': { - 'native': { - 'title': { - 'required': true, - 'len': 15 - }, - 'body': { - 'required': true - }, - 'image': { - 'required': true, - 'sizes': [150, 150] - }, - 'icon': { - 'required': true, - 'sizes': [50, 50] - }, - 'clickUrl': { - 'required': true - }, - 'cta': { - 'required': true - }, - 'sponsoredBy': { - 'required': true - } - } - }, - 'bidId': '3150ccb55da321', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - }, - { - 'bidder': 'bridgewell', - 'params': { - 'ChannelID': 'CgUxMjMzOBIBNiIGcGVubnkzKggI2AUQWhoBOQ', - }, - 'adUnitCode': 'adunit-code-2', - 'sizes': [1, 1], - 'mediaTypes': { - 'native': { - 'title': { - 'required': false, - 'len': 15 - }, - 'body': { - 'required': false - }, - 'image': { - 'required': false, - 'sizes': [150, 150] - }, - 'icon': { - 'required': false, - 'sizes': [50, 50] - }, - 'clickUrl': { - 'required': false - }, - 'cta': { - 'required': false - }, - 'sponsoredBy': { - 'required': false - } - } - }, - 'bidId': '3150ccb55da321', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - } - ]; - const adapter = newBidder(spec); - - describe('inherited functions', function () { - it('exists and is a function', function () { - expect(adapter.callBids).to.exist.and.to.be.a('function'); - }); - }); - - describe('isBidRequestValid', function () { - let bidWithoutCpmWeight = { - 'bidder': 'bridgewell', - 'params': { - 'ChannelID': 'CLJgEAYYvxUiBXBlbm55KgkIrAIQ-gEaATk' - }, - 'adUnitCode': 'adunit-code', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - }; - - let bidWithCorrectCpmWeight = { - 'bidder': 'bridgewell', - 'params': { - 'ChannelID': 'CLJgEAYYvxUiBXBlbm55KgkIrAIQ-gEaATk', - 'cpmWeight': 0.5 - }, - 'adUnitCode': 'adunit-code', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - }; - - let bidWithUncorrectCpmWeight = { - 'bidder': 'bridgewell', - 'params': { - 'ChannelID': 'CLJgEAYYvxUiBXBlbm55KgkIrAIQ-gEaATk', - 'cpmWeight': -1.0 - }, - 'adUnitCode': 'adunit-code', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - }; - - let bidWithZeroCpmWeight = { - 'bidder': 'bridgewell', - 'params': { - 'ChannelID': 'CLJgEAYYvxUiBXBlbm55KgkIrAIQ-gEaATk', - 'cpmWeight': 0 - }, - 'adUnitCode': 'adunit-code', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - }; - - it('should return true when required params found', function () { - expect(spec.isBidRequestValid(bidWithoutCpmWeight)).to.equal(true); - expect(spec.isBidRequestValid(bidWithCorrectCpmWeight)).to.equal(true); - expect(spec.isBidRequestValid(bidWithUncorrectCpmWeight)).to.equal(false); - expect(spec.isBidRequestValid(bidWithZeroCpmWeight)).to.equal(false); - }); - - it('should return false when required params not found', function () { - expect(spec.isBidRequestValid({})).to.equal(false); - }); - - it('should return false when required params are not passed', function () { - let bidWithoutCpmWeight = Object.assign({}, bidWithoutCpmWeight); - let bidWithCorrectCpmWeight = Object.assign({}, bidWithCorrectCpmWeight); - let bidWithUncorrectCpmWeight = Object.assign({}, bidWithUncorrectCpmWeight); - let bidWithZeroCpmWeight = Object.assign({}, bidWithZeroCpmWeight); - - delete bidWithoutCpmWeight.params; - delete bidWithCorrectCpmWeight.params; - delete bidWithUncorrectCpmWeight.params; - delete bidWithZeroCpmWeight.params; - - bidWithoutCpmWeight.params = { - 'ChannelID': 0 - }; - - bidWithCorrectCpmWeight.params = { - 'ChannelID': 0 - }; - - bidWithUncorrectCpmWeight.params = { - 'ChannelID': 0 - }; - - bidWithZeroCpmWeight.params = { - 'ChannelID': 0 - }; - - expect(spec.isBidRequestValid(bidWithoutCpmWeight)).to.equal(false); - expect(spec.isBidRequestValid(bidWithCorrectCpmWeight)).to.equal(false); - expect(spec.isBidRequestValid(bidWithUncorrectCpmWeight)).to.equal(false); - expect(spec.isBidRequestValid(bidWithZeroCpmWeight)).to.equal(false); - }); - }); - - describe('buildRequests', function () { - it('should attach valid params to the tag', function () { - const request = spec.buildRequests(bidRequests); - const payload = request.data; - const adUnits = payload.adUnits; - - expect(payload).to.be.an('object'); - expect(adUnits).to.be.an('array'); - for (let i = 0, max_i = adUnits.length; i < max_i; i++) { - let adUnit = adUnits[i]; - expect(adUnit).to.have.property('ChannelID').that.is.a('string'); - } - }); - - it('should attach validBidRequests to the tag', function () { - const request = spec.buildRequests(bidRequests); - const validBidRequests = request.validBidRequests; - expect(validBidRequests).to.deep.equal(bidRequests); - }); - }); - - describe('interpretResponse', function () { - const request = spec.buildRequests(bidRequests); - const serverResponses = [ - { - 'id': 'e5b10774-32bf-4931-85ee-05095e8cff21', - 'bidder_code': 'bridgewell', - 'cpm': 5.0, - 'width': 300, - 'height': 250, - 'mediaType': 'banner', - 'ad': '
test 300x250
', - 'ttl': 360, - 'netRevenue': true, - 'currency': 'NTD' - }, - { - 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', - 'bidder_code': 'bridgewell', - 'cpm': 5.0, - 'width': 728, - 'height': 90, - 'mediaType': 'banner', - 'ad': '
test 728x90
', - 'ttl': 360, - 'netRevenue': true, - 'currency': 'NTD' - }, - { - 'id': '8f12c646-3b87-4326-a837-c2a76999f168', - 'bidder_code': 'bridgewell', - 'cpm': 5.0, - 'width': 300, - 'height': 250, - 'mediaType': 'banner', - 'ad': '
test 300x250
', - 'ttl': 360, - 'netRevenue': true, - 'currency': 'NTD' - }, - { - 'id': '8f12c646-3b87-4326-a837-c2a76999f168', - 'bidder_code': 'bridgewell', - 'cpm': 5.0, - 'width': 300, - 'height': 250, - 'mediaType': 'banner', - 'ad': '
test 300x250
', - 'ttl': 360, - 'netRevenue': true, - 'currency': 'NTD' - }, - { - 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', - 'bidder_code': 'bridgewell', - 'cpm': 5.0, - 'width': 728, - 'height': 90, - 'mediaType': 'banner', - 'ad': '
test 728x90
', - 'ttl': 360, - 'netRevenue': true, - 'currency': 'NTD' - }, - { - 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', - 'bidder_code': 'bridgewell', - 'cpm': 5.0, - 'width': 728, - 'height': 90, - 'mediaType': 'banner', - 'ad': '
test 728x90
', - 'ttl': 360, - 'netRevenue': true, - 'currency': 'NTD' - }, - { - 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', - 'bidder_code': 'bridgewell', - 'cpm': 5.0, - 'width': 728, - 'height': 90, - 'mediaType': 'banner', - 'ad': '
test 728x90
', - 'ttl': 360, - 'netRevenue': true, - 'currency': 'NTD' - }, - { - 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', - 'bidder_code': 'bridgewell', - 'cpm': 5.0, - 'width': 1, - 'height': 1, - 'mediaType': 'native', - 'native': { - 'image': { - 'url': 'https://img.scupio.com/test/test-image.jpg', - 'width': 150, - 'height': 150 - }, - 'title': 'test-title', - 'sponsoredBy': 'test-sponsoredBy', - 'body': 'test-body', - 'icon': { - 'url': 'https://img.scupio.com/test/test-icon.jpg', - 'width': 50, - 'height': 50 - }, - 'clickUrl': 'https://img.scupio.com/test-clickUrl', - 'clickTrackers': ['https://img.scupio.com/test-clickTracker'], - 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker'] - }, - 'ttl': 360, - 'netRevenue': true, - 'currency': 'NTD' - }, - { - 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', - 'bidder_code': 'bridgewell', - 'cpm': 5.0, - 'width': 1, - 'height': 1, - 'mediaType': 'native', - 'native': { - 'image': { - 'url': 'https://img.scupio.com/test/test-image.jpg', - 'width': 150, - 'height': 150 - }, - 'title': 'test-title', - 'sponsoredBy': 'test-sponsoredBy', - 'body': 'test-body', - 'icon': { - 'url': 'https://img.scupio.com/test/test-icon.jpg', - 'width': 50, - 'height': 50 - }, - 'clickUrl': 'https://img.scupio.com/test-clickUrl', - 'clickTrackers': ['https://img.scupio.com/test-clickTracker'], - 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker'] - }, - 'ttl': 360, - 'netRevenue': true, - 'currency': 'NTD' - } - ]; - - it('should return all required parameters', function () { - const result = spec.interpretResponse({'body': serverResponses}, request); - result.every(res => expect(res.cpm).to.be.a('number')); - result.every(res => expect(res.width).to.be.a('number')); - result.every(res => expect(res.height).to.be.a('number')); - result.every(res => expect(res.ttl).to.be.a('number')); - result.every(res => expect(res.netRevenue).to.be.a('boolean')); - result.every(res => expect(res.currency).to.be.a('string')); - result.every(res => { - if (res.ad) { - expect(res.ad).to.be.an('string'); - } else if (res.native) { - expect(res.native).to.be.an('object'); - } - }); - }); - - it('should give up bid if server response is undefiend', function () { - const result = spec.interpretResponse({'body': undefined}, request); - expect(result).to.deep.equal([]); - }); - - it('should give up bid if request sizes is missing', function () { - let target = Object.assign({}, serverResponses[0]); - target.consumed = false; - const result = spec.interpretResponse({'body': [target]}, spec.buildRequests([{ - 'bidder': 'bridgewell', - 'params': { - 'ChannelID': 'CLJgEAYYvxUiBXBlbm55KgkIrAIQ-gEaATk' - }, - 'adUnitCode': 'adunit-code-1', - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - }])); - expect(result).to.deep.equal([]); - }); - - it('should give up bid if response sizes is invalid', function () { - let target = { - 'id': 'e5b10774-32bf-4931-85ee-05095e8cff21', - 'bidder_code': 'bridgewell', - 'cpm': 5.0, - 'width': 1, - 'height': 1, - 'ad': '
test 300x250
', - 'ttl': 360, - 'netRevenue': true, - 'currency': 'NTD' - }; - - const result = spec.interpretResponse({'body': [target]}, request); - expect(result).to.deep.equal([]); - }); - - it('should give up bid if cpm is missing', function () { - let target = { - 'id': 'e5b10774-32bf-4931-85ee-05095e8cff21', - 'bidder_code': 'bridgewell', - 'width': 300, - 'height': 250, - 'ad': '
test 300x250
', - 'ttl': 360, - 'netRevenue': true, - 'currency': 'NTD' - }; - - const result = spec.interpretResponse({'body': [target]}, request); - expect(result).to.deep.equal([]); - }); - - it('should give up bid if width or height is missing', function () { - let target = { - 'id': 'e5b10774-32bf-4931-85ee-05095e8cff21', - 'bidder_code': 'bridgewell', - 'cpm': 5.0, - 'ad': '
test 300x250
', - 'ttl': 360, - 'netRevenue': true, - 'currency': 'NTD' - }; - - const result = spec.interpretResponse({'body': [target]}, request); - expect(result).to.deep.equal([]); - }); - - it('should give up bid if ad is missing', function () { - let target = { - 'id': 'e5b10774-32bf-4931-85ee-05095e8cff21', - 'bidder_code': 'bridgewell', - 'cpm': 5.0, - 'width': 300, - 'height': 250, - 'mediaType': 'banner', - 'ttl': 360, - 'netRevenue': true, - 'currency': 'NTD' - }; - - const result = spec.interpretResponse({'body': [target]}, request); - expect(result).to.deep.equal([]); - }); - - it('should give up bid if revenue mode is missing', function () { - let target = { - 'id': 'e5b10774-32bf-4931-85ee-05095e8cff21', - 'bidder_code': 'bridgewell', - 'cpm': 5.0, - 'width': 300, - 'height': 250, - 'ad': '
test 300x250
', - 'ttl': 360, - 'currency': 'NTD' - }; - - const result = spec.interpretResponse({'body': [target]}, request); - expect(result).to.deep.equal([]); - }); - - it('should give up bid if currency is missing', function () { - let target = { - 'id': 'e5b10774-32bf-4931-85ee-05095e8cff21', - 'bidder_code': 'bridgewell', - 'cpm': 5.0, - 'width': 300, - 'height': 250, - 'ad': '
test 300x250
', - 'ttl': 360, - 'netRevenue': true - }; - - const result = spec.interpretResponse({'body': [target]}, request); - expect(result).to.deep.equal([]); - }); - - it('should give up bid if mediaType is missing', function () { - let target = { - 'id': 'e5b10774-32bf-4931-85ee-05095e8cff21', - 'bidder_code': 'bridgewell', - 'cpm': 5.0, - 'width': 300, - 'height': 250, - 'ad': '
test 300x250
', - 'ttl': 360, - 'netRevenue': true, - 'currency': 'NTD' - }; - - const result = spec.interpretResponse({'body': [target]}, request); - expect(result).to.deep.equal([]); - }); - - it('should give up bid if property native of mediaType native is missing', function () { - let target = { - 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', - 'bidder_code': 'bridgewell', - 'cpm': 5.0, - 'width': 1, - 'height': 1, - 'mediaType': 'native', - 'ttl': 360, - 'netRevenue': true, - 'currency': 'NTD' - }; - - const result = spec.interpretResponse({'body': [target]}, request); - expect(result).to.deep.equal([]); - }); - - it('should give up bid if native title is missing', function () { - let target = { - 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', - 'bidder_code': 'bridgewell', - 'cpm': 5.0, - 'width': 1, - 'height': 1, - 'mediaType': 'native', - 'native': { - 'image': { - 'url': 'https://img.scupio.com/test/test-image.jpg', - 'width': 150, - 'height': 150 - }, - 'sponsoredBy': 'test-sponsoredBy', - 'body': 'test-body', - 'icon': { - 'url': 'https://img.scupio.com/test/test-icon.jpg', - 'width': 50, - 'height': 50 - }, - 'clickUrl': 'https://img.scupio.com/test-clickUrl', - 'clickTrackers': ['https://img.scupio.com/test-clickTracker'], - 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker'] - }, - 'ttl': 360, - 'netRevenue': true, - 'currency': 'NTD' - }; - - const result = spec.interpretResponse({'body': [target]}, request); - expect(result).to.deep.equal([]); - }); - - it('should give up bid if native title is too long', function () { - let target = { - 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', - 'bidder_code': 'bridgewell', - 'cpm': 5.0, - 'width': 1, - 'height': 1, - 'mediaType': 'native', - 'native': { - 'image': { - 'url': 'https://img.scupio.com/test/test-image.jpg', - 'width': 150, - 'height': 150 - }, - 'title': 'test-titletest-title', - 'sponsoredBy': 'test-sponsoredBy', - 'body': 'test-body', - 'icon': { - 'url': 'https://img.scupio.com/test/test-icon.jpg', - 'width': 50, - 'height': 50 - }, - 'clickUrl': 'https://img.scupio.com/test-clickUrl', - 'clickTrackers': ['https://img.scupio.com/test-clickTracker'], - 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker'] - }, - 'ttl': 360, - 'netRevenue': true, - 'currency': 'NTD' - }; - - const result = spec.interpretResponse({'body': [target]}, request); - expect(result).to.deep.equal([]); - }); - - it('should give up bid if native body is missing', function () { - let target = { - 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', - 'bidder_code': 'bridgewell', - 'cpm': 5.0, - 'width': 1, - 'height': 1, - 'mediaType': 'native', - 'native': { - 'image': { - 'url': 'https://img.scupio.com/test/test-image.jpg', - 'width': 150, - 'height': 150 - }, - 'title': 'test-title', - 'sponsoredBy': 'test-sponsoredBy', - 'icon': { - 'url': 'https://img.scupio.com/test/test-icon.jpg', - 'width': 50, - 'height': 50 - }, - 'clickUrl': 'https://img.scupio.com/test-clickUrl', - 'clickTrackers': ['https://img.scupio.com/test-clickTracker'], - 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker'] - }, - 'ttl': 360, - 'netRevenue': true, - 'currency': 'NTD' - }; - - const result = spec.interpretResponse({'body': [target]}, request); - expect(result).to.deep.equal([]); - - it('should give up bid if native image url is missing', function () { - let target = { - 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', - 'bidder_code': 'bridgewell', - 'cpm': 5.0, - 'width': 1, - 'height': 1, - 'mediaType': 'native', - 'native': { - 'image': { - 'width': 150, - 'height': 150 - }, - 'title': 'test-title', - 'sponsoredBy': 'test-sponsoredBy', - 'body': 'test-body', - 'icon': { - 'url': 'https://img.scupio.com/test/test-icon.jpg', - 'width': 50, - 'height': 50 - }, - 'clickUrl': 'https://img.scupio.com/test-clickUrl', - 'clickTrackers': ['https://img.scupio.com/test-clickTracker'], - 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker'] - }, - 'ttl': 360, - 'netRevenue': true, - 'currency': 'NTD' - }; - - const result = spec.interpretResponse({'body': [target]}, request); - expect(result).to.deep.equal([]); - }); - }); - - it('should give up bid if native image is missing', function () { - let target = { - 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', - 'bidder_code': 'bridgewell', - 'cpm': 5.0, - 'width': 1, - 'height': 1, - 'mediaType': 'native', - 'native': { - 'title': 'test-title', - 'sponsoredBy': 'test-sponsoredBy', - 'body': 'test-body', - 'icon': { - 'url': 'https://img.scupio.com/test/test-icon.jpg', - 'width': 50, - 'height': 50 - }, - 'clickUrl': 'https://img.scupio.com/test-clickUrl', - 'clickTrackers': ['https://img.scupio.com/test-clickTracker'], - 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker'] - }, - 'ttl': 360, - 'netRevenue': true, - 'currency': 'NTD' - }; - - const result = spec.interpretResponse({'body': [target]}, request); - expect(result).to.deep.equal([]); - }); - - it('should give up bid if native image url is missing', function () { - let target = { - 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', - 'bidder_code': 'bridgewell', - 'cpm': 5.0, - 'width': 1, - 'height': 1, - 'mediaType': 'native', - 'native': { - 'image': { - }, - 'title': 'test-title', - 'sponsoredBy': 'test-sponsoredBy', - 'body': 'test-body', - 'icon': { - 'url': 'https://img.scupio.com/test/test-icon.jpg', - 'width': 50, - 'height': 50 - }, - 'clickUrl': 'https://img.scupio.com/test-clickUrl', - 'clickTrackers': ['https://img.scupio.com/test-clickTracker'], - 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker'] - }, - 'ttl': 360, - 'netRevenue': true, - 'currency': 'NTD' - }; - - const result = spec.interpretResponse({'body': [target]}, request); - expect(result).to.deep.equal([]); - }); - - it('should give up bid if native image sizes is unmatch', function () { - let target = { - 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', - 'bidder_code': 'bridgewell', - 'cpm': 5.0, - 'width': 1, - 'height': 1, - 'mediaType': 'native', - 'native': { - 'image': { - 'url': 'https://img.scupio.com/test/test-image.jpg' - }, - 'title': 'test-title', - 'sponsoredBy': 'test-sponsoredBy', - 'body': 'test-body', - 'icon': { - 'url': 'https://img.scupio.com/test/test-icon.jpg', - 'width': 50, - 'height': 50 - }, - 'clickUrl': 'https://img.scupio.com/test-clickUrl', - 'clickTrackers': ['https://img.scupio.com/test-clickTracker'], - 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker'] - }, - 'ttl': 360, - 'netRevenue': true, - 'currency': 'NTD' - }; - - const result = spec.interpretResponse({'body': [target]}, request); - expect(result).to.deep.equal([]); - }); - - it('should give up bid if native sponsoredBy is missing', function () { - let target = { - 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', - 'bidder_code': 'bridgewell', - 'cpm': 5.0, - 'width': 1, - 'height': 1, - 'mediaType': 'native', - 'native': { - 'image': { - 'url': 'https://img.scupio.com/test/test-image.jpg', - 'width': 150, - 'height': 150 - }, - 'title': 'test-title', - 'body': 'test-body', - 'icon': { - 'url': 'https://img.scupio.com/test/test-icon.jpg', - 'width': 50, - 'height': 50 - }, - 'clickUrl': 'https://img.scupio.com/test-clickUrl', - 'clickTrackers': ['https://img.scupio.com/test-clickTracker'], - 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker'] - }, - 'ttl': 360, - 'netRevenue': true, - 'currency': 'NTD' - }; - - const result = spec.interpretResponse({'body': [target]}, request); - expect(result).to.deep.equal([]); - }); - - it('should give up bid if native icon is missing', function () { - let target = { - 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', - 'bidder_code': 'bridgewell', - 'cpm': 5.0, - 'width': 1, - 'height': 1, - 'mediaType': 'native', - 'native': { - 'image': { - 'url': 'https://img.scupio.com/test/test-image.jpg', - 'width': 150, - 'height': 150 - }, - 'title': 'test-title', - 'sponsoredBy': 'test-sponsoredBy', - 'body': 'test-body', - 'clickUrl': 'https://img.scupio.com/test-clickUrl', - 'clickTrackers': ['https://img.scupio.com/test-clickTracker'], - 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker'] - }, - 'ttl': 360, - 'netRevenue': true, - 'currency': 'NTD' - }; - - const result = spec.interpretResponse({'body': [target]}, request); - expect(result).to.deep.equal([]); - }); - - it('should give up bid if native icon url is missing', function () { - let target = { - 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', - 'bidder_code': 'bridgewell', - 'cpm': 5.0, - 'width': 1, - 'height': 1, - 'mediaType': 'native', - 'native': { - 'image': { - 'url': 'https://img.scupio.com/test/test-image.jpg', - 'width': 150, - 'height': 150 - }, - 'title': 'test-title', - 'sponsoredBy': 'test-sponsoredBy', - 'body': 'test-body', - 'icon': { - 'width': 50, - 'height': 50 - }, - 'clickUrl': 'https://img.scupio.com/test-clickUrl', - 'clickTrackers': ['https://img.scupio.com/test-clickTracker'], - 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker'] - }, - 'ttl': 360, - 'netRevenue': true, - 'currency': 'NTD' - }; - - const result = spec.interpretResponse({'body': [target]}, request); - expect(result).to.deep.equal([]); - }); - - it('should give up bid if native icon sizes is unmatch', function () { - let target = { - 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', - 'bidder_code': 'bridgewell', - 'cpm': 5.0, - 'width': 1, - 'height': 1, - 'mediaType': 'native', - 'native': { - 'image': { - 'url': 'https://img.scupio.com/test/test-image.jpg', - 'width': 150, - 'height': 150 - }, - 'title': 'test-title', - 'sponsoredBy': 'test-sponsoredBy', - 'body': 'test-body', - 'icon': { - 'url': 'https://img.scupio.com/test/test-icon.jpg' - }, - 'clickUrl': 'https://img.scupio.com/test-clickUrl', - 'clickTrackers': ['https://img.scupio.com/test-clickTracker'], - 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker'] - }, - 'ttl': 360, - 'netRevenue': true, - 'currency': 'NTD' - }; - - const result = spec.interpretResponse({'body': [target]}, request); - expect(result).to.deep.equal([]); - }); - - it('should give up bid if native clickUrl is missing', function () { - let target = { - 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', - 'bidder_code': 'bridgewell', - 'cpm': 5.0, - 'width': 1, - 'height': 1, - 'mediaType': 'native', - 'native': { - 'image': { - 'url': 'https://img.scupio.com/test/test-image.jpg', - 'width': 150, - 'height': 150 - }, - 'title': 'test-title', - 'sponsoredBy': 'test-sponsoredBy', - 'body': 'test-body', - 'icon': { - 'url': 'https://img.scupio.com/test/test-icon.jpg', - 'width': 50, - 'height': 50 - }, - 'clickTrackers': ['https://img.scupio.com/test-clickTracker'], - 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker'] - }, - 'ttl': 360, - 'netRevenue': true, - 'currency': 'NTD' - }; - - const result = spec.interpretResponse({'body': [target]}, request); - expect(result).to.deep.equal([]); - }); - - it('should give up bid if native clickTrackers is missing', function () { - let target = { - 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', - 'bidder_code': 'bridgewell', - 'cpm': 5.0, - 'width': 1, - 'height': 1, - 'mediaType': 'native', - 'native': { - 'image': { - 'url': 'https://img.scupio.com/test/test-image.jpg', - 'width': 150, - 'height': 150 - }, - 'title': 'test-title', - 'sponsoredBy': 'test-sponsoredBy', - 'body': 'test-body', - 'icon': { - 'url': 'https://img.scupio.com/test/test-icon.jpg', - 'width': 50, - 'height': 50 - }, - 'clickUrl': 'https://img.scupio.com/test-clickUrl', - 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker'] - }, - 'ttl': 360, - 'netRevenue': true, - 'currency': 'NTD' - }; - - const result = spec.interpretResponse({'body': [target]}, request); - expect(result).to.deep.equal([]); - }); - - it('should give up bid if native clickTrackers is empty', function () { - let target = { - 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', - 'bidder_code': 'bridgewell', - 'cpm': 5.0, - 'width': 1, - 'height': 1, - 'mediaType': 'native', - 'native': { - 'image': { - 'url': 'https://img.scupio.com/test/test-image.jpg', - 'width': 150, - 'height': 150 - }, - 'title': 'test-title', - 'sponsoredBy': 'test-sponsoredBy', - 'body': 'test-body', - 'icon': { - 'url': 'https://img.scupio.com/test/test-icon.jpg', - 'width': 50, - 'height': 50 - }, - 'clickUrl': 'https://img.scupio.com/test-clickUrl', - 'clickTrackers': [], - 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker'] - }, - 'ttl': 360, - 'netRevenue': true, - 'currency': 'NTD' - }; - - const result = spec.interpretResponse({'body': [target]}, request); - expect(result).to.deep.equal([]); - }); - - it('should give up bid if native impressionTrackers is missing', function () { - let target = { - 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', - 'bidder_code': 'bridgewell', - 'cpm': 5.0, - 'width': 1, - 'height': 1, - 'mediaType': 'native', - 'native': { - 'image': { - 'url': 'https://img.scupio.com/test/test-image.jpg', - 'width': 150, - 'height': 150 - }, - 'title': 'test-title', - 'sponsoredBy': 'test-sponsoredBy', - 'body': 'test-body', - 'icon': { - 'url': 'https://img.scupio.com/test/test-icon.jpg', - 'width': 50, - 'height': 50 - }, - 'clickUrl': 'https://img.scupio.com/test-clickUrl', - 'clickTrackers': ['https://img.scupio.com/test-clickTracker'] - }, - 'ttl': 360, - 'netRevenue': true, - 'currency': 'NTD' - }; - - const result = spec.interpretResponse({'body': [target]}, request); - expect(result).to.deep.equal([]); - }); - - it('should give up bid if native impressionTrackers is empty', function () { - let target = { - 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', - 'bidder_code': 'bridgewell', - 'cpm': 5.0, - 'width': 1, - 'height': 1, - 'mediaType': 'native', - 'native': { - 'image': { - 'url': 'https://img.scupio.com/test/test-image.jpg', - 'width': 150, - 'height': 150 - }, - 'title': 'test-title', - 'sponsoredBy': 'test-sponsoredBy', - 'body': 'test-body', - 'icon': { - 'url': 'https://img.scupio.com/test/test-icon.jpg', - 'width': 50, - 'height': 50 - }, - 'clickUrl': 'https://img.scupio.com/test-clickUrl', - 'clickTrackers': ['https://img.scupio.com/test-clickTracker'], - 'impressionTrackers': [] - }, - 'ttl': 360, - 'netRevenue': true, - 'currency': 'NTD' - }; - - const result = spec.interpretResponse({'body': [target]}, request); - expect(result).to.deep.equal([]); - }); - - it('should give up bid if mediaType is not support', function () { - let target = { - 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', - 'bidder_code': 'bridgewell', - 'cpm': 5.0, - 'width': 1, - 'height': 1, - 'mediaType': 'superNiceAd', - 'ttl': 360, - 'netRevenue': true, - 'currency': 'NTD' - }; - - const result = spec.interpretResponse({'body': [target]}, request); - expect(result).to.deep.equal([]); - }); - }); -}); diff --git a/test/spec/modules/bucksenseBidAdapter_spec.js b/test/spec/modules/bucksenseBidAdapter_spec.js index 17b5c3ceff5f..b9da6c077b26 100644 --- a/test/spec/modules/bucksenseBidAdapter_spec.js +++ b/test/spec/modules/bucksenseBidAdapter_spec.js @@ -75,11 +75,11 @@ describe('Bucksense Adapter', function() { 'auctionStart': 1557176022728, 'timeout': 1000, 'refererInfo': { - 'referer': 'http://stefanod.hera.pe/prebid/?pbjs_debug=true', + 'referer': 'https://stefanod.hera.pe/prebid/?pbjs_debug=true', 'reachedTop': true, 'numIframes': 0, 'stack': [ - 'http://stefanod.hera.pe/prebid/?pbjs_debug=true' + 'https://stefanod.hera.pe/prebid/?pbjs_debug=true' ] }, 'start': 1557176022731 @@ -109,7 +109,7 @@ describe('Bucksense Adapter', function() { 'pub_id': 'prebid.org', 'pl_id': '1000', 'secure': 0, - 'href': 'http://prebid.org/developers.html', + 'href': 'https://prebid.org/developers.html', 'bid_id': '27aaf8e96d9fd5', 'params': { 'placementId': '1000' diff --git a/test/spec/modules/c1xBidAdapter_spec.js b/test/spec/modules/c1xBidAdapter_spec.js index 268ad46d0ce9..a728e52dbc4d 100644 --- a/test/spec/modules/c1xBidAdapter_spec.js +++ b/test/spec/modules/c1xBidAdapter_spec.js @@ -106,13 +106,13 @@ describe('C1XAdapter', function () { { 'params': { 'siteId': '9999', - 'pageurl': 'http://c1exchange.com/' + 'pageurl': 'https://c1exchange.com/' } }); const request = c1xAdapter.buildRequests([bidRequest]); const originalPayload = parseRequest(request.data); const payloadObj = JSON.parse(originalPayload); - expect(payloadObj.pageurl).to.equal('http://c1exchange.com/'); + expect(payloadObj.pageurl).to.equal('https://c1exchange.com/'); }); it('should convert GDPR Consent to proper form and attach to request', function () { diff --git a/test/spec/modules/ccxBidAdapter_spec.js b/test/spec/modules/ccxBidAdapter_spec.js deleted file mode 100644 index a89a0402a97a..000000000000 --- a/test/spec/modules/ccxBidAdapter_spec.js +++ /dev/null @@ -1,403 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/ccxBidAdapter'; -import * as utils from 'src/utils'; - -describe('ccxAdapter', function () { - let bids = [ - { - adUnitCode: 'banner', - auctionId: '0b9de793-8eda-481e-a548-c187d58b28d9', - bidId: '2e56e1af51a5d7', - bidder: 'ccx', - bidderRequestId: '17e7b9f58a607e', - mediaTypes: { - banner: { - sizes: [[300, 250]] - } - }, - params: { - placementId: 607 - }, - sizes: [[300, 250]], - transactionId: 'aefddd38-cfa0-48ab-8bdd-325de4bab5f9' - }, - { - adUnitCode: 'video', - auctionId: '0b9de793-8eda-481e-a548-c187d58b28d9', - bidId: '3u94t90ut39tt3t', - bidder: 'ccx', - bidderRequestId: '23ur20r239r2r', - mediaTypes: { - video: { - playerSize: [[640, 480]] - } - }, - params: { - placementId: 608 - }, - sizes: [[640, 480]], - transactionId: 'aefddd38-cfa0-48ab-8bdd-325de4bab5f9' - } - ]; - describe('isBidRequestValid', function () { - it('Valid bid requests', function () { - expect(spec.isBidRequestValid(bids[0])).to.be.true; - expect(spec.isBidRequestValid(bids[1])).to.be.true; - }); - it('Invalid bid reqeusts - no placementId', function () { - let bidsClone = utils.deepClone(bids); - bidsClone[0].params = undefined; - expect(spec.isBidRequestValid(bidsClone[0])).to.be.false; - }); - it('Invalid bid reqeusts - invalid banner sizes', function () { - let bidsClone = utils.deepClone(bids); - bidsClone[0].mediaTypes.banner.sizes = [300, 250]; - expect(spec.isBidRequestValid(bidsClone[0])).to.be.false; - bidsClone[0].mediaTypes.banner.sizes = [[300, 250], [750]]; - expect(spec.isBidRequestValid(bidsClone[0])).to.be.false; - bidsClone[0].mediaTypes.banner.sizes = []; - expect(spec.isBidRequestValid(bidsClone[0])).to.be.false; - }); - it('Invalid bid reqeusts - invalid video sizes', function () { - let bidsClone = utils.deepClone(bids); - bidsClone[1].mediaTypes.video.playerSize = []; - expect(spec.isBidRequestValid(bidsClone[1])).to.be.false; - bidsClone[1].mediaTypes.video.sizes = [640, 480]; - expect(spec.isBidRequestValid(bidsClone[1])).to.be.false; - }); - it('Valid bid reqeust - old style sizes', function () { - let bidsClone = utils.deepClone(bids); - delete (bidsClone[0].mediaTypes); - delete (bidsClone[1].mediaTypes); - expect(spec.isBidRequestValid(bidsClone[0])).to.be.true; - expect(spec.isBidRequestValid(bidsClone[1])).to.be.true; - bidsClone[0].sizes = [300, 250]; - expect(spec.isBidRequestValid(bidsClone[0])).to.be.true; - }); - }); - describe('buildRequests', function () { - it('No valid bids', function () { - expect(spec.buildRequests([])).to.be.undefined; - }); - - it('Valid bid request - default', function () { - let response = spec.buildRequests(bids, {bids}); - expect(response).to.be.not.empty; - expect(response.data).to.be.not.empty; - - let data = JSON.parse(response.data); - - expect(data).to.be.an('object'); - expect(data).to.have.keys('site', 'imp', 'id', 'ext', 'device'); - - let imps = [ - { - banner: { - format: [ - { - w: 300, - h: 250 - } - ] - }, - ext: { - pid: 607 - }, - id: '2e56e1af51a5d7', - secure: 1 - }, - { - video: { - w: 640, - h: 480, - protocols: [2, 3, 5, 6], - mimes: ['video/mp4', 'video/x-flv'], - playbackmethod: [1, 2, 3, 4], - skip: 0 - }, - id: '3u94t90ut39tt3t', - secure: 1, - ext: { - pid: 608 - } - } - ]; - expect(data.imp).to.deep.have.same.members(imps); - }); - - it('Valid bid request - custom', function () { - let bidsClone = utils.deepClone(bids); - let imps = [ - { - banner: { - format: [ - { - w: 300, - h: 250 - } - ] - }, - ext: { - pid: 607 - }, - id: '2e56e1af51a5d7', - secure: 1 - }, - { - video: { - w: 640, - h: 480, - protocols: [5, 6], - mimes: ['video/mp4'], - playbackmethod: [3], - skip: 1, - skipafter: 5 - }, - id: '3u94t90ut39tt3t', - secure: 1, - ext: { - pid: 608 - } - } - ]; - - bidsClone[1].params.video = {}; - bidsClone[1].params.video.protocols = [5, 6]; - bidsClone[1].params.video.mimes = ['video/mp4']; - bidsClone[1].params.video.playbackmethod = [3]; - bidsClone[1].params.video.skip = 1; - bidsClone[1].params.video.skipafter = 5; - - let response = spec.buildRequests(bidsClone, {'bids': bidsClone}); - let data = JSON.parse(response.data); - - expect(data.imp).to.deep.have.same.members(imps); - }); - it('Valid bid request - sizes old style', function () { - let bidsClone = utils.deepClone(bids); - delete (bidsClone[0].mediaTypes); - delete (bidsClone[1].mediaTypes); - bidsClone[0].mediaType = 'banner'; - bidsClone[1].mediaType = 'video'; - - let imps = [ - { - banner: { - format: [ - { - w: 300, - h: 250 - } - ] - }, - ext: { - pid: 607 - }, - id: '2e56e1af51a5d7', - secure: 1 - }, - { - video: { - w: 640, - h: 480, - protocols: [2, 3, 5, 6], - mimes: ['video/mp4', 'video/x-flv'], - playbackmethod: [1, 2, 3, 4], - skip: 0 - }, - id: '3u94t90ut39tt3t', - secure: 1, - ext: { - pid: 608 - } - } - ]; - - let response = spec.buildRequests(bidsClone, {'bids': bidsClone}); - let data = JSON.parse(response.data); - - expect(data.imp).to.deep.have.same.members(imps); - }); - it('Valid bid request - sizes old style - no media type', function () { - let bidsClone = utils.deepClone(bids); - delete (bidsClone[0].mediaTypes); - delete (bidsClone[1]); - - let imps = [ - { - banner: { - format: [ - { - w: 300, - h: 250 - } - ] - }, - ext: { - pid: 607 - }, - id: '2e56e1af51a5d7', - secure: 1 - } - ]; - - let response = spec.buildRequests(bidsClone, {'bids': bidsClone}); - let data = JSON.parse(response.data); - - expect(data.imp).to.deep.have.same.members(imps); - }); - }); - - let response = { - id: '0b9de793-8eda-481e-a548-c187d58b28d9', - seatbid: [ - { - bid: [ - { - id: '2e56e1af51a5d7_221', - impid: '2e56e1af51a5d7', - price: 8.1, - adid: '221', - adm: '', - adomain: ['clickonometrics.com'], - crid: '221', - w: 300, - h: 250, - ext: { - type: 'standard' - } - }, - { - id: '2e56e1af51a5d8_222', - impid: '2e56e1af51a5d8', - price: 5.68, - adid: '222', - adm: '', - adomain: ['clickonometrics.com'], - crid: '222', - w: 640, - h: 480, - ext: { - type: 'video' - } - } - ] - } - ], - cur: 'PLN', - ext: { - ttl: 5, - usersync: [ - { - type: 'image', - url: 'http://foo.sync?param=1' - }, - { - type: 'iframe', - url: 'http://foo.sync?param=2' - } - ] - } - }; - - describe('interpretResponse', function () { - it('Valid bid response - multi', function () { - let bidResponses = [ - { - requestId: '2e56e1af51a5d7', - cpm: 8.1, - width: 300, - height: 250, - creativeId: '221', - netRevenue: false, - ttl: 5, - currency: 'PLN', - ad: '' - }, - { - requestId: '2e56e1af51a5d8', - cpm: 5.68, - width: 640, - height: 480, - creativeId: '222', - netRevenue: false, - ttl: 5, - currency: 'PLN', - vastXml: '' - } - ]; - expect(spec.interpretResponse({body: response})).to.deep.have.same.members(bidResponses); - }); - - it('Valid bid response - single', function () { - delete response.seatbid[0].bid[1]; - let bidResponses = [ - { - requestId: '2e56e1af51a5d7', - cpm: 8.1, - width: 300, - height: 250, - creativeId: '221', - netRevenue: false, - ttl: 5, - currency: 'PLN', - ad: '' - } - ]; - expect(spec.interpretResponse({body: response})).to.deep.have.same.members(bidResponses); - }); - - it('Empty bid response', function () { - expect(spec.interpretResponse({})).to.be.empty; - }); - }); - describe('getUserSyncs', function () { - it('Valid syncs - all', function () { - let syncOptions = { - iframeEnabled: true, - pixelEnabled: true - }; - - let expectedSyncs = [ - { - type: 'image', - url: 'http://foo.sync?param=1' - }, - { - type: 'iframe', - url: 'http://foo.sync?param=2' - } - ]; - expect(spec.getUserSyncs(syncOptions, [{body: response}])).to.deep.have.same.members(expectedSyncs); - }); - - it('Valid syncs - only image', function () { - let syncOptions = { - iframeEnabled: false, - pixelEnabled: true - }; - let expectedSyncs = [ - { - type: 'image', url: 'http://foo.sync?param=1' - } - ]; - expect(spec.getUserSyncs(syncOptions, [{body: response}])).to.deep.have.same.members(expectedSyncs); - }); - - it('Valid syncs - only iframe', function () { - let syncOptions = {iframeEnabled: true, pixelEnabled: false}; - let expectedSyncs = [ - { - type: 'iframe', url: 'http://foo.sync?param=2' - } - ]; - expect(spec.getUserSyncs(syncOptions, [{body: response}])).to.deep.have.same.members(expectedSyncs); - }); - - it('Valid syncs - empty', function () { - let syncOptions = {iframeEnabled: true, pixelEnabled: true}; - response.ext.usersync = {}; - expect(spec.getUserSyncs(syncOptions, [{body: response}])).to.be.empty; - }); - }); -}); diff --git a/test/spec/modules/cedatoBidAdapter_spec.js b/test/spec/modules/cedatoBidAdapter_spec.js index 969c06a64a29..d05f3e7abbf0 100644 --- a/test/spec/modules/cedatoBidAdapter_spec.js +++ b/test/spec/modules/cedatoBidAdapter_spec.js @@ -68,7 +68,7 @@ describe('the cedato adapter', function () { adomain: 'cedato.com', uuid: bid.bidId, crid: '1450133326', - adm: "
\n\n\n", + adm: "
\n\n\n", h: 250, w: 300, price: '0.1' diff --git a/test/spec/modules/cleanmedianetBidAdapter_spec.js b/test/spec/modules/cleanmedianetBidAdapter_spec.js deleted file mode 100644 index 09f76806fd70..000000000000 --- a/test/spec/modules/cleanmedianetBidAdapter_spec.js +++ /dev/null @@ -1,603 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/cleanmedianetBidAdapter'; -import { helper } from 'modules/cleanmedianetBidAdapter'; -import * as utils from 'src/utils'; -import { newBidder } from '../../../src/adapters/bidderFactory'; -import { deepClone } from 'src/utils'; - -const supplyPartnerId = '123'; -const adapter = newBidder(spec); -describe('CleanmedianetAdapter', function() { - describe('Is String start with search ', function() { - it('check if a string started with', function() { - expect(helper.startsWith('cleanmediaads.com', 'cleanmediaads')).to.equal( - true - ); - }); - }); - - describe('inherited functions', function() { - it('exists and is a function', function() { - expect(adapter.callBids).to.exist.and.to.be.a('function'); - }); - }); - - describe('isBidRequestValid', function() { - it('should validate supply-partner ID', function() { - expect(spec.isBidRequestValid({ params: {} })).to.equal(false); - expect( - spec.isBidRequestValid({ params: { supplyPartnerId: 123 } }) - ).to.equal(false); - expect( - spec.isBidRequestValid({ params: { supplyPartnerId: '123' } }) - ).to.equal(true); - }); - - it('should validate bid floor', function() { - expect( - spec.isBidRequestValid({ params: { supplyPartnerId: '123' } }) - ).to.equal(true); // bidfloor has a default - expect( - spec.isBidRequestValid({ - params: { supplyPartnerId: '123', bidfloor: '123' } - }) - ).to.equal(false); - expect( - spec.isBidRequestValid({ - params: { supplyPartnerId: '123', bidfloor: 0.1 } - }) - ).to.equal(true); - }); - - it('should validate adpos', function() { - expect( - spec.isBidRequestValid({ params: { supplyPartnerId: '123' } }) - ).to.equal(true); // adpos has a default - expect( - spec.isBidRequestValid({ - params: { supplyPartnerId: '123', adpos: '123' } - }) - ).to.equal(false); - expect( - spec.isBidRequestValid({ - params: { supplyPartnerId: '123', adpos: 0.1 } - }) - ).to.equal(true); - }); - - it('should validate instl', function() { - expect( - spec.isBidRequestValid({ params: { supplyPartnerId: '123' } }) - ).to.equal(true); // adpos has a default - expect( - spec.isBidRequestValid({ - params: { supplyPartnerId: '123', instl: '123' } - }) - ).to.equal(false); - expect( - spec.isBidRequestValid({ - params: { supplyPartnerId: '123', instl: -1 } - }) - ).to.equal(false); - expect( - spec.isBidRequestValid({ params: { supplyPartnerId: '123', instl: 0 } }) - ).to.equal(true); - expect( - spec.isBidRequestValid({ params: { supplyPartnerId: '123', instl: 1 } }) - ).to.equal(true); - expect( - spec.isBidRequestValid({ params: { supplyPartnerId: '123', instl: 2 } }) - ).to.equal(false); - }); - }); - - describe('buildRequests', function() { - const bidRequest = { - adUnitCode: 'adunit-code', - auctionId: '1d1a030790a475', - mediaTypes: { - banner: {} - }, - params: { - supplyPartnerId: supplyPartnerId - }, - sizes: [[300, 250], [300, 600]], - transactionId: 'a123456789', - refererInfo: { referer: 'http://examplereferer.com' }, - gdprConsent: { - consentString: 'some string', - gdprApplies: true - } - }; - it('returns an array', function() { - let response; - response = spec.buildRequests([]); - expect(Array.isArray(response)).to.equal(true); - expect(response.length).to.equal(0); - response = spec.buildRequests([bidRequest], bidRequest); - expect(Array.isArray(response)).to.equal(true); - expect(response.length).to.equal(1); - const adUnit1 = Object.assign({}, utils.deepClone(bidRequest), { - auctionId: '1', - adUnitCode: 'a' - }); - const adUnit2 = Object.assign({}, utils.deepClone(bidRequest), { - auctionId: '1', - adUnitCode: 'b' - }); - response = spec.buildRequests([adUnit1, adUnit2], bidRequest); - expect(Array.isArray(response)).to.equal(true); - expect(response.length).to.equal(2); - }); - - it('builds request correctly', function() { - let stub = sinon - .stub(utils, 'getTopWindowUrl') - .returns('http://www.test.com/page.html'); - let bidRequest2 = deepClone(bidRequest); - bidRequest2.refererInfo.referer = 'http://www.test.com/page.html'; - let response = spec.buildRequests([bidRequest], bidRequest2)[0]; - expect(response.data.site.domain).to.equal('www.test.com'); - expect(response.data.site.page).to.equal('http://www.test.com/page.html'); - expect(response.data.site.ref).to.equal('http://www.test.com/page.html'); - expect(response.data.imp.length).to.equal(1); - expect(response.data.imp[0].id).to.equal(bidRequest.transactionId); - expect(response.data.imp[0].instl).to.equal(0); - expect(response.data.imp[0].tagid).to.equal(bidRequest.adUnitCode); - expect(response.data.imp[0].bidfloor).to.equal(0); - expect(response.data.imp[0].bidfloorcur).to.equal('USD'); - const bidRequestWithInstlEquals1 = utils.deepClone(bidRequest); - bidRequestWithInstlEquals1.params.instl = 1; - response = spec.buildRequests( - [bidRequestWithInstlEquals1], - bidRequest2 - )[0]; - expect(response.data.imp[0].instl).to.equal( - bidRequestWithInstlEquals1.params.instl - ); - const bidRequestWithInstlEquals0 = utils.deepClone(bidRequest); - bidRequestWithInstlEquals0.params.instl = 1; - response = spec.buildRequests( - [bidRequestWithInstlEquals0], - bidRequest2 - )[0]; - expect(response.data.imp[0].instl).to.equal( - bidRequestWithInstlEquals0.params.instl - ); - const bidRequestWithBidfloorEquals1 = utils.deepClone(bidRequest); - bidRequestWithBidfloorEquals1.params.bidfloor = 1; - response = spec.buildRequests( - [bidRequestWithBidfloorEquals1], - bidRequest2 - )[0]; - expect(response.data.imp[0].bidfloor).to.equal( - bidRequestWithBidfloorEquals1.params.bidfloor - ); - stub.restore(); - }); - - it('builds request banner object correctly', function() { - let response; - const bidRequestWithBanner = utils.deepClone(bidRequest); - bidRequestWithBanner.mediaTypes = { - banner: { - sizes: [[300, 250], [120, 600]] - } - }; - response = spec.buildRequests([bidRequestWithBanner], bidRequest)[0]; - expect(response.data.imp[0].banner.w).to.equal( - bidRequestWithBanner.mediaTypes.banner.sizes[0][0] - ); - expect(response.data.imp[0].banner.h).to.equal( - bidRequestWithBanner.mediaTypes.banner.sizes[0][1] - ); - expect(response.data.imp[0].banner.pos).to.equal(0); - const bidRequestWithPosEquals1 = utils.deepClone(bidRequestWithBanner); - bidRequestWithPosEquals1.params.pos = 1; - response = spec.buildRequests([bidRequestWithPosEquals1], bidRequest)[0]; - expect(response.data.imp[0].banner.pos).to.equal( - bidRequestWithPosEquals1.params.pos - ); - }); - - it('builds request video object correctly', function() { - let response; - const bidRequestWithVideo = utils.deepClone(bidRequest); - bidRequestWithVideo.mediaTypes = { - video: { - sizes: [[300, 250], [120, 600]] - } - }; - response = spec.buildRequests([bidRequestWithVideo], bidRequest)[0]; - expect(response.data.imp[0].video.w).to.equal( - bidRequestWithVideo.mediaTypes.video.sizes[0][0] - ); - expect(response.data.imp[0].video.h).to.equal( - bidRequestWithVideo.mediaTypes.video.sizes[0][1] - ); - expect(response.data.imp[0].video.pos).to.equal(0); - const bidRequestWithPosEquals1 = utils.deepClone(bidRequestWithVideo); - bidRequestWithPosEquals1.params.pos = 1; - response = spec.buildRequests([bidRequestWithPosEquals1], bidRequest)[0]; - expect(response.data.imp[0].video.pos).to.equal( - bidRequestWithPosEquals1.params.pos - ); - }); - - it('builds request video object correctly with context', function() { - let response; - const bidRequestWithVideo = utils.deepClone(bidRequest); - bidRequestWithVideo.mediaTypes = { - video: { - context: 'instream' - } - }; - response = spec.buildRequests([bidRequestWithVideo], bidRequest)[0]; - expect(response.data.imp[0].video.ext.context).to.equal('instream'); - bidRequestWithVideo.mediaTypes.video.context = 'outstream'; - - const bidRequestWithPosEquals1 = utils.deepClone(bidRequestWithVideo); - bidRequestWithPosEquals1.mediaTypes.video.context = 'outstream'; - response = spec.buildRequests([bidRequestWithPosEquals1], bidRequest)[0]; - expect(response.data.imp[0].video.ext.context).to.equal('outstream'); - - const bidRequestWithPosEquals2 = utils.deepClone(bidRequestWithVideo); - bidRequestWithPosEquals2.mediaTypes.video.context = null; - response = spec.buildRequests([bidRequestWithPosEquals2], bidRequest)[0]; - expect(response.data.imp[0].video.ext.context).to.equal(null); - }); - it('builds request video object correctly with multi-dimensions size array', function () { - let bidRequestWithVideo = utils.deepClone(bidRequest); - bidRequestWithVideo.mediaTypes.video = { - playerSize: [[304, 254], [305, 255]], - context: 'instream' - }; - - let response = spec.buildRequests([bidRequestWithVideo], bidRequest)[0]; - expect(response.data.imp[1].video.w).to.equal(304); - expect(response.data.imp[1].video.h).to.equal(254); - - bidRequestWithVideo = utils.deepClone(bidRequest); - bidRequestWithVideo.mediaTypes.video = { - playerSize: [304, 254] - }; - - response = spec.buildRequests([bidRequestWithVideo], bidRequest)[0]; - expect(response.data.imp[1].video.w).to.equal(304); - expect(response.data.imp[1].video.h).to.equal(254); - }); - - it('builds request with gdpr consent', function() { - let response = spec.buildRequests([bidRequest], bidRequest)[0]; - expect(response.data.ext).to.have.property('gdpr_consent'); - expect(response.data.ext.gdpr_consent.consent_string).to.equal( - 'some string' - ); - expect(response.data.ext.gdpr_consent.consent_required).to.equal(true); - }); - }); - - describe('interpretResponse', function() { - const bannerBidRequest = { - adUnitCode: 'adunit-code', - auctionId: '1d1a030790a475', - mediaTypes: { - banner: {} - }, - params: { - supplyPartnerId: supplyPartnerId - }, - sizes: [[300, 250], [300, 600]], - transactionId: 'a123456789', - bidId: '111', - refererInfo: { referer: 'http://examplereferer.com' } - }; - - const videoBidRequest = { - adUnitCode: 'adunit-code', - auctionId: '1d1a030790a475', - mediaTypes: { - video: {} - }, - params: { - supplyPartnerId: supplyPartnerId - }, - sizes: [[300, 250], [300, 600]], - transactionId: 'a123456789', - bidId: '111', - refererInfo: { referer: 'http://examplereferer.com' } - }; - - const rtbResponse = { - id: 'imp_5b05b9fde4b09084267a556f', - bidid: 'imp_5b05b9fde4b09084267a556f', - cur: 'USD', - ext: { - utrk: [ - { type: 'iframe', url: '//bidder.cleanmediaads.com/user/sync/1' }, - { type: 'image', url: '//bidder.cleanmediaads.com/user/sync/2' } - ] - }, - seatbid: [ - { - seat: 'seat1', - group: 0, - bid: [ - { - id: '0', - impid: '1', - price: 2.016, - adid: '579ef31bfa788b9d2000d562', - nurl: - 'https://bidder.cleanmediaads.com/pix/monitoring/win_notice/imp_5b05b9fde4b09084267a556f/im.gif?r=imp_5b05b9fde4b09084267a556f&i=1&a=579ef31bfa788b9d2000d562&b=0&p=${AUCTION_PRICE}', - adm: - '', - adomain: ['aaa.com'], - cid: '579ef268fa788b9d2000d55c', - crid: '579ef31bfa788b9d2000d562', - attr: [], - h: 600, - w: 120, - ext: { - vast_url: 'http://my.vast.com', - utrk: [{ type: 'iframe', url: '//p.partner1.io/user/sync/1' }] - } - } - ] - }, - { - seat: 'seat2', - group: 0, - bid: [ - { - id: '1', - impid: '1', - price: 3, - adid: '542jlhdfd2112jnjf3x', - nurl: - 'https://bidder.cleanmediaads.com/pix/monitoring/win_notice/imp_5b05b9fde4b09084267a556f/im.gif?r=imp_5b05b9fde4b09084267a556f&i=1&a=579ef31bfa788b9d2000d562&b=0&p=${AUCTION_PRICE}', - adm: - ' ', - adomain: ['bbb.com'], - cid: 'fgdlwjh2498ydjhg1', - crid: 'kjh34297ydh2133d', - attr: [], - h: 250, - w: 300, - ext: { - utrk: [{ type: 'image', url: '//p.partner2.io/user/sync/1' }] - } - } - ] - } - ] - }; - - it('returns an empty array on missing response', function() { - let response; - - response = spec.interpretResponse(undefined, { - bidRequest: bannerBidRequest - }); - expect(Array.isArray(response)).to.equal(true); - expect(response.length).to.equal(0); - - response = spec.interpretResponse({}, { bidRequest: bannerBidRequest }); - expect(Array.isArray(response)).to.equal(true); - expect(response.length).to.equal(0); - }); - - it('aggregates banner bids from all seat bids', function() { - const response = spec.interpretResponse( - { body: rtbResponse }, - { bidRequest: bannerBidRequest } - ); - expect(Array.isArray(response)).to.equal(true); - expect(response.length).to.equal(1); - - const ad0 = response[0]; - expect(ad0.requestId).to.equal(bannerBidRequest.bidId); - expect(ad0.cpm).to.equal(rtbResponse.seatbid[1].bid[0].price); - expect(ad0.width).to.equal(rtbResponse.seatbid[1].bid[0].w); - expect(ad0.height).to.equal(rtbResponse.seatbid[1].bid[0].h); - expect(ad0.ttl).to.equal(60 * 10); - expect(ad0.creativeId).to.equal(rtbResponse.seatbid[1].bid[0].crid); - expect(ad0.netRevenue).to.equal(true); - expect(ad0.currency).to.equal( - rtbResponse.seatbid[1].bid[0].cur || rtbResponse.cur || 'USD' - ); - expect(ad0.ad).to.equal(rtbResponse.seatbid[1].bid[0].adm); - expect(ad0.vastXml).to.be.an('undefined'); - expect(ad0.vastUrl).to.be.an('undefined'); - }); - - it('aggregates video bids from all seat bids', function() { - const response = spec.interpretResponse( - { body: rtbResponse }, - { bidRequest: videoBidRequest } - ); - expect(Array.isArray(response)).to.equal(true); - expect(response.length).to.equal(1); - - const ad0 = response[0]; - expect(ad0.requestId).to.equal(videoBidRequest.bidId); - expect(ad0.cpm).to.equal(rtbResponse.seatbid[0].bid[0].price); - expect(ad0.width).to.equal(rtbResponse.seatbid[0].bid[0].w); - expect(ad0.height).to.equal(rtbResponse.seatbid[0].bid[0].h); - expect(ad0.ttl).to.equal(60 * 10); - expect(ad0.creativeId).to.equal(rtbResponse.seatbid[0].bid[0].crid); - expect(ad0.netRevenue).to.equal(true); - expect(ad0.currency).to.equal( - rtbResponse.seatbid[0].bid[0].cur || rtbResponse.cur || 'USD' - ); - expect(ad0.ad).to.be.an('undefined'); - expect(ad0.vastXml).to.equal(rtbResponse.seatbid[0].bid[0].adm); - expect(ad0.vastUrl).to.equal(rtbResponse.seatbid[0].bid[0].ext.vast_url); - }); - - it('aggregates user-sync pixels', function() { - const response = spec.getUserSyncs({}, [{ body: rtbResponse }]); - expect(Array.isArray(response)).to.equal(true); - expect(response.length).to.equal(4); - expect(response[0].type).to.equal(rtbResponse.ext.utrk[0].type); - expect(response[0].url).to.equal( - rtbResponse.ext.utrk[0].url + '?gc=missing' - ); - expect(response[1].type).to.equal(rtbResponse.ext.utrk[1].type); - expect(response[1].url).to.equal( - rtbResponse.ext.utrk[1].url + '?gc=missing' - ); - expect(response[2].type).to.equal( - rtbResponse.seatbid[0].bid[0].ext.utrk[0].type - ); - expect(response[2].url).to.equal( - rtbResponse.seatbid[0].bid[0].ext.utrk[0].url + '?gc=missing' - ); - expect(response[3].type).to.equal( - rtbResponse.seatbid[1].bid[0].ext.utrk[0].type - ); - expect(response[3].url).to.equal( - rtbResponse.seatbid[1].bid[0].ext.utrk[0].url + '?gc=missing' - ); - }); - - it('supports configuring outstream renderers', function() { - const videoResponse = { - id: '64f32497-b2f7-48ec-9205-35fc39894d44', - bidid: 'imp_5c24924de4b0d106447af333', - cur: 'USD', - seatbid: [ - { - seat: '3668', - group: 0, - bid: [ - { - id: 'gb_1', - impid: 'afbb5852-7cea-4a81-aa9a-a41aab505c23', - price: 5.0, - adid: '1274', - nurl: - 'https://bidder.cleanmediaads.com/pix/1275/win_notice/imp_5c24924de4b0d106447af333/im.gif?r=imp_5c24924de4b0d106447af333&i=afbb5852-7cea-4a81-aa9a-a41aab505c23&a=1274&b=gb_1&p=${AUCTION_PRICE}', - adomain: [], - adm: - '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n', - cid: '3668', - crid: '1274', - cat: [], - attr: [], - h: 250, - w: 300, - ext: { - vast_url: - 'https://bidder.cleanmediaads.com/pix/1275/vast_o/imp_5c24924de4b0d106447af333/im.xml?r=imp_5c24924de4b0d106447af333&i=afbb5852-7cea-4a81-aa9a-a41aab505c23&a=1274&b=gb_1&w=300&h=250&vatu=aHR0cHM6Ly9zdGF0aWMuZ2FtYmlkLmlvL2RlbW8vdmFzdC54bWw&vwarv', - imptrackers: [ - 'https://bidder.cleanmediaads.com/pix/1275/imp/imp_5c24924de4b0d106447af333/im.gif?r=imp_5c24924de4b0d106447af333&i=afbb5852-7cea-4a81-aa9a-a41aab505c23&a=1274&b=gb_1' - ] - } - } - ] - } - ], - ext: { - utrk: [ - { - type: 'image', - url: - 'https://bidder.cleanmediaads.com/pix/1275/scm?cb=1545900621675' - } - ] - } - }; - const videoRequest = deepClone(videoBidRequest); - videoRequest.mediaTypes.video.context = 'outstream'; - const result = spec.interpretResponse( - { body: videoResponse }, - { bidRequest: videoRequest } - ); - expect(result[0].renderer).to.not.equal(undefined); - }); - - it('validates in/existing of gdpr consent', function() { - let videoResponse = { - id: '64f32497-b2f7-48ec-9205-35fc39894d44', - bidid: 'imp_5c24924de4b0d106447af333', - cur: 'USD', - seatbid: [ - { - seat: '3668', - group: 0, - bid: [ - { - id: 'gb_1', - impid: 'afbb5852-7cea-4a81-aa9a-a41aab505c23', - price: 5.0, - adid: '1274', - nurl: - 'https://bidder.cleanmediaads.com/pix/1275/win_notice/imp_5c24924de4b0d106447af333/im.gif?r=imp_5c24924de4b0d106447af333&i=afbb5852-7cea-4a81-aa9a-a41aab505c23&a=1274&b=gb_1&p=${AUCTION_PRICE}', - adomain: [], - adm: - '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n', - cid: '3668', - crid: '1274', - cat: [], - attr: [], - h: 250, - w: 300, - ext: { - vast_url: - 'https://bidder.cleanmediaads.com/pix/1275/vast_o/imp_5c24924de4b0d106447af333/im.xml?r=imp_5c24924de4b0d106447af333&i=afbb5852-7cea-4a81-aa9a-a41aab505c23&a=1274&b=gb_1&w=300&h=250&vatu=aHR0cHM6Ly9zdGF0aWMuZ2FtYmlkLmlvL2RlbW8vdmFzdC54bWw&vwarv', - imptrackers: [ - 'https://bidder.cleanmediaads.com/pix/1275/imp/imp_5c24924de4b0d106447af333/im.gif?r=imp_5c24924de4b0d106447af333&i=afbb5852-7cea-4a81-aa9a-a41aab505c23&a=1274&b=gb_1' - ] - } - } - ] - } - ], - ext: { - utrk: [ - { - type: 'image', - url: - 'https://bidder.cleanmediaads.com/pix/1275/scm?cb=1545900621675' - } - ] - } - }; - let gdprConsent = { - gdprApplies: true, - consentString: 'consent string' - }; - let result = spec.getUserSyncs( - {}, - [{ body: videoResponse }], - gdprConsent - ); - expect(result).to.be.an('array'); - expect(result.length).to.equal(1); - expect(result[0].type).to.equal('image'); - expect(result[0].url).to.equal( - 'https://bidder.cleanmediaads.com/pix/1275/scm?cb=1545900621675&gc=consent%20string' - ); - - gdprConsent.gdprApplies = false; - result = spec.getUserSyncs({}, [{ body: videoResponse }], gdprConsent); - expect(result).to.be.an('array'); - expect(result.length).to.equal(1); - expect(result[0].type).to.equal('image'); - expect(result[0].url).to.equal( - 'https://bidder.cleanmediaads.com/pix/1275/scm?cb=1545900621675&gc=missing' - ); - - videoResponse.ext.utrk[0].url = - 'https://bidder.cleanmediaads.com/pix/1275/scm'; - result = spec.getUserSyncs({}, [{ body: videoResponse }], gdprConsent); - expect(result).to.be.an('array'); - expect(result.length).to.equal(1); - expect(result[0].type).to.equal('image'); - expect(result[0].url).to.equal( - 'https://bidder.cleanmediaads.com/pix/1275/scm?gc=missing' - ); - }); - }); -}); diff --git a/test/spec/modules/coinzillaBidAdapter_spec.js b/test/spec/modules/coinzillaBidAdapter_spec.js index 7a0c745d57d3..e9157e2a7353 100644 --- a/test/spec/modules/coinzillaBidAdapter_spec.js +++ b/test/spec/modules/coinzillaBidAdapter_spec.js @@ -57,8 +57,8 @@ describe('coinzillaBidAdapter', function () { 'refererInfo': { 'numIframes': 0, 'reachedTop': true, - 'referer': 'http://example.com', - 'stack': ['http://example.com'] + 'referer': 'https://example.com', + 'stack': ['https://example.com'] } }; diff --git a/test/spec/modules/collectcentBidAdapter_spec.js b/test/spec/modules/collectcentBidAdapter_spec.js index 04c819992cdd..7398c5c7dd93 100644 --- a/test/spec/modules/collectcentBidAdapter_spec.js +++ b/test/spec/modules/collectcentBidAdapter_spec.js @@ -38,7 +38,7 @@ describe('Collectcent', function () { expect(serverRequest.method).to.equal('POST'); }); it('Returns valid URL', function () { - expect(serverRequest.url).to.equal('//publishers.motionspots.com/?c=o&m=multi'); + expect(serverRequest.url).to.equal('https://publishers.motionspots.com/?c=o&m=multi'); }); it('Returns valid data if array of bids is valid', function () { let data = serverRequest.data; @@ -112,7 +112,7 @@ describe('Collectcent', function () { expect(userSync[0].type).to.exist; expect(userSync[0].url).to.exist; expect(userSync[0].type).to.be.equal('image'); - expect(userSync[0].url).to.be.equal('//publishers.motionspots.com/?c=o&m=cookie'); + expect(userSync[0].url).to.be.equal('https://publishers.motionspots.com/?c=o&m=cookie'); }); }); }); diff --git a/test/spec/modules/colombiaBidAdapter_spec.js b/test/spec/modules/colombiaBidAdapter_spec.js deleted file mode 100644 index 5a8678e866cb..000000000000 --- a/test/spec/modules/colombiaBidAdapter_spec.js +++ /dev/null @@ -1,152 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/colombiaBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; - -const HOST_NAME = document.location.protocol + '//' + window.location.host; -const ENDPOINT = 'https://ade.clmbtech.com/cde/prebid.htm'; - -describe('colombiaBidAdapter', function() { - const adapter = newBidder(spec); - - describe('isBidRequestValid', function () { - let bid = { - 'bidder': 'colombia', - 'params': { - placementId: '307466' - }, - 'adUnitCode': 'adunit-code', - 'sizes': [ - [300, 250] - ], - 'bidId': '23beaa6af6cdde', - 'bidderRequestId': '19c0c1efdf37e7', - 'auctionId': '61466567-d482-4a16-96f0-fe5f25ffbdf1', - }; - - it('should return true when required params found', function () { - expect(spec.isBidRequestValid(bid)).to.equal(true); - }); - - it('should return false when placementId not passed correctly', function () { - bid.params.placementId = ''; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - - it('should return false when require params are not passed', function () { - let bid = Object.assign({}, bid); - bid.params = {}; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - }); - - describe('buildRequests', function () { - let bidRequests = [ - { - 'bidder': 'colombia', - 'params': { - placementId: '307466' - }, - 'adUnitCode': 'adunit-code1', - 'sizes': [ - [300, 250] - ], - 'bidId': '23beaa6af6cdde', - 'bidderRequestId': '19c0c1efdf37e7', - 'auctionId': '61466567-d482-4a16-96f0-fe5f25ffbdf1', - }, - { - 'bidder': 'colombia', - 'params': { - placementId: '307466' - }, - 'adUnitCode': 'adunit-code2', - 'sizes': [ - [300, 250] - ], - 'bidId': '382091349b149f"', - 'bidderRequestId': '"1f9c98192de251"', - 'auctionId': '61466567-d482-4a16-96f0-fe5f25ffbdf1', - } - ]; - - const request = spec.buildRequests(bidRequests); - - it('sends bid request to our endpoint via POST', function () { - expect(request[0].method).to.equal('POST'); - expect(request[1].method).to.equal('POST'); - }); - - it('attaches source and version to endpoint URL as query params', function () { - expect(request[0].url).to.equal(ENDPOINT); - expect(request[1].url).to.equal(ENDPOINT); - }); - }); - - describe('interpretResponse', function () { - let bidRequest = [ - { - 'method': 'POST', - 'url': ENDPOINT, - 'data': { - 'v': 'hb1', - 'p': '307466', - 'w': '300', - 'h': '250', - 'cb': 12892917383, - 'r': 'http%3A%2F%2Flocalhost%3A9876%2F%3Fid%3D74552836', - 'uid': '23beaa6af6cdde', - 't': 'i', - 'd': HOST_NAME - } - } - ]; - - let serverResponse = { - body: { - 'ad': '
This is test case
', - 'cpm': 3.14, - 'creativeId': '6b958110-612c-4b03-b6a9-7436c9f746dc-1sk24', - 'currency': 'USD', - 'statusMessage': 'Bid available', - 'uid': '23beaa6af6cdde', - 'width': 300, - 'height': 250, - 'netRevenue': true, - 'ttl': 600 - } - }; - - it('should get the correct bid response', function () { - let expectedResponse = [{ - 'requestId': '23beaa6af6cdde', - 'cpm': 3.14, - 'width': 300, - 'height': 250, - 'creativeId': '6b958110-612c-4b03-b6a9-7436c9f746dc-1sk24', - 'dealId': '', - 'currency': 'USD', - 'netRevenue': true, - 'ttl': 3000, - 'referrer': '', - 'ad': '
This is test case
' - }]; - let result = spec.interpretResponse(serverResponse, bidRequest[0]); - expect(Object.keys(result)).to.deep.equal(Object.keys(expectedResponse)); - }); - - it('handles empty bid response', function () { - let response = { - body: { - 'uid': '2c0b634db95a01', - 'height': 0, - 'crid': '', - 'statusMessage': 'Bid returned empty or error response', - 'width': 0, - 'cpm': 0 - } - }; - let result = spec.interpretResponse(response, bidRequest[0]); - expect(result.length).to.equal(0); - }); - }); -}); diff --git a/test/spec/modules/contentigniteBidAdapter_spec.js b/test/spec/modules/contentigniteBidAdapter_spec.js deleted file mode 100644 index 1867791a2343..000000000000 --- a/test/spec/modules/contentigniteBidAdapter_spec.js +++ /dev/null @@ -1,186 +0,0 @@ -import { expect } from 'chai'; -import { spec } from '../../../modules/contentigniteBidAdapter'; - -describe('Content Ignite adapter', function () { - let bidRequests; - - beforeEach(function () { - bidRequests = [ - { - bidder: 'contentignite', - params: { - accountID: '168237', - zoneID: '299680', - keyword: 'business', - minCPM: '0.10', - maxCPM: '1.00' - }, - placementCode: '/19968336/header-bid-tag-1', - sizes: [[728, 90]], - bidId: '23acc48ad47af5', - auctionId: '0fb4905b-9456-4152-86be-c6f6d259ba99', - bidderRequestId: '1c56ad30b9b8ca8', - transactionId: '92489f71-1bf2-49a0-adf9-000cea934729' - } - ]; - }); - - describe('implementation', function () { - describe('for requests', function () { - it('should accept valid bid', function () { - const validBid = { - bidder: 'contentignite', - params: { - accountID: '168237', - zoneID: '299680' - } - }, - isValid = spec.isBidRequestValid(validBid); - - expect(isValid).to.equal(true); - }); - - it('should reject invalid bid', function () { - const invalidBid = { - bidder: 'contentignite', - params: { - accountID: '168237' - } - }, - isValid = spec.isBidRequestValid(invalidBid); - - expect(isValid).to.equal(false); - }); - - it('should set the keyword parameter', function () { - const requests = spec.buildRequests(bidRequests), - requestURL = requests[0].url; - - expect(requestURL).to.have.string(';kw=business;'); - }); - - it('should increment the count for the same zone', function () { - const bidRequests = [ - { - sizes: [[728, 90]], - bidder: 'contentignite', - params: { - accountID: '107878', - zoneID: '86133' - } - }, - { - sizes: [[728, 90]], - bidder: 'contentignite', - params: { - accountID: '107878', - zoneID: '86133' - } - } - ], - requests = spec.buildRequests(bidRequests), - firstRequest = requests[0].url, - secondRequest = requests[1].url; - - expect(firstRequest).to.have.string(';place=0;'); - expect(secondRequest).to.have.string(';place=1;'); - }); - }); - - describe('bid responses', function () { - it('should return complete bid response', function () { - const serverResponse = { - body: { - status: 'SUCCESS', - account_id: 107878, - zone_id: 86133, - cpm: 0.1, - width: 728, - height: 90, - place: 0, - ad_code: - '
', - tracking_pixels: [] - } - }, - bids = spec.interpretResponse(serverResponse, { - bidRequest: bidRequests[0] - }); - - expect(bids).to.be.lengthOf(1); - expect(bids[0].cpm).to.equal(0.1); - expect(bids[0].width).to.equal(728); - expect(bids[0].height).to.equal(90); - expect(bids[0].currency).to.equal('USD'); - expect(bids[0].netRevenue).to.equal(true); - expect(bids[0].ad).to.have.length.above(1); - }); - - it('should return empty bid response', function () { - const serverResponse = { - status: 'NO_ELIGIBLE_ADS', - zone_id: 299680, - width: 728, - height: 90, - place: 0 - }, - bids = spec.interpretResponse(serverResponse, { - bidRequest: bidRequests[0] - }); - - expect(bids).to.be.lengthOf(0); - }); - - it('should return empty bid response on incorrect size', function () { - const serverResponse = { - status: 'SUCCESS', - account_id: 168237, - zone_id: 299680, - cpm: 0.1, - width: 300, - height: 250, - place: 0 - }, - bids = spec.interpretResponse(serverResponse, { - bidRequest: bidRequests[0] - }); - - expect(bids).to.be.lengthOf(0); - }); - - it('should return empty bid response with CPM too low', function () { - const serverResponse = { - status: 'SUCCESS', - account_id: 168237, - zone_id: 299680, - cpm: 0.05, - width: 728, - height: 90, - place: 0 - }, - bids = spec.interpretResponse(serverResponse, { - bidRequest: bidRequests[0] - }); - - expect(bids).to.be.lengthOf(0); - }); - - it('should return empty bid response with CPM too high', function () { - const serverResponse = { - status: 'SUCCESS', - account_id: 168237, - zone_id: 299680, - cpm: 7.0, - width: 728, - height: 90, - place: 0 - }, - bids = spec.interpretResponse(serverResponse, { - bidRequest: bidRequests[0] - }); - - expect(bids).to.be.lengthOf(0); - }); - }); - }); -}); diff --git a/test/spec/modules/cosmosBidAdapter_spec.js b/test/spec/modules/cosmosBidAdapter_spec.js index 348f5ae3ddf3..7eb51c596e4a 100644 --- a/test/spec/modules/cosmosBidAdapter_spec.js +++ b/test/spec/modules/cosmosBidAdapter_spec.js @@ -87,7 +87,7 @@ describe('Cosmos adapter', function () { 'id': '82DAAE22-FF66-4FAB-84AB-347B0C5CD02C', 'impid': '39f5cc6eff9b37', 'price': 0.858309, - 'adm': 'CosmosHQVAST 2.0 Instream Test 1VAST 2.0 Instream Test 1https://track.cosmoshq.com/event?data=%7B%22id%22%3A%221566011421045%22%2C%22bid%22%3A%2282DAAE22-FF66-4FAB-84AB-347B0C5CD02C%22%2C%22ts%22%3A%2220190817031021%22%2C%22pid%22%3A1001%2C%22plcid%22%3A1%2C%22aid%22%3A1%2C%22did%22%3A1%2C%22cid%22%3A%2222918%22%2C%22af%22%3A3%2C%22at%22%3A1%2C%22w%22%3A300%2C%22h%22%3A250%2C%22crid%22%3A%22v55jutrh%22%2C%22pp%22%3A0.858309%2C%22cp%22%3A0.858309%2C%22mg%22%3A0%7D&type=1http://track.dsp.impression.com/impression00:00:60http://sync.cosmoshq.com/static/video/SampleVideo_1280x720_10mb.mp4', + 'adm': 'CosmosHQVAST 2.0 Instream Test 1VAST 2.0 Instream Test 1https://track.cosmoshq.com/event?data=%7B%22id%22%3A%221566011421045%22%2C%22bid%22%3A%2282DAAE22-FF66-4FAB-84AB-347B0C5CD02C%22%2C%22ts%22%3A%2220190817031021%22%2C%22pid%22%3A1001%2C%22plcid%22%3A1%2C%22aid%22%3A1%2C%22did%22%3A1%2C%22cid%22%3A%2222918%22%2C%22af%22%3A3%2C%22at%22%3A1%2C%22w%22%3A300%2C%22h%22%3A250%2C%22crid%22%3A%22v55jutrh%22%2C%22pp%22%3A0.858309%2C%22cp%22%3A0.858309%2C%22mg%22%3A0%7D&type=1https//track.dsp.impression.com/impression00:00:60https//sync.cosmoshq.com/static/video/SampleVideo_1280x720_10mb.mp4', 'adid': 'v55jutrh', 'adomain': ['febreze.com'], 'iurl': 'https://thetradedesk-t-general.s3.amazonaws.com/AdvertiserLogos/vgl908z.png', @@ -202,7 +202,7 @@ describe('Cosmos adapter', function () { it('build request object: endpoint check', function () { let request = spec.buildRequests(bannerBidRequests); - expect(request[0].url).to.equal('//bid.cosmoshq.com/openrtb2/bids'); + expect(request[0].url).to.equal('https://bid.cosmoshq.com/openrtb2/bids'); expect(request[0].method).to.equal('POST'); }); diff --git a/test/spec/modules/cpmstarBidAdapter_spec.js b/test/spec/modules/cpmstarBidAdapter_spec.js index 3dd06a484d93..d080a2570ab1 100755 --- a/test/spec/modules/cpmstarBidAdapter_spec.js +++ b/test/spec/modules/cpmstarBidAdapter_spec.js @@ -59,7 +59,7 @@ describe('Cpmstar Bid Adapter', function () { expect(requests[0]).to.have.property('method'); expect(requests[0]).to.have.property('url'); expect(requests[0]).to.have.property('bidRequest'); - expect(requests[0].url).to.include('//server.cpmstar.com/view.aspx'); + expect(requests[0].url).to.include('https://server.cpmstar.com/view.aspx'); }); it('should produce a valid staging request', function () { var stgReq = deepClone(valid_bid_requests); @@ -68,7 +68,7 @@ describe('Cpmstar Bid Adapter', function () { expect(requests[0]).to.have.property('method'); expect(requests[0]).to.have.property('url'); expect(requests[0]).to.have.property('bidRequest'); - expect(requests[0].url).to.include('//staging.server.cpmstar.com/view.aspx'); + expect(requests[0].url).to.include('https://staging.server.cpmstar.com/view.aspx'); }); it('should produce a valid dev request', function () { var devReq = deepClone(valid_bid_requests); @@ -77,7 +77,7 @@ describe('Cpmstar Bid Adapter', function () { expect(requests[0]).to.have.property('method'); expect(requests[0]).to.have.property('url'); expect(requests[0]).to.have.property('bidRequest'); - expect(requests[0].url).to.include('//dev.server.cpmstar.com/view.aspx'); + expect(requests[0].url).to.include('https://dev.server.cpmstar.com/view.aspx'); }); }) diff --git a/test/spec/modules/danmarketBidAdapter_spec.js b/test/spec/modules/danmarketBidAdapter_spec.js deleted file mode 100644 index 973cd2afb1c8..000000000000 --- a/test/spec/modules/danmarketBidAdapter_spec.js +++ /dev/null @@ -1,309 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/danmarketBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; - -describe('DAN_Marketplace Adapter', function () { - const adapter = newBidder(spec); - - describe('inherited functions', function () { - it('exists and is a function', function () { - expect(adapter.callBids).to.exist.and.to.be.a('function'); - }); - }); - - describe('isBidRequestValid', function () { - let bid = { - 'bidder': 'danmarket', - 'params': { - 'uid': '4' - }, - 'adUnitCode': 'adunit-code', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - }; - - it('should return true when required params found', function () { - expect(spec.isBidRequestValid(bid)).to.equal(true); - }); - - it('should return false when required params are not passed', function () { - let bid = Object.assign({}, bid); - delete bid.params; - bid.params = { - 'uid': 0 - }; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - }); - - describe('buildRequests', function () { - let bidRequests = [ - { - 'bidder': 'danmarket', - 'params': { - 'uid': '5' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - }, - { - 'bidder': 'danmarket', - 'params': { - 'uid': '5' - }, - 'adUnitCode': 'adunit-code-2', - 'sizes': [[728, 90]], - 'bidId': '3150ccb55da321', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - }, - { - 'bidder': 'danmarket', - 'params': { - 'uid': '6' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '42dbe3a7168a6a', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - } - ]; - - it('should attach valid params to the tag', function () { - const request = spec.buildRequests([bidRequests[0]]); - const payload = request.data; - expect(payload).to.be.an('object'); - expect(payload).to.have.property('u').that.is.a('string'); - expect(payload).to.have.property('pt', 'net'); - expect(payload).to.have.property('auids', '5'); - }); - - it('auids must not be duplicated', function () { - const request = spec.buildRequests(bidRequests); - const payload = request.data; - expect(payload).to.be.an('object'); - expect(payload).to.have.property('u').that.is.a('string'); - expect(payload).to.have.property('pt', 'net'); - expect(payload).to.have.property('auids', '5,6'); - }); - - it('pt parameter must be "gross" if params.priceType === "gross"', function () { - bidRequests[1].params.priceType = 'gross'; - const request = spec.buildRequests(bidRequests); - const payload = request.data; - expect(payload).to.be.an('object'); - expect(payload).to.have.property('u').that.is.a('string'); - expect(payload).to.have.property('pt', 'gross'); - expect(payload).to.have.property('auids', '5,6'); - delete bidRequests[1].params.priceType; - }); - - it('pt parameter must be "net" or "gross"', function () { - bidRequests[1].params.priceType = 'some'; - const request = spec.buildRequests(bidRequests); - const payload = request.data; - expect(payload).to.be.an('object'); - expect(payload).to.have.property('u').that.is.a('string'); - expect(payload).to.have.property('pt', 'net'); - expect(payload).to.have.property('auids', '5,6'); - delete bidRequests[1].params.priceType; - }); - - it('if gdprConsent is present payload must have gdpr params', function () { - const request = spec.buildRequests(bidRequests, {gdprConsent: {consentString: 'AAA', gdprApplies: true}}); - const payload = request.data; - expect(payload).to.be.an('object'); - expect(payload).to.have.property('gdpr_consent', 'AAA'); - expect(payload).to.have.property('gdpr_applies', 1); - }); - - it('if gdprApplies is false gdpr_applies must be 0', function () { - const request = spec.buildRequests(bidRequests, {gdprConsent: {consentString: 'AAA', gdprApplies: false}}); - const payload = request.data; - expect(payload).to.be.an('object'); - expect(payload).to.have.property('gdpr_consent', 'AAA'); - expect(payload).to.have.property('gdpr_applies', 0); - }); - - it('if gdprApplies is undefined gdpr_applies must be 1', function () { - const request = spec.buildRequests(bidRequests, {gdprConsent: {consentString: 'AAA'}}); - const payload = request.data; - expect(payload).to.be.an('object'); - expect(payload).to.have.property('gdpr_consent', 'AAA'); - expect(payload).to.have.property('gdpr_applies', 1); - }); - }); - - describe('interpretResponse', function () { - const responses = [ - {'bid': [{'price': 1.15, 'adm': '
test content 1
', 'auid': 4, 'h': 250, 'w': 300}], 'seat': '1'}, - {'bid': [{'price': 0.5, 'adm': '
test content 2
', 'auid': 5, 'h': 90, 'w': 728}], 'seat': '1'}, - {'bid': [{'price': 0, 'auid': 6, 'h': 250, 'w': 300}], 'seat': '1'}, - {'bid': [{'price': 0, 'adm': '
test content 4
', 'h': 250, 'w': 300}], 'seat': '1'}, - undefined, - {'bid': [], 'seat': '1'}, - {'seat': '1'}, - ]; - - it('should get correct bid response', function () { - const bidRequests = [ - { - 'bidder': 'danmarket', - 'params': { - 'uid': '4' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '659423fff799cb', - 'bidderRequestId': '5f2009617a7c0a', - 'auctionId': '1cbd2feafe5e8b', - } - ]; - const request = spec.buildRequests(bidRequests); - const expectedResponse = [ - { - 'requestId': '659423fff799cb', - 'cpm': 1.15, - 'creativeId': 4, - 'dealId': undefined, - 'width': 300, - 'height': 250, - 'ad': '
test content 1
', - 'currency': 'USD', - 'netRevenue': true, - 'ttl': 360, - } - ]; - - const result = spec.interpretResponse({'body': {'seatbid': [responses[0]]}}, request); - expect(result).to.deep.equal(expectedResponse); - }); - - it('should get correct multi bid response', function () { - const bidRequests = [ - { - 'bidder': 'danmarket', - 'params': { - 'uid': '4' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '300bfeb0d71a5b', - 'bidderRequestId': '2c2bb1972df9a', - 'auctionId': '1fa09aee5c8c99', - }, - { - 'bidder': 'danmarket', - 'params': { - 'uid': '5' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '4dff80cc4ee346', - 'bidderRequestId': '2c2bb1972df9a', - 'auctionId': '1fa09aee5c8c99', - }, - { - 'bidder': 'danmarket', - 'params': { - 'uid': '4' - }, - 'adUnitCode': 'adunit-code-2', - 'sizes': [[728, 90]], - 'bidId': '5703af74d0472a', - 'bidderRequestId': '2c2bb1972df9a', - 'auctionId': '1fa09aee5c8c99', - } - ]; - const request = spec.buildRequests(bidRequests); - const expectedResponse = [ - { - 'requestId': '300bfeb0d71a5b', - 'cpm': 1.15, - 'creativeId': 4, - 'dealId': undefined, - 'width': 300, - 'height': 250, - 'ad': '
test content 1
', - 'currency': 'USD', - 'netRevenue': true, - 'ttl': 360, - }, - { - 'requestId': '5703af74d0472a', - 'cpm': 1.15, - 'creativeId': 4, - 'dealId': undefined, - 'width': 300, - 'height': 250, - 'ad': '
test content 1
', - 'currency': 'USD', - 'netRevenue': true, - 'ttl': 360, - }, - { - 'requestId': '4dff80cc4ee346', - 'cpm': 0.5, - 'creativeId': 5, - 'dealId': undefined, - 'width': 728, - 'height': 90, - 'ad': '
test content 2
', - 'currency': 'USD', - 'netRevenue': true, - 'ttl': 360, - } - ]; - - const result = spec.interpretResponse({'body': {'seatbid': [responses[0], responses[1]]}}, request); - expect(result).to.deep.equal(expectedResponse); - }); - - it('handles wrong and nobid responses', function () { - const bidRequests = [ - { - 'bidder': 'danmarket', - 'params': { - 'uid': '6' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '300bfeb0d7190gf', - 'bidderRequestId': '2c2bb1972d23af', - 'auctionId': '1fa09aee5c84d34', - }, - { - 'bidder': 'danmarket', - 'params': { - 'uid': '7' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '300bfeb0d71321', - 'bidderRequestId': '2c2bb1972d23af', - 'auctionId': '1fa09aee5c84d34', - }, - { - 'bidder': 'danmarket', - 'params': { - 'uid': '8' - }, - 'adUnitCode': 'adunit-code-2', - 'sizes': [[728, 90]], - 'bidId': '300bfeb0d7183bb', - 'bidderRequestId': '2c2bb1972d23af', - 'auctionId': '1fa09aee5c84d34', - } - ]; - const request = spec.buildRequests(bidRequests); - const result = spec.interpretResponse({'body': {'seatbid': responses.slice(2)}}, request); - expect(result.length).to.equal(0); - }); - }); -}); diff --git a/test/spec/modules/datablocksBidAdapter_spec.js b/test/spec/modules/datablocksBidAdapter_spec.js index d39116ccb710..af0fd8a3bc9a 100644 --- a/test/spec/modules/datablocksBidAdapter_spec.js +++ b/test/spec/modules/datablocksBidAdapter_spec.js @@ -116,8 +116,8 @@ const bidderRequest = { refererInfo: { numIframes: 0, reachedTop: true, - referer: 'http://v5demo.datablocks.net/test', - stack: ['http://v5demo.datablocks.net/test'] + referer: 'https://v5demo.datablocks.net/test', + stack: ['https://v5demo.datablocks.net/test'] }, start: Date.now(), timeout: 10000 @@ -133,7 +133,7 @@ let resObject = { id: '1090738570', impid: '2966b257c81d27', price: 24.000000, - adm: '
RON', + adm: 'RON', cid: '55', adid: '177654', crid: '177656', @@ -145,7 +145,7 @@ let resObject = { id: '1090738571', impid: '2966b257c81d28', price: 24.000000, - adm: 'RON', + adm: 'RON', cid: '55', adid: '177654', crid: '177656', @@ -157,7 +157,7 @@ let resObject = { id: '1090738570', impid: '15d9012765e36c', price: 24.000000, - adm: '{"native":{"ver":"1.2","assets":[{"id":1,"required":1,"title":{"text":"Example Title"}},{"id":2,"required":1,"data":{"value":"Example Body"}},{"id":3,"required":1,"img":{"url":"http://example.image.com/"}}],"link":{"url":"http://click.example.com/c/264597/?fcid=29699699045816"},"imptrackers":["http://impression.example.com/i/264597/?fcid=29699699045816"]}}', + adm: '{"native":{"ver":"1.2","assets":[{"id":1,"required":1,"title":{"text":"Example Title"}},{"id":2,"required":1,"data":{"value":"Example Body"}},{"id":3,"required":1,"img":{"url":"https://example.image.com/"}}],"link":{"url":"https://click.example.com/c/264597/?fcid=29699699045816"},"imptrackers":["https://impression.example.com/i/264597/?fcid=29699699045816"]}}', cid: '132145', adid: '154321', crid: '177432', @@ -170,7 +170,7 @@ let resObject = { cid: '12345', adid: '12345', crid: '123456', - nurl: 'http://click.v5demo.datablocks.net/m//?fcid=435235435432', + nurl: 'https://click.v5demo.datablocks.net/m//?fcid=435235435432', cat: [], api: [], w: 500, @@ -183,7 +183,7 @@ let resObject = { }; let bidRequest = { method: 'POST', - url: '//v5demo.datablocks.net/search/?sid=7560', + url: 'https://v5demo.datablocks.net/search/?sid=7560', options: { withCredentials: false }, @@ -219,7 +219,7 @@ let bidRequest = { site: { domain: '', id: 'blank', - page: 'http://v5demo.datablocks.net/test' + page: 'https://v5demo.datablocks.net/test' } } } @@ -251,7 +251,7 @@ describe('DatablocksAdapter', function() { }); it('Returns valid URL', function() { expect(request.url).to.exist; - expect(request.url).to.equal('//v5demo.datablocks.net/search/?sid=7560'); + expect(request.url).to.equal('https://v5demo.datablocks.net/search/?sid=7560'); }); it('Should be a valid openRTB request', function() { diff --git a/test/spec/modules/decenteradsBidAdapter_spec.js b/test/spec/modules/decenteradsBidAdapter_spec.js deleted file mode 100644 index 3c8569b3b616..000000000000 --- a/test/spec/modules/decenteradsBidAdapter_spec.js +++ /dev/null @@ -1,207 +0,0 @@ -import { expect } from 'chai' -import { spec } from '../../../modules/decenteradsBidAdapter' -import { deepStrictEqual, notEqual, ok, strictEqual } from 'assert' - -describe('DecenteradsAdapter', () => { - const bid = { - bidId: '9ec5b177515ee2e5', - bidder: 'decenterads', - params: { - placementId: 0, - traffic: 'banner' - } - } - - describe('isBidRequestValid', () => { - it('Should return true if there are bidId, params and placementId parameters present', () => { - strictEqual(true, spec.isBidRequestValid(bid)) - }) - - it('Should return false if at least one of parameters is not present', () => { - const b = { ...bid } - delete b.params.placementId - strictEqual(false, spec.isBidRequestValid(b)) - }) - }) - - describe('buildRequests', () => { - const serverRequest = spec.buildRequests([bid]) - - it('Creates a ServerRequest object with method, URL and data', () => { - ok(serverRequest) - ok(serverRequest.method) - ok(serverRequest.url) - ok(serverRequest.data) - }) - - it('Returns POST method', () => { - strictEqual('POST', serverRequest.method) - }) - - it('Returns valid URL', () => { - strictEqual('//supply.decenterads.com/?c=o&m=multi', serverRequest.url) - }) - - it('Returns valid data if array of bids is valid', () => { - const { data } = serverRequest - strictEqual('object', typeof data) - deepStrictEqual(['deviceWidth', 'deviceHeight', 'language', 'secure', 'host', 'page', 'placements'], Object.keys(data)) - strictEqual('number', typeof data.deviceWidth) - strictEqual('number', typeof data.deviceHeight) - strictEqual('string', typeof data.language) - strictEqual('string', typeof data.host) - strictEqual('string', typeof data.page) - notEqual(-1, [0, 1].indexOf(data.secure)) - - const placement = data.placements[0] - deepStrictEqual(['placementId', 'bidId', 'traffic'], Object.keys(placement)) - strictEqual(0, placement.placementId) - strictEqual('9ec5b177515ee2e5', placement.bidId) - strictEqual('banner', placement.traffic) - }) - - it('Returns empty data if no valid requests are passed', () => { - const { placements } = spec.buildRequests([]).data - - expect(spec.buildRequests([]).data.placements).to.be.an('array') - strictEqual(0, placements.length) - }) - }) - - describe('interpretResponse', () => { - const validData = [ - { - body: [{ - mediaType: 'banner', - width: 300, - height: 250, - cpm: 0.4, - ad: 'Test', - requestId: '9ec5b177515ee2e5', - ttl: 120, - creativeId: '2', - netRevenue: true, - currency: 'USD', - dealId: '1' - }] - }, - { - body: [{ - vastUrl: 'decenterads.com', - mediaType: 'video', - cpm: 0.5, - requestId: '9ec5b177515ee2e5', - ttl: 120, - creativeId: '2', - netRevenue: true, - currency: 'USD', - dealId: '1' - }] - }, - { - body: [{ - mediaType: 'native', - clickUrl: 'decenterads.com', - title: 'Test', - image: 'decenterads.com', - creativeId: '2', - impressionTrackers: ['decenterads.com'], - ttl: 120, - cpm: 0.4, - requestId: '9ec5b177515ee2e5', - netRevenue: true, - currency: 'USD', - }] - } - ] - - for (const obj of validData) { - const { mediaType } = obj.body[0] - - it(`Should interpret ${mediaType} response`, () => { - const response = spec.interpretResponse(obj) - - expect(response).to.be.an('array') - strictEqual(1, response.length) - - const copy = { ...obj.body[0] } - delete copy.mediaType - deepStrictEqual(copy, response[0]) - }) - } - - const invalidData = [ - { - body: [{ - width: 300, - cpm: 0.4, - ad: 'Test', - requestId: '9ec5b177515ee2e5', - ttl: 120, - creativeId: '2', - netRevenue: true, - currency: 'USD', - dealId: '1' - }] - }, - { - body: [{ - mediaType: 'video', - cpm: 0.5, - requestId: '9ec5b177515ee2e5', - ttl: 120, - creativeId: '2', - netRevenue: true, - currency: 'USD', - dealId: '1' - }] - }, - { - body: [{ - mediaType: 'native', - clickUrl: 'decenterads.com', - title: 'Test', - impressionTrackers: ['decenterads.com'], - ttl: 120, - requestId: '9ec5b177515ee2e5', - creativeId: '2', - netRevenue: true, - currency: 'USD', - }] - } - ] - - for (const obj of invalidData) { - const { mediaType } = obj.body[0] - - it(`Should return an empty array if invalid ${mediaType} response is passed `, () => { - const response = spec.interpretResponse(obj) - - expect(response).to.be.an('array') - strictEqual(0, response.length) - }) - } - - it('Should return an empty array if invalid response is passed', () => { - const response = spec.interpretResponse({ - body: [{ - ttl: 120, - creativeId: '2', - netRevenue: true, - currency: 'USD', - dealId: '1' - }] - }) - - expect(response).to.be.an('array') - strictEqual(0, response.length) - }) - }) - - describe('getUserSyncs', () => { - it('Returns valid URL and type', () => { - const expectedResult = [{ type: 'image', url: '//supply.decenterads.com/?c=o&m=cookie' }] - deepStrictEqual(expectedResult, spec.getUserSyncs()) - }) - }) -}) diff --git a/test/spec/modules/dgadsBidAdapter_spec.js b/test/spec/modules/dgadsBidAdapter_spec.js deleted file mode 100644 index 2454885217df..000000000000 --- a/test/spec/modules/dgadsBidAdapter_spec.js +++ /dev/null @@ -1,299 +0,0 @@ -import {expect} from 'chai'; -import * as utils from 'src/utils'; -import {spec, getCookieUid} from 'modules/dgadsBidAdapter'; -import {newBidder} from 'src/adapters/bidderFactory'; -import { BANNER, NATIVE } from 'src/mediaTypes'; - -describe('dgadsBidAdapter', function () { - const adapter = newBidder(spec); - const UID_NAME = 'dgads_uid'; - const VALID_ENDPOINT = 'https://ads-tr.bigmining.com/ad/p/bid'; - - describe('inherited functions', function () { - it('exists and is a function', function () { - expect(adapter.callBids).to.exist.and.to.be.a('function'); - }); - }); - - describe('isBidRequestValid', function () { - let bid = { - 'bidder': 'dgads', - params: { - site_id: '1', - location_id: '1' - } - }; - it('should return true when required params found', function () { - expect(spec.isBidRequestValid(bid)).to.equal(true); - }); - - it('should return false when required params(location_id) are not passed', function () { - let bid = Object.assign({}, bid); - delete bid.params; - bid.params = { - site_id: '1' - }; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - - it('should return false when required params(site_id) are not passed', function () { - let bid = Object.assign({}, bid); - delete bid.params; - bid.params = { - location_id: '1' - }; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - }); - - describe('buildRequests', function () { - const bidRequests = [ - { // banner - bidder: 'dgads', - mediaType: 'banner', - params: { - site_id: '1', - location_id: '1' - }, - adUnitCode: 'adunit-code', - sizes: [[300, 250]], - bidId: '2db3101abaec66', - bidderRequestId: '14a9f773e30243', - auctionId: 'c0cd37c5-af11-464d-b83e-35863e533b1f', - transactionId: 'c1f1eff6-23c6-4844-a321-575212939e37' - }, - { // native - bidder: 'dgads', - sizes: [[300, 250]], - params: { - site_id: '1', - location_id: '10' - }, - mediaTypes: { - native: { - image: { - required: true - }, - title: { - required: true, - len: 25 - }, - clickUrl: { - required: true - }, - body: { - required: true, - len: 140 - }, - sponsoredBy: { - required: true, - len: 40 - } - }, - }, - adUnitCode: 'adunit-code', - bidId: '2db3101abaec66', - bidderRequestId: '14a9f773e30243', - auctionId: 'c0cd37c5-af11-464d-b83e-35863e533b1f', - transactionId: 'c1f1eff6-23c6-4844-a321-575212939e37' - } - ]; - it('no bidRequests', function () { - const noBidRequests = []; - expect(Object.keys(spec.buildRequests(noBidRequests)).length).to.equal(0); - }); - it('getCookieUid return empty if cookie not found', function () { - expect(getCookieUid(UID_NAME)).to.equal(''); - }); - const data = { - location_id: '1', - site_id: '1', - transaction_id: 'c1f1eff6-23c6-4844-a321-575212939e37', - bid_id: '2db3101abaec66', - referer: utils.getTopWindowUrl(), - _uid: '' - }; - it('sends bid request to VALID_ENDPOINT via GET', function () { - const request = spec.buildRequests(bidRequests)[0]; - expect(request.url).to.equal(VALID_ENDPOINT); - expect(request.method).to.equal('GET'); - }); - it('should attache params to the request', function () { - const request = spec.buildRequests(bidRequests)[0]; - expect(request.data['_loc']).to.equal(data['location_id']); - expect(request.data['_medium']).to.equal(data['site_id']); - expect(request.data['transaction_id']).to.equal(data['transaction_id']); - expect(request.data['bid_id']).to.equal(data['bid_id']); - expect(request.data['referer']).to.equal(data['referer']); - expect(request.data['_uid']).to.equal(data['_uid']); - }); - }); - - describe('interpretResponse', function () { - const bidRequests = { - banner: { - bidRequest: { - bidder: 'dgads', - params: { - location_id: '1', - site_id: '1' - }, - transactionId: 'c1f1eff6-23c6-4844-a321-575212939e37', - bidId: '2db3101abaec66', - adUnitCode: 'adunit-code', - sizes: [[300, 250]], - bidderRequestId: '14a9f773e30243', - auctionId: 'c0cd37c5-af11-464d-b83e-35863e533b1f' - }, - }, - native: { - bidRequest: { - bidder: 'adg', - params: { - site_id: '1', - location_id: '10' - }, - mediaTypes: { - native: { - image: { - required: true - }, - title: { - required: true, - len: 25 - }, - body: { - required: true, - len: 140 - }, - sponsoredBy: { - required: true, - len: 40 - } - } - }, - transactionId: 'f76f6dfd-d64f-4645-a29f-682bac7f431a', - bidId: '2f6ac468a9c15e', - adUnitCode: 'adunit-code', - sizes: [[1, 1]], - bidderRequestId: '14a9f773e30243', - auctionId: '4aae9f05-18c6-4fcd-80cf-282708cd584a', - }, - }, - }; - - const serverResponse = { - noAd: { - results: [], - }, - banner: { - bids: { - ads: { - ad: '', - cpm: 1.22, - w: 300, - h: 250, - creativeId: 'xuidx62944aab4fx37f', - ttl: 60, - bidId: '2f6ac468a9c15e' - } - } - }, - native: { - bids: { - ads: { - cpm: 1.22, - title: 'title', - desc: 'description', - sponsoredBy: 'sponsoredBy', - image: 'https://ads-tr.bigmining.com/img/300_250_1.jpg', - w: 300, - h: 250, - ttl: 60, - bidId: '2f6ac468a9c15e', - creativeId: 'xuidx62944aab4fx37f', - isNative: 1, - impressionTrackers: ['https://ads-tr.bigmining.com/ad/view/beacon.gif'], - clickTrackers: ['https://ads-tr.bigmining.com/ad/view/beacon.png'], - clickUrl: 'http://www.garage.co.jp/ja/' - }, - } - } - }; - - const bidResponses = { - banner: { - requestId: '2f6ac468a9c15e', - cpm: 1.22, - width: 300, - height: 250, - creativeId: 'xuidx62944aab4fx37f', - currency: 'JPY', - netRevenue: true, - ttl: 60, - referrer: utils.getTopWindowUrl(), - ad: '', - }, - native: { - requestId: '2f6ac468a9c15e', - cpm: 1.22, - creativeId: 'xuidx62944aab4fx37f', - currency: 'JPY', - netRevenue: true, - ttl: 60, - native: { - image: { - url: 'https://ads-tr.bigmining.com/img/300_250_1.jpg', - width: 300, - height: 250 - }, - title: 'title', - body: 'description', - sponsoredBy: 'sponsoredBy', - clickUrl: 'http://www.garage.co.jp/ja/', - impressionTrackers: ['https://ads-tr.bigmining.com/ad/view/beacon.gif'], - clickTrackers: ['https://ads-tr.bigmining.com/ad/view/beacon.png'] - }, - referrer: utils.getTopWindowUrl(), - creativeid: 'xuidx62944aab4fx37f', - mediaType: NATIVE - } - }; - - it('no bid responses', function () { - const result = spec.interpretResponse({body: serverResponse.noAd}, bidRequests.banner); - expect(result.length).to.equal(0); - }); - it('handles banner responses', function () { - const result = spec.interpretResponse({body: serverResponse.banner}, bidRequests.banner)[0]; - expect(result.requestId).to.equal(bidResponses.banner.requestId); - expect(result.width).to.equal(bidResponses.banner.width); - expect(result.height).to.equal(bidResponses.banner.height); - expect(result.creativeId).to.equal(bidResponses.banner.creativeId); - expect(result.currency).to.equal(bidResponses.banner.currency); - expect(result.netRevenue).to.equal(bidResponses.banner.netRevenue); - expect(result.ttl).to.equal(bidResponses.banner.ttl); - expect(result.referrer).to.equal(bidResponses.banner.referrer); - expect(result.ad).to.equal(bidResponses.banner.ad); - }); - - it('handles native responses', function () { - const result = spec.interpretResponse({body: serverResponse.native}, bidRequests.native)[0]; - expect(result.requestId).to.equal(bidResponses.native.requestId); - expect(result.creativeId).to.equal(bidResponses.native.creativeId); - expect(result.currency).to.equal(bidResponses.native.currency); - expect(result.netRevenue).to.equal(bidResponses.native.netRevenue); - expect(result.ttl).to.equal(bidResponses.native.ttl); - expect(result.referrer).to.equal(bidResponses.native.referrer); - expect(result.native.title).to.equal(bidResponses.native.native.title); - expect(result.native.body).to.equal(bidResponses.native.native.body); - expect(result.native.sponsoredBy).to.equal(bidResponses.native.native.sponsoredBy); - expect(result.native.image.url).to.equal(bidResponses.native.native.image.url); - expect(result.native.image.width).to.equal(bidResponses.native.native.image.width); - expect(result.native.image.height).to.equal(bidResponses.native.native.image.height); - expect(result.native.clickUrl).to.equal(bidResponses.native.native.clickUrl); - expect(result.native.impressionTrackers[0]).to.equal(bidResponses.native.native.impressionTrackers[0]); - expect(result.native.clickTrackers[0]).to.equal(bidResponses.native.native.clickTrackers[0]); - }); - }); -}); diff --git a/test/spec/modules/dspxBidAdapter_spec.js b/test/spec/modules/dspxBidAdapter_spec.js deleted file mode 100644 index 7eeac43680a4..000000000000 --- a/test/spec/modules/dspxBidAdapter_spec.js +++ /dev/null @@ -1,130 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/dspxBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; - -const ENDPOINT_URL = 'https://buyer.dspx.tv/request/'; - -describe('dspxAdapter', function () { - const adapter = newBidder(spec); - - describe('isBidRequestValid', function () { - let bid = { - 'bidder': 'dspx', - 'params': { - 'placement': '6682', - 'pfilter': { - 'floorprice': 1000000 - }, - 'bcat': 'IAB2,IAB4', - 'dvt': 'desktop' - }, - 'sizes': [ - [300, 250] - ], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475' - }; - - it('should return true when required params found', function () { - expect(spec.isBidRequestValid(bid)).to.equal(true); - }); - - it('should return false when required params are not passed', function () { - let bid = Object.assign({}, bid); - delete bid.params; - bid.params = { - 'someIncorrectParam': 0 - }; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - }); - - describe('buildRequests', function () { - let bidRequests = [{ - 'bidder': 'dspx', - 'params': { - 'placement': '6682', - 'pfilter': { - 'floorprice': 1000000, - 'private_auction': 0, - 'geo': { - 'country': 'DE' - } - }, - 'bcat': 'IAB2,IAB4', - 'dvt': 'desktop' - }, - 'sizes': [ - [300, 250] - ], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475' - }]; - - let bidderRequest = { - refererInfo: { - referer: 'some_referrer.net' - } - } - - const request = spec.buildRequests(bidRequests, bidderRequest); - it('sends bid request to our endpoint via GET', function () { - expect(request[0].method).to.equal('GET'); - let data = request[0].data.replace(/rnd=\d+\&/g, '').replace(/ref=.*\&bid/g, 'bid'); - expect(data).to.equal('_f=html&alternative=prebid_js&inventory_item_id=6682&srw=300&srh=250&idt=100&bid_id=30b31c1838de1e&pfilter%5Bfloorprice%5D=1000000&pfilter%5Bprivate_auction%5D=0&pfilter%5Bgeo%5D%5Bcountry%5D=DE&bcat=IAB2%2CIAB4&dvt=desktop'); - }); - }); - - describe('interpretResponse', function () { - let serverResponse = { - 'body': { - 'cpm': 5000000, - 'crid': 100500, - 'width': '300', - 'height': '250', - 'tag': '', - 'requestId': '220ed41385952a', - 'currency': 'EUR', - 'ttl': 60, - 'netRevenue': true, - 'zone': '6682' - } - }; - - let expectedResponse = [{ - requestId: '23beaa6af6cdde', - cpm: 0.5, - width: 0, - height: 0, - creativeId: 100500, - dealId: '', - currency: 'EUR', - netRevenue: true, - ttl: 300, - referrer: '', - ad: '' - }]; - - it('should get the correct bid response by display ad', function () { - let bidRequest = [{ - 'method': 'GET', - 'url': ENDPOINT_URL, - 'data': { - 'bid_id': '30b31c1838de1e' - } - }]; - let result = spec.interpretResponse(serverResponse, bidRequest[0]); - expect(Object.keys(result[0])).to.have.members(Object.keys(expectedResponse[0])); - }); - - it('handles empty bid response', function () { - let response = { - body: {} - }; - let result = spec.interpretResponse(response); - expect(result.length).to.equal(0); - }); - }); -}); diff --git a/test/spec/modules/ebdrBidAdapter_spec.js b/test/spec/modules/ebdrBidAdapter_spec.js index d742e28f2e68..3cac03024c09 100644 --- a/test/spec/modules/ebdrBidAdapter_spec.js +++ b/test/spec/modules/ebdrBidAdapter_spec.js @@ -147,7 +147,7 @@ describe('ebdrBidAdapter', function () { h: _mediaTypes == BANNER ? bid.mediaTypes[_mediaTypes].sizes[0][1] : bid.mediaTypes[_mediaTypes].playerSize[1] }; }); - const serverResponse = {id: '1d0c4017f02458', seatbid: [{bid: [{id: '23a01e95856577', impid: '23a01e95856577', price: 0.81, adid: 'abcde-12345', nurl: 'https://cdn0.bnmla.com/vtest.xml', adm: '\nStatic VASTStatic VAST Tag00:00:15http://www.engagebdr.com/c', adomain: ['advertiserdomain.com'], iurl: '', cid: 'campaign1', crid: 'abcde-12345', w: 300, h: 250}], seat: '19513bcfca8006'}], bidid: '19513bcfca8006', cur: 'USD'}; + const serverResponse = {id: '1d0c4017f02458', seatbid: [{bid: [{id: '23a01e95856577', impid: '23a01e95856577', price: 0.81, adid: 'abcde-12345', nurl: 'https://cdn0.bnmla.com/vtest.xml', adm: '\nStatic VASTStatic VAST Tag00:00:15https//www.engagebdr.com/c', adomain: ['advertiserdomain.com'], iurl: '', cid: 'campaign1', crid: 'abcde-12345', w: 300, h: 250}], seat: '19513bcfca8006'}], bidid: '19513bcfca8006', cur: 'USD'}; const bidResponse = spec.interpretResponse({ body: serverResponse }, ebdrReq); expect(bidResponse[0]).to.deep.equal({ requestId: bidRequests[1].bidId, @@ -189,7 +189,7 @@ describe('ebdrBidAdapter', function () { h: _mediaTypes == BANNER ? bid.mediaTypes[_mediaTypes].sizes[0][1] : bid.mediaTypes[_mediaTypes].playerSize[1] }; }); - const serverResponse = {id: '1d0c4017f02458', seatbid: [{bid: [{id: '2c5e8a1a84522d', impid: '2c5e8a1a84522d', price: 0.81, adid: 'abcde-12345', nurl: '', adm: '
', adomain: ['advertiserdomain.com'], iurl: '', cid: 'campaign1', crid: 'abcde-12345', w: 300, h: 250}], seat: '19513bcfca8006'}], bidid: '19513bcfca8006', cur: 'USD', w: 300, h: 250}; + const serverResponse = {id: '1d0c4017f02458', seatbid: [{bid: [{id: '2c5e8a1a84522d', impid: '2c5e8a1a84522d', price: 0.81, adid: 'abcde-12345', nurl: '', adm: '
', adomain: ['advertiserdomain.com'], iurl: '', cid: 'campaign1', crid: 'abcde-12345', w: 300, h: 250}], seat: '19513bcfca8006'}], bidid: '19513bcfca8006', cur: 'USD', w: 300, h: 250}; const bidResponse = spec.interpretResponse({ body: serverResponse }, ebdrReq); expect(bidResponse[0]).to.deep.equal({ requestId: bidRequests[ 0 ].bidId, @@ -215,14 +215,14 @@ describe('ebdrBidAdapter', function () { } }); it('sucess with usersync url', function () { - const serverResponse = {id: '1d0c4017f02458', seatbid: [{bid: [{id: '2c5e8a1a84522d', impid: '2c5e8a1a84522d', price: 0.81, adid: 'abcde-12345', nurl: '', adm: '
', adomain: ['advertiserdomain.com'], iurl: '//match.bnmla.com/usersync?sspid=59&redir=', cid: 'campaign1', crid: 'abcde-12345', w: 300, h: 250}], seat: '19513bcfca8006'}], bidid: '19513bcfca8006', cur: 'USD', w: 300, h: 250}; + const serverResponse = {id: '1d0c4017f02458', seatbid: [{bid: [{id: '2c5e8a1a84522d', impid: '2c5e8a1a84522d', price: 0.81, adid: 'abcde-12345', nurl: '', adm: '
', adomain: ['advertiserdomain.com'], iurl: 'https://match.bnmla.com/usersync?sspid=59&redir=', cid: 'campaign1', crid: 'abcde-12345', w: 300, h: 250}], seat: '19513bcfca8006'}], bidid: '19513bcfca8006', cur: 'USD', w: 300, h: 250}; const result = []; - result.push({type: 'image', url: '//match.bnmla.com/usersync?sspid=59&redir='}); + result.push({type: 'image', url: 'https://match.bnmla.com/usersync?sspid=59&redir='}); expect(spec.getUserSyncs(syncOptions, { body: serverResponse })).to.deep.equal(result); }); it('sucess without usersync url', function () { - const serverResponse = {id: '1d0c4017f02458', seatbid: [{bid: [{id: '2c5e8a1a84522d', impid: '2c5e8a1a84522d', price: 0.81, adid: 'abcde-12345', nurl: '', adm: '
', adomain: ['advertiserdomain.com'], iurl: '', cid: 'campaign1', crid: 'abcde-12345', w: 300, h: 250}], seat: '19513bcfca8006'}], bidid: '19513bcfca8006', cur: 'USD', w: 300, h: 250}; + const serverResponse = {id: '1d0c4017f02458', seatbid: [{bid: [{id: '2c5e8a1a84522d', impid: '2c5e8a1a84522d', price: 0.81, adid: 'abcde-12345', nurl: '', adm: '
', adomain: ['advertiserdomain.com'], iurl: '', cid: 'campaign1', crid: 'abcde-12345', w: 300, h: 250}], seat: '19513bcfca8006'}], bidid: '19513bcfca8006', cur: 'USD', w: 300, h: 250}; const result = []; expect(spec.getUserSyncs(syncOptions, { body: serverResponse })).to.deep.equal(result); }); diff --git a/test/spec/modules/emoteevBidAdapter_spec.js b/test/spec/modules/emoteevBidAdapter_spec.js index b6a62c169636..bb0f28125bee 100644 --- a/test/spec/modules/emoteevBidAdapter_spec.js +++ b/test/spec/modules/emoteevBidAdapter_spec.js @@ -78,8 +78,8 @@ const cannedBidderRequest = { canonicalUrl: undefined, numIframes: 0, reachedTop: true, - referer: 'http://localhost:9999/integrationExamples/gpt/hello_world_emoteev.html', - stack: ['http://localhost:9999/integrationExamples/gpt/hello_world_emoteev.html'] + referer: 'https://localhost:9999/integrationExamples/gpt/hello_world_emoteev.html', + stack: ['https://localhost:9999/integrationExamples/gpt/hello_world_emoteev.html'] }, start: 1544200012839, timeout: 3000, diff --git a/test/spec/modules/emx_digitalBidAdapter_spec.js b/test/spec/modules/emx_digitalBidAdapter_spec.js deleted file mode 100644 index 525e5808e400..000000000000 --- a/test/spec/modules/emx_digitalBidAdapter_spec.js +++ /dev/null @@ -1,558 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/emx_digitalBidAdapter'; -import * as utils from 'src/utils'; -import { newBidder } from 'src/adapters/bidderFactory'; - -describe('emx_digital Adapter', function () { - describe('callBids', function () { - const adapter = newBidder(spec); - it('exists and is a function', function () { - expect(adapter.callBids).to.exist.and.to.be.a('function'); - }); - }); - - describe('isBidRequestValid', function () { - describe('banner request validity', function () { - let bid = { - 'bidder': 'emx_digital', - 'params': { - 'tagid': '25251' - }, - 'mediaTypes': { - 'banner': { - 'sizes': [[300, 250]] - } - }, - 'adUnitCode': 'adunit-code', - 'sizes': [ - [300, 250], - [300, 600] - ], - 'bidId': '30b31c2501de1e', - 'bidderRequestId': '22edbae3120bf6', - 'auctionId': '1d1a01234a475' - }; - let badBid = { - 'bidder': 'emx_digital', - 'params': { - 'tagid': '25251' - }, - 'mediaTypes': { - 'banner': { - } - }, - 'adUnitCode': 'adunit-code', - 'bidId': '30b31c2501de1e', - 'bidderRequestId': '22edbae3120bf6', - 'auctionId': '1d1a01234a475' - }; - let noBid = {}; - let otherBid = { - 'bidder': 'emxdigital', - 'params': { - 'tagid': '25251' - }, - 'mediaTypes': { - 'banner': { - 'sizes': [[300, 250]] - } - }, - 'adUnitCode': 'adunit-code', - 'sizes': [ - [300, 250], - [300, 600] - ], - 'bidId': '30b31c2501de1e', - 'bidderRequestId': '22edbae3120bf6', - 'auctionId': '1d1a01234a475' - }; - let noMediaSizeBid = { - 'bidder': 'emxdigital', - 'params': { - 'tagid': '25251' - }, - 'mediaTypes': { - 'banner': {} - }, - 'adUnitCode': 'adunit-code', - 'sizes': [ - [300, 250], - [300, 600] - ], - 'bidId': '30b31c2501de1e', - 'bidderRequestId': '22edbae3120bf6', - 'auctionId': '1d1a01234a475' - }; - - it('should return true when required params found', function () { - expect(spec.isBidRequestValid(bid)).to.equal(true); - expect(spec.isBidRequestValid(badBid)).to.equal(false); - expect(spec.isBidRequestValid(noBid)).to.equal(false); - expect(spec.isBidRequestValid(otherBid)).to.equal(false); - expect(spec.isBidRequestValid(noMediaSizeBid)).to.equal(false); - }); - }); - - describe('video request validity', function () { - let bid = { - 'bidder': 'emx_digital', - 'params': { - 'tagid': '25251', - 'video': {} - }, - 'mediaTypes': { - 'video': { - 'context': 'instream', - 'playerSize': [640, 480] - } - }, - 'adUnitCode': 'adunit-code', - 'sizes': [ - [300, 250], - [300, 600] - ], - 'bidId': '30b31c2501de1e', - 'bidderRequestId': '22edbae3120bf6', - 'auctionId': '1d1a01234a475' - }; - let noInstreamBid = { - 'bidder': 'emx_digital', - 'params': { - 'tagid': '25251', - 'video': { - 'protocols': [1, 7] - } - }, - 'mediaTypes': { - 'video': { - 'context': 'something_random' - } - }, - 'adUnitCode': 'adunit-code', - 'sizes': [ - [300, 250], - [300, 600] - ], - 'bidId': '30b31c2501de1e', - 'bidderRequestId': '22edbae3120bf6', - 'auctionId': '1d1a01234a475' - }; - - let outstreamBid = { - 'bidder': 'emx_digital', - 'params': { - 'tagid': '25251', - 'video': {} - }, - 'mediaTypes': { - 'video': { - 'context': 'outstream', - 'playerSize': [640, 480] - } - }, - 'adUnitCode': 'adunit-code', - 'sizes': [ - [300, 250], - [300, 600] - ], - 'bidId': '30b31c2501de1e', - 'bidderRequestId': '22edbae3120bf6', - 'auctionId': '1d1a01234a475' - }; - - it('should return true when required params found', function () { - expect(spec.isBidRequestValid(bid)).to.equal(true); - expect(spec.isBidRequestValid(noInstreamBid)).to.equal(false); - expect(spec.isBidRequestValid(outstreamBid)).to.equal(true); - }); - - it('should contain tagid param', function () { - expect(spec.isBidRequestValid({ - bidder: 'emx_digital', - params: {}, - mediaTypes: { - banner: { - sizes: [[300, 250]] - } - } - })).to.equal(false); - expect(spec.isBidRequestValid({ - bidder: 'emx_digital', - params: { - tagid: '' - }, - mediaTypes: { - banner: { - sizes: [[300, 250]] - } - } - })).to.equal(false); - expect(spec.isBidRequestValid({ - bidder: 'emx_digital', - params: { - tagid: '123' - }, - mediaTypes: { - banner: { - sizes: [[300, 250]] - } - } - })).to.equal(true); - }); - }); - }); - - describe('buildRequests', function () { - let bidderRequest = { - 'bidderCode': 'emx_digital', - 'auctionId': 'e19f1eff-8b27-42a6-888d-9674e5a6130c', - 'bidderRequestId': '22edbae3120bf6', - 'timeout': 1500, - 'refererInfo': { - 'numIframes': 0, - 'reachedTop': true, - 'referer': 'https://example.com/index.html?pbjs_debug=true' - }, - 'bids': [{ - 'bidder': 'emx_digital', - 'params': { - 'tagid': '25251' - }, - 'adUnitCode': 'adunit-code', - 'mediaTypes': { - 'banner': { - 'sizes': [ - [300, 250], - [300, 600] - ] - } - }, - 'sizes': [ - [300, 250], - [300, 600] - ], - 'bidId': '30b31c2501de1e', - 'auctionId': 'e19f1eff-8b27-42a6-888d-9674e5a6130c', - 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', - }] - }; - let request = spec.buildRequests(bidderRequest.bids, bidderRequest); - - it('sends bid request to ENDPOINT via POST', function () { - expect(request.method).to.equal('POST'); - }); - - it('contains the correct options', function () { - expect(request.options.withCredentials).to.equal(true); - }); - - it('contains a properly formatted endpoint url', function () { - const url = request.url.split('?'); - const queryParams = url[1].split('&'); - expect(queryParams[0]).to.match(new RegExp('^t=\d*', 'g')); - expect(queryParams[1]).to.match(new RegExp('^ts=\d*', 'g')); - }); - - it('builds with bid floor', function () { - const bidRequestWithBidFloor = utils.deepClone(bidderRequest.bids); - bidRequestWithBidFloor[0].params.bidfloor = 1; - const requestWithFloor = spec.buildRequests(bidRequestWithBidFloor, bidderRequest); - const data = JSON.parse(requestWithFloor.data); - expect(data.imp[0].bidfloor).to.equal(bidRequestWithBidFloor[0].params.bidfloor); - }); - - it('builds request properly', function () { - const data = JSON.parse(request.data); - expect(Array.isArray(data.imp)).to.equal(true); - expect(data.id).to.equal(bidderRequest.auctionId); - expect(data.imp.length).to.equal(1); - expect(data.imp[0].id).to.equal('30b31c2501de1e'); - expect(data.imp[0].tid).to.equal('d7b773de-ceaa-484d-89ca-d9f51b8d61ec'); - expect(data.imp[0].tagid).to.equal('25251'); - expect(data.imp[0].secure).to.equal(0); - expect(data.imp[0].vastXml).to.equal(undefined); - }); - - it('properly sends site information and protocol', function () { - request = spec.buildRequests(bidderRequest.bids, bidderRequest); - request = JSON.parse(request.data); - expect(request.site.domain).to.equal(utils.getTopWindowLocation().hostname); - expect(decodeURIComponent(request.site.page)).to.equal(bidderRequest.refererInfo.referer); - expect(request.site.ref).to.equal(window.top.document.referrer); - }); - - it('builds correctly formatted request banner object', function () { - let bidRequestWithBanner = utils.deepClone(bidderRequest.bids); - let request = spec.buildRequests(bidRequestWithBanner, bidderRequest); - const data = JSON.parse(request.data); - expect(data.imp[0].video).to.equal(undefined); - expect(data.imp[0].banner).to.exist.and.to.be.a('object'); - expect(data.imp[0].banner.w).to.equal(bidRequestWithBanner[0].mediaTypes.banner.sizes[0][0]); - expect(data.imp[0].banner.h).to.equal(bidRequestWithBanner[0].mediaTypes.banner.sizes[0][1]); - expect(data.imp[0].banner.format[0].w).to.equal(bidRequestWithBanner[0].mediaTypes.banner.sizes[0][0]); - expect(data.imp[0].banner.format[0].h).to.equal(bidRequestWithBanner[0].mediaTypes.banner.sizes[0][1]); - expect(data.imp[0].banner.format[1].w).to.equal(bidRequestWithBanner[0].mediaTypes.banner.sizes[1][0]); - expect(data.imp[0].banner.format[1].h).to.equal(bidRequestWithBanner[0].mediaTypes.banner.sizes[1][1]); - }); - - it('builds correctly formatted request video object for instream', function () { - let bidRequestWithVideo = utils.deepClone(bidderRequest.bids); - bidRequestWithVideo[0].mediaTypes = { - video: { - context: 'instream', - playerSize: [[640, 480]] - }, - }; - bidRequestWithVideo[0].params.video = {}; - let request = spec.buildRequests(bidRequestWithVideo, bidderRequest); - const data = JSON.parse(request.data); - expect(data.imp[0].video).to.exist.and.to.be.a('object'); - expect(data.imp[0].video.w).to.equal(bidRequestWithVideo[0].mediaTypes.video.playerSize[0][0]); - expect(data.imp[0].video.h).to.equal(bidRequestWithVideo[0].mediaTypes.video.playerSize[0][1]); - }); - - it('builds correctly formatted request video object for outstream', function () { - let bidRequestWithOutstreamVideo = utils.deepClone(bidderRequest.bids); - bidRequestWithOutstreamVideo[0].mediaTypes = { - video: { - context: 'outstream', - playerSize: [[640, 480]] - }, - }; - bidRequestWithOutstreamVideo[0].params.video = {}; - let request = spec.buildRequests(bidRequestWithOutstreamVideo, bidderRequest); - const data = JSON.parse(request.data); - expect(data.imp[0].video).to.exist.and.to.be.a('object'); - expect(data.imp[0].video.w).to.equal(bidRequestWithOutstreamVideo[0].mediaTypes.video.playerSize[0][0]); - expect(data.imp[0].video.h).to.equal(bidRequestWithOutstreamVideo[0].mediaTypes.video.playerSize[0][1]); - }); - - it('shouldn\'t contain a user obj without GDPR information', function () { - let request = spec.buildRequests(bidderRequest.bids, bidderRequest) - request = JSON.parse(request.data) - expect(request).to.not.have.property('user'); - }); - - it('should have the right gdpr info when enabled', function () { - let consentString = 'OIJSZsOAFsABAB8EMXZZZZZ+A=='; - bidderRequest.gdprConsent = { - 'consentString': consentString, - 'gdprApplies': true - }; - let request = spec.buildRequests(bidderRequest.bids, bidderRequest); - - request = JSON.parse(request.data) - expect(request.regs.ext).to.have.property('gdpr', 1); - expect(request.user.ext).to.have.property('consent', consentString); - }); - - it('should\'t contain consent string if gdpr isn\'t applied', function () { - bidderRequest.gdprConsent = { - 'gdprApplies': false - }; - let request = spec.buildRequests(bidderRequest.bids, bidderRequest); - request = JSON.parse(request.data) - expect(request.regs.ext).to.have.property('gdpr', 0); - expect(request).to.not.have.property('user'); - }); - it('should add us privacy info to request', function() { - let consentString = '1YNN'; - bidderRequest.uspConsent = consentString; - let request = spec.buildRequests(bidderRequest.bids, bidderRequest); - request = JSON.parse(request.data); - expect(request.us_privacy).to.exist; - expect(request.us_privacy).to.exist.and.to.equal(consentString); - }); - }); - - describe('interpretResponse', function () { - let bid = { - 'bidder': 'emx_digital', - 'params': { - 'tagid': '25251', - 'video': {} - }, - 'mediaTypes': { - 'video': { - 'context': 'instream', - 'playerSize': [640, 480] - } - }, - 'adUnitCode': 'adunit-code', - 'sizes': [ - [300, 250], - [300, 600] - ], - 'bidId': '30b31c2501de1e', - 'bidderRequestId': '22edbae3120bf6', - 'auctionId': '1d1a01234a475' - }; - - const serverResponse = { - 'id': '12819a18-56e1-4256-b836-b69a10202668', - 'seatbid': [{ - 'bid': [{ - 'adid': '123456abcde', - 'adm': '', - 'crid': '3434abab34', - 'h': 250, - 'id': '987654321cba', - 'price': 0.5, - 'ttl': 300, - 'w': 300 - }], - 'seat': '1356' - }, { - 'bid': [{ - 'adid': '123456abcdf', - 'adm': '', - 'crid': '3434abab35', - 'h': 600, - 'id': '987654321cba', - 'price': 0.5, - 'ttl': 300, - 'w': 300 - }] - }] - }; - - const expectedResponse = [{ - 'requestId': '12819a18-56e1-4256-b836-b69a10202668', - 'cpm': 0.5, - 'width': 300, - 'height': 250, - 'creativeId': '3434abab34', - 'dealId': null, - 'currency': 'USD', - 'netRevneue': true, - 'mediaType': 'banner', - 'ad': '', - 'ttl': 300 - }, { - 'requestId': '12819a18-56e1-4256-b836-b69a10202668', - 'cpm': 0.7, - 'width': 300, - 'height': 600, - 'creativeId': '3434abab35', - 'dealId': null, - 'currency': 'USD', - 'netRevneue': true, - 'mediaType': 'banner', - 'ad': '', - 'ttl': 300 - }]; - - it('should properly format bid response', function () { - let result = spec.interpretResponse({ - body: serverResponse - }); - expect(Object.keys(result[0]).length).to.equal(Object.keys(expectedResponse[0]).length); - expect(Object.keys(result[0]).requestId).to.equal(Object.keys(expectedResponse[0]).requestId); - expect(Object.keys(result[0]).bidderCode).to.equal(Object.keys(expectedResponse[0]).bidderCode); - expect(Object.keys(result[0]).cpm).to.equal(Object.keys(expectedResponse[0]).cpm); - expect(Object.keys(result[0]).creativeId).to.equal(Object.keys(expectedResponse[0]).creativeId); - expect(Object.keys(result[0]).width).to.equal(Object.keys(expectedResponse[0]).width); - expect(Object.keys(result[0]).height).to.equal(Object.keys(expectedResponse[0]).height); - expect(Object.keys(result[0]).ttl).to.equal(Object.keys(expectedResponse[0]).ttl); - expect(Object.keys(result[0]).adId).to.equal(Object.keys(expectedResponse[0]).adId); - expect(Object.keys(result[0]).currency).to.equal(Object.keys(expectedResponse[0]).currency); - expect(Object.keys(result[0]).netRevenue).to.equal(Object.keys(expectedResponse[0]).netRevenue); - expect(Object.keys(result[0]).ad).to.equal(Object.keys(expectedResponse[0]).ad); - }); - - it('should return multiple bids', function () { - let result = spec.interpretResponse({ - body: serverResponse - }); - expect(Array.isArray(result.seatbid)) - - const ad0 = result[0]; - const ad1 = result[1]; - expect(ad0.ad).to.equal(serverResponse.seatbid[0].bid[0].adm); - expect(ad0.cpm).to.equal(serverResponse.seatbid[0].bid[0].price); - expect(ad0.creativeId).to.equal(serverResponse.seatbid[0].bid[0].crid); - expect(ad0.currency).to.equal('USD'); - expect(ad0.netRevenue).to.equal(true); - expect(ad0.requestId).to.equal(serverResponse.seatbid[0].bid[0].id); - expect(ad0.ttl).to.equal(300); - - expect(ad1.ad).to.equal(serverResponse.seatbid[1].bid[0].adm); - expect(ad1.cpm).to.equal(serverResponse.seatbid[1].bid[0].price); - expect(ad1.creativeId).to.equal(serverResponse.seatbid[1].bid[0].crid); - expect(ad1.currency).to.equal('USD'); - expect(ad1.netRevenue).to.equal(true); - expect(ad1.requestId).to.equal(serverResponse.seatbid[1].bid[0].id); - expect(ad1.ttl).to.equal(300); - }); - - it('returns a banner bid for non-xml creatives', function () { - let result = spec.interpretResponse({ - body: serverResponse - }, { bidRequest: bid } - ); - const ad0 = result[0]; - const ad1 = result[1]; - expect(ad0.mediaType).to.equal('banner'); - expect(ad0.ad.indexOf(''; - serverResponse.seatbid[1].bid[0].adm = ''; - - let result = spec.interpretResponse({ - body: serverResponse - }, { bidRequest: bid } - ); - const ad0 = result[0]; - const ad1 = result[1]; - expect(ad0.mediaType).to.equal('video'); - expect(ad0.ad.indexOf(' -1).to.equal(true); - expect(ad0.vastXml).to.equal(serverResponse.seatbid[0].bid[0].adm); - expect(ad0.ad).to.exist.and.to.be.a('string'); - expect(ad1.mediaType).to.equal('video'); - expect(ad1.ad.indexOf(' -1).to.equal(true); - expect(ad1.vastXml).to.equal(serverResponse.seatbid[1].bid[0].adm); - expect(ad1.ad).to.exist.and.to.be.a('string'); - }); - - it('handles nobid responses', function () { - let serverResponse = { - 'bids': [] - }; - - let result = spec.interpretResponse({ - body: serverResponse - }); - expect(result.length).to.equal(0); - }); - - it('should not throw an error when decoding an improperly encoded adm', function () { - serverResponse.seatbid[0].bid[0].adm = '\\<\\/script\\>'; - serverResponse.seatbid[1].bid[0].adm = '%3F%%3Demx%3C3prebid' - - assert.doesNotThrow(() => spec.interpretResponse({ - body: serverResponse - })); - }); - }); - - describe('getUserSyncs', function () { - let syncOptionsIframe = { iframeEnabled: true }; - let syncOptionsPixel = { pixelEnabled: true }; - it('Should push the correct sync type depending on the config', function () { - let iframeSync = spec.getUserSyncs(syncOptionsIframe); - expect(iframeSync.length).to.equal(1); - expect(iframeSync[0].type).to.equal('iframe'); - }); - }); -}); diff --git a/test/spec/modules/eplanningBidAdapter_spec.js b/test/spec/modules/eplanningBidAdapter_spec.js deleted file mode 100644 index 3152c43c6ffc..000000000000 --- a/test/spec/modules/eplanningBidAdapter_spec.js +++ /dev/null @@ -1,724 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/eplanningBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; -import * as utils from 'src/utils'; - -describe('E-Planning Adapter', function () { - const adapter = newBidder('spec'); - const CI = '12345'; - const ADUNIT_CODE = 'adunit-co:de'; - const ADUNIT_CODE2 = 'adunit-code-dos'; - const ADUNIT_CODE_VIEW = 'adunit-code-view'; - const ADUNIT_CODE_VIEW2 = 'adunit-code-view2'; - const ADUNIT_CODE_VIEW3 = 'adunit-code-view3'; - const CLEAN_ADUNIT_CODE2 = '300x250_1'; - const CLEAN_ADUNIT_CODE = '300x250_0'; - const BID_ID = '123456789'; - const BID_ID2 = '987654321'; - const BID_ID3 = '998877665'; - const CPM = 1.3; - const W = '300'; - const H = '250'; - const ADM = '
This is an ad
'; - const I_ID = '7854abc56248f873'; - const CRID = '1234567890'; - const TEST_ISV = 'leles.e-planning.net'; - const validBid = { - 'bidder': 'eplanning', - 'bidId': BID_ID, - 'params': { - 'ci': CI, - }, - 'adUnitCode': ADUNIT_CODE, - 'sizes': [[300, 250], [300, 600]], - }; - const validBid2 = { - 'bidder': 'eplanning', - 'bidId': BID_ID2, - 'params': { - 'ci': CI, - }, - 'adUnitCode': ADUNIT_CODE2, - 'sizes': [[300, 250], [300, 600]], - }; - const validBidView = { - 'bidder': 'eplanning', - 'bidId': BID_ID, - 'params': { - 'ci': CI, - }, - 'adUnitCode': ADUNIT_CODE_VIEW, - 'sizes': [[300, 250], [300, 600]], - }; - const validBidView2 = { - 'bidder': 'eplanning', - 'bidId': BID_ID2, - 'params': { - 'ci': CI, - }, - 'adUnitCode': ADUNIT_CODE_VIEW2, - 'sizes': [[300, 250], [300, 600]], - }; - const validBidView3 = { - 'bidder': 'eplanning', - 'bidId': BID_ID3, - 'params': { - 'ci': CI, - }, - 'adUnitCode': ADUNIT_CODE_VIEW3, - 'sizes': [[300, 250], [300, 600]], - }; - const testBid = { - 'bidder': 'eplanning', - 'params': { - 't': 1, - 'isv': TEST_ISV - }, - 'adUnitCode': ADUNIT_CODE, - 'sizes': [[300, 250], [300, 600]], - }; - const invalidBid = { - 'bidder': 'eplanning', - 'params': { - }, - 'adUnitCode': 'adunit-code', - 'sizes': [[300, 250], [300, 600]], - }; - const response = { - body: { - 'sI': { - 'k': '12345' - }, - 'sec': { - 'k': 'ROS' - }, - 'sp': [{ - 'k': CLEAN_ADUNIT_CODE, - 'a': [{ - 'adm': ADM, - 'id': '7854abc56248f874', - 'i': I_ID, - 'fi': '7854abc56248f872', - 'ip': '45621afd87462104', - 'w': W, - 'h': H, - 'crid': CRID, - 'pr': CPM - }], - }], - 'cs': [ - 'http://a-sync-url.com/', - { - 'u': 'http://another-sync-url.com/test.php?&partner=123456&endpoint=us-east', - 'ifr': true - } - ] - } - }; - const responseWithTwoAdunits = { - body: { - 'sI': { - 'k': '12345' - }, - 'sec': { - 'k': 'ROS' - }, - 'sp': [{ - 'k': CLEAN_ADUNIT_CODE, - 'a': [{ - 'adm': ADM, - 'id': '7854abc56248f874', - 'i': I_ID, - 'fi': '7854abc56248f872', - 'ip': '45621afd87462104', - 'w': W, - 'h': H, - 'crid': CRID, - 'pr': CPM - }] - }, { - 'k': CLEAN_ADUNIT_CODE2, - 'a': [{ - 'adm': ADM, - 'id': '7854abc56248f874', - 'i': I_ID, - 'fi': '7854abc56248f872', - 'ip': '45621afd87462104', - 'w': W, - 'h': H, - 'crid': CRID, - 'pr': CPM - }], - }, - ], - 'cs': [ - 'http://a-sync-url.com/', - { - 'u': 'http://another-sync-url.com/test.php?&partner=123456&endpoint=us-east', - 'ifr': true - } - ] - } - }; - const responseWithNoAd = { - body: { - 'sI': { - 'k': '12345' - }, - 'sec': { - 'k': 'ROS' - }, - 'sp': [{ - 'k': 'spname', - }], - 'cs': [ - 'http://a-sync-url.com/', - { - 'u': 'http://another-sync-url.com/test.php?&partner=123456&endpoint=us-east', - 'ifr': true - } - ] - } - }; - const responseWithNoSpace = { - body: { - 'sI': { - 'k': '12345' - }, - 'sec': { - 'k': 'ROS' - }, - 'cs': [ - 'http://a-sync-url.com/', - { - 'u': 'http://another-sync-url.com/test.php?&partner=123456&endpoint=us-east', - 'ifr': true - } - ] - } - }; - - describe('inherited functions', function () { - it('exists and is a function', function () { - expect(adapter.callBids).to.exist.and.to.be.a('function'); - }); - }); - - describe('isBidRequestValid', function () { - it('should return true when bid has ci parameter', function () { - expect(spec.isBidRequestValid(validBid)).to.equal(true); - }); - - it('should return false when bid does not have ci parameter and is not a test bid', function () { - expect(spec.isBidRequestValid(invalidBid)).to.equal(false); - }); - - it('should return true when bid does not have ci parameter but is a test bid', function () { - expect(spec.isBidRequestValid(testBid)).to.equal(true); - }); - }); - - describe('buildRequests', function () { - let bidRequests = [validBid]; - - it('should create the url correctly', function () { - const url = spec.buildRequests(bidRequests).url; - expect(url).to.equal('//ads.us.e-planning.net/hb/1/' + CI + '/1/localhost/ROS'); - }); - - it('should return GET method', function () { - const method = spec.buildRequests(bidRequests).method; - expect(method).to.equal('GET'); - }); - - it('should return r parameter with value pbjs', function () { - const r = spec.buildRequests(bidRequests).data.r; - expect(r).to.equal('pbjs'); - }); - - it('should return pbv parameter with value prebid version', function () { - const pbv = spec.buildRequests(bidRequests).data.pbv; - expect(pbv).to.equal('$prebid.version$'); - }); - - it('should return e parameter with value according to the adunit sizes', function () { - const e = spec.buildRequests(bidRequests).data.e; - expect(e).to.equal('300x250_0:300x250,300x600'); - }); - - it('should return correct e parameter with more than one adunit', function () { - const NEW_CODE = ADUNIT_CODE + '2'; - const CLEAN_NEW_CODE = CLEAN_ADUNIT_CODE + '2'; - const anotherBid = { - 'bidder': 'eplanning', - 'params': { - 'ci': CI, - }, - 'adUnitCode': NEW_CODE, - 'sizes': [[100, 100]], - }; - bidRequests.push(anotherBid); - - const e = spec.buildRequests(bidRequests).data.e; - expect(e).to.equal('300x250_0:300x250,300x600+100x100_0:100x100'); - }); - - it('should return correct e parameter when the adunit has no size', function () { - const noSizeBid = { - 'bidder': 'eplanning', - 'params': { - 'ci': CI, - }, - 'adUnitCode': ADUNIT_CODE, - }; - - const e = spec.buildRequests([noSizeBid]).data.e; - expect(e).to.equal('1x1_0:1x1'); - }); - - it('should return ur parameter with current window url', function () { - const ur = spec.buildRequests(bidRequests).data.ur; - expect(ur).to.equal(utils.getTopWindowUrl()); - }); - - it('should return fr parameter when there is a referrer', function () { - const referrer = 'thisisafakereferrer'; - const stubGetReferrer = sinon.stub(utils, 'getTopWindowReferrer'); - stubGetReferrer.returns(referrer); - const fr = spec.buildRequests(bidRequests).data.fr; - expect(fr).to.equal(referrer); - stubGetReferrer.restore() - }); - - it('should return crs parameter with document charset', function () { - let expected; - try { - expected = window.top.document.characterSet; - } catch (e) { - expected = document.characterSet; - } - - const chset = spec.buildRequests(bidRequests).data.crs; - - expect(chset).to.equal(expected); - }); - - it('should return the testing url when the request has the t parameter', function () { - const url = spec.buildRequests([testBid]).url; - const expectedUrl = '//' + TEST_ISV + '/layers/t_pbjs_2.json'; - expect(url).to.equal(expectedUrl); - }); - - it('should return the parameter ncb with value 1', function () { - const ncb = spec.buildRequests(bidRequests).data.ncb; - expect(ncb).to.equal('1'); - }); - }); - - describe('interpretResponse', function () { - it('should return an empty array when there is no ads in the response', function () { - const bidResponses = spec.interpretResponse(responseWithNoAd); - expect(bidResponses).to.be.empty; - }); - - it('should return an empty array when there is no spaces in the response', function () { - const bidResponses = spec.interpretResponse(responseWithNoSpace); - expect(bidResponses).to.be.empty; - }); - - it('should correctly map the parameters in the response', function () { - const bidResponse = spec.interpretResponse(response, { adUnitToBidId: { [CLEAN_ADUNIT_CODE]: BID_ID } })[0]; - const expectedResponse = { - requestId: BID_ID, - cpm: CPM, - width: W, - height: H, - ad: ADM, - ttl: 120, - creativeId: CRID, - netRevenue: true, - currency: 'USD', - }; - expect(bidResponse).to.deep.equal(expectedResponse); - }); - }); - - describe('getUserSyncs', function () { - const sOptionsAllEnabled = { - pixelEnabled: true, - iframeEnabled: true - }; - const sOptionsAllDisabled = { - pixelEnabled: false, - iframeEnabled: false - }; - const sOptionsOnlyPixel = { - pixelEnabled: true, - iframeEnabled: false - }; - const sOptionsOnlyIframe = { - pixelEnabled: false, - iframeEnabled: true - }; - - it('should return an empty array if the response has no syncs', function () { - const noSyncsResponse = { cs: [] }; - const syncs = spec.getUserSyncs(sOptionsAllEnabled, [noSyncsResponse]); - expect(syncs).to.be.empty; - }); - - it('should return an empty array if there is no sync options enabled', function () { - const syncs = spec.getUserSyncs(sOptionsAllDisabled, [response]); - expect(syncs).to.be.empty; - }); - - it('should only return pixels if iframe is not enabled', function () { - const syncs = spec.getUserSyncs(sOptionsOnlyPixel, [response]); - syncs.forEach(sync => expect(sync.type).to.equal('image')); - }); - - it('should only return iframes if pixel is not enabled', function () { - const syncs = spec.getUserSyncs(sOptionsOnlyIframe, [response]); - syncs.forEach(sync => expect(sync.type).to.equal('iframe')); - }); - }); - - describe('adUnits mapping to bidId', function () { - it('should correctly map the bidId to the adunit', function () { - const requests = spec.buildRequests([validBid, validBid2]); - const responses = spec.interpretResponse(responseWithTwoAdunits, requests); - expect(responses[0].requestId).to.equal(BID_ID); - expect(responses[1].requestId).to.equal(BID_ID2); - }); - }); - describe('viewability', function() { - let storageIdRender = 'pbsr_' + validBidView.adUnitCode; - let storageIdView = 'pbvi_' + validBidView.adUnitCode; - let bidRequests = [validBidView]; - let bidRequestMultiple = [validBidView, validBidView2, validBidView3]; - let getLocalStorageSpy; - let setDataInLocalStorageSpy; - let hasLocalStorageStub; - let clock; - let element; - let getBoundingClientRectStub; - let sandbox = sinon.sandbox.create(); - let focusStub; - function createElement(id) { - element = document.createElement('div'); - element.id = id || ADUNIT_CODE_VIEW; - element.style.width = '50px'; - element.style.height = '50px'; - if (frameElement) { - frameElement.style.width = '100px'; - frameElement.style.height = '100px'; - } - element.style.background = 'black'; - document.body.appendChild(element); - } - function createElementVisible(id) { - createElement(id); - sandbox.stub(element, 'getBoundingClientRect').returns({ - x: 0, - y: 0, - width: 50, - height: 50, - top: 0, - right: 50, - bottom: 50, - left: 0, - }); - } - function createElementOutOfView(id) { - createElement(id); - sandbox.stub(element, 'getBoundingClientRect').returns({ - x: 100, - y: 100, - width: 250, - height: 250, - top: 100, - right: 350, - bottom: 350, - left: 100, - }); - } - - function createPartiallyVisibleElement(id) { - createElement(id); - sandbox.stub(element, 'getBoundingClientRect').returns({ - x: 0, - y: 0, - width: 50, - height: 150, - top: 0, - right: 50, - bottom: 150, - left: 0, - }); - } - function createPartiallyInvisibleElement(id) { - createElement(id); - sandbox.stub(element, 'getBoundingClientRect').returns({ - x: 0, - y: 0, - width: 150, - height: 150, - top: 0, - right: 150, - bottom: 150, - left: 0, - }); - } - function createElementOutOfRange(id) { - createElement(id); - sandbox.stub(element, 'getBoundingClientRect').returns({ - x: 200, - y: 200, - width: 350, - height: 350, - top: 200, - right: 350, - bottom: 350, - left: 200, - }); - } - beforeEach(function () { - getLocalStorageSpy = sandbox.spy(utils, 'getDataFromLocalStorage'); - setDataInLocalStorageSpy = sandbox.spy(utils, 'setDataInLocalStorage'); - - hasLocalStorageStub = sandbox.stub(utils, 'hasLocalStorage'); - hasLocalStorageStub.returns(true); - - clock = sandbox.useFakeTimers(); - - focusStub = sandbox.stub(window.top.document, 'hasFocus'); - focusStub.returns(true); - }); - afterEach(function () { - sandbox.restore(); - if (document.getElementById(ADUNIT_CODE_VIEW)) { - document.body.removeChild(element); - } - window.top.localStorage.removeItem(storageIdRender); - window.top.localStorage.removeItem(storageIdView); - }); - - it('should create the url correctly without LocalStorage', function() { - createElementVisible(); - hasLocalStorageStub.returns(false); - const response = spec.buildRequests(bidRequests); - - expect(response.url).to.equal('//ads.us.e-planning.net/hb/1/' + CI + '/1/localhost/ROS'); - expect(response.data.vs).to.equal('F'); - - sinon.assert.notCalled(getLocalStorageSpy); - sinon.assert.notCalled(setDataInLocalStorageSpy); - }); - - it('should create the url correctly with LocalStorage', function() { - createElementVisible(); - const response = spec.buildRequests(bidRequests); - expect(response.url).to.equal('//ads.us.e-planning.net/hb/1/' + CI + '/1/localhost/ROS'); - - expect(response.data.vs).to.equal('F'); - - sinon.assert.called(getLocalStorageSpy); - sinon.assert.called(setDataInLocalStorageSpy); - sinon.assert.calledWith(getLocalStorageSpy, storageIdRender); - sinon.assert.calledWith(setDataInLocalStorageSpy, storageIdRender); - - expect(utils.getDataFromLocalStorage(storageIdRender)).to.equal('1'); - }); - - context('when element is fully in view', function() { - let respuesta; - beforeEach(function () { - createElementVisible(); - }); - it('when you have a render', function() { - respuesta = spec.buildRequests(bidRequests); - clock.tick(1005); - - expect(respuesta.data.vs).to.equal('F'); - - expect(utils.getDataFromLocalStorage(storageIdRender)).to.equal('1'); - expect(utils.getDataFromLocalStorage(storageIdView)).to.equal('1'); - }); - it('when you have more than four render', function() { - utils.setDataInLocalStorage(storageIdRender, 4); - respuesta = spec.buildRequests(bidRequests); - clock.tick(1005); - - expect(respuesta.data.vs).to.equal('0'); - - expect(utils.getDataFromLocalStorage(storageIdRender)).to.equal('5'); - expect(utils.getDataFromLocalStorage(storageIdView)).to.equal('1'); - }); - it('when you have more than four render and already record visibility', function() { - utils.setDataInLocalStorage(storageIdRender, 4); - utils.setDataInLocalStorage(storageIdView, 4); - respuesta = spec.buildRequests(bidRequests); - clock.tick(1005); - - expect(respuesta.data.vs).to.equal('a'); - - expect(utils.getDataFromLocalStorage(storageIdRender)).to.equal('5'); - expect(utils.getDataFromLocalStorage(storageIdView)).to.equal('5'); - }); - }); - - context('when element is out of view', function() { - let respuesta; - beforeEach(function () { - createElementOutOfView(); - }); - - it('when you have a render', function() { - respuesta = spec.buildRequests(bidRequests); - clock.tick(1005); - expect(respuesta.data.vs).to.equal('F'); - - expect(utils.getDataFromLocalStorage(storageIdRender)).to.equal('1'); - expect(utils.getDataFromLocalStorage(storageIdView)).to.equal(null); - }); - it('when you have more than four render', function() { - utils.setDataInLocalStorage(storageIdRender, 4); - respuesta = spec.buildRequests(bidRequests); - clock.tick(1005); - expect(respuesta.data.vs).to.equal('0'); - - expect(utils.getDataFromLocalStorage(storageIdRender)).to.equal('5'); - expect(utils.getDataFromLocalStorage(storageIdView)).to.equal(null); - }); - }); - - context('when element is partially in view', function() { - let respuesta; - it('should register visibility with more than 50%', function() { - createPartiallyVisibleElement(); - respuesta = spec.buildRequests(bidRequests); - clock.tick(1005); - - expect(utils.getDataFromLocalStorage(storageIdRender)).to.equal('1'); - expect(utils.getDataFromLocalStorage(storageIdView)).to.equal('1'); - }); - it('you should not register visibility with less than 50%', function() { - createPartiallyInvisibleElement(); - respuesta = spec.buildRequests(bidRequests); - clock.tick(1005); - - expect(utils.getDataFromLocalStorage(storageIdRender)).to.equal('1'); - expect(utils.getDataFromLocalStorage(storageIdView)).to.equal(null); - }); - }); - context('when width or height of the element is zero', function() { - beforeEach(function () { - createElementVisible(); - }); - it('if the width is zero but the height is within the range', function() { - element.style.width = '0px'; - spec.buildRequests(bidRequests) - clock.tick(1005); - - expect(utils.getDataFromLocalStorage(storageIdRender)).to.equal('1'); - expect(utils.getDataFromLocalStorage(storageIdView)).to.equal(null); - }); - it('if the height is zero but the width is within the range', function() { - element.style.height = '0px'; - spec.buildRequests(bidRequests) - clock.tick(1005); - - expect(utils.getDataFromLocalStorage(storageIdRender)).to.equal('1'); - expect(utils.getDataFromLocalStorage(storageIdView)).to.equal(null); - }); - it('if both are zero', function() { - element.style.height = '0px'; - element.style.width = '0px'; - spec.buildRequests(bidRequests) - clock.tick(1005); - - expect(utils.getDataFromLocalStorage(storageIdRender)).to.equal('1'); - expect(utils.getDataFromLocalStorage(storageIdView)).to.equal(null); - }); - }); - context('when tab is inactive', function() { - it('I should not register if it is not in focus', function() { - createElementVisible(); - focusStub.returns(false); - spec.buildRequests(bidRequests); - clock.tick(1005); - expect(utils.getDataFromLocalStorage(storageIdRender)).to.equal('1'); - expect(utils.getDataFromLocalStorage(storageIdView)).to.equal(null); - }); - }); - context('segmentBeginsBeforeTheVisibleRange', function() { - it('segmentBeginsBeforeTheVisibleRange', function() { - createElementOutOfRange(); - spec.buildRequests(bidRequests); - clock.tick(1005); - expect(utils.getDataFromLocalStorage(storageIdRender)).to.equal('1'); - expect(utils.getDataFromLocalStorage(storageIdView)).to.equal(null); - }); - }); - context('when there are multiple adunit', function() { - let respuesta; - beforeEach(function () { - [ADUNIT_CODE_VIEW, ADUNIT_CODE_VIEW2, ADUNIT_CODE_VIEW3].forEach(ac => { - utils.setDataInLocalStorage('pbsr_' + ac, 5); - utils.setDataInLocalStorage('pbvi_' + ac, 5); - }); - }); - afterEach(function () { - [ADUNIT_CODE_VIEW, ADUNIT_CODE_VIEW2, ADUNIT_CODE_VIEW3].forEach(ac => { - if (document.getElementById(ac)) { - document.body.removeChild(document.getElementById(ac)); - } - window.top.localStorage.removeItem(ac); - window.top.localStorage.removeItem(ac); - }); - }); - it('all visibles', function() { - createElementVisible(ADUNIT_CODE_VIEW); - createElementVisible(ADUNIT_CODE_VIEW2); - createElementVisible(ADUNIT_CODE_VIEW3); - - respuesta = spec.buildRequests(bidRequestMultiple); - clock.tick(1005); - [ADUNIT_CODE_VIEW, ADUNIT_CODE_VIEW2, ADUNIT_CODE_VIEW3].forEach(ac => { - expect(utils.getDataFromLocalStorage('pbsr_' + ac)).to.equal('6'); - expect(utils.getDataFromLocalStorage('pbvi_' + ac)).to.equal('6'); - }); - expect('aaa').to.equal(respuesta.data.vs); - }); - it('none visible', function() { - createElementOutOfView(ADUNIT_CODE_VIEW); - createElementOutOfView(ADUNIT_CODE_VIEW2); - createElementOutOfView(ADUNIT_CODE_VIEW3); - - respuesta = spec.buildRequests(bidRequestMultiple); - clock.tick(1005); - [ADUNIT_CODE_VIEW, ADUNIT_CODE_VIEW2, ADUNIT_CODE_VIEW3].forEach(ac => { - expect(utils.getDataFromLocalStorage('pbsr_' + ac)).to.equal('6'); - expect(utils.getDataFromLocalStorage('pbvi_' + ac)).to.equal('5'); - }); - - expect('aaa').to.equal(respuesta.data.vs); - }); - it('some visible and others not visible', function() { - createElementVisible(ADUNIT_CODE_VIEW); - createElementOutOfView(ADUNIT_CODE_VIEW2); - createElementOutOfView(ADUNIT_CODE_VIEW3); - - respuesta = spec.buildRequests(bidRequestMultiple); - clock.tick(1005); - expect(utils.getDataFromLocalStorage('pbsr_' + ADUNIT_CODE_VIEW)).to.equal('6'); - expect(utils.getDataFromLocalStorage('pbvi_' + ADUNIT_CODE_VIEW)).to.equal('6'); - [ADUNIT_CODE_VIEW2, ADUNIT_CODE_VIEW3].forEach(ac => { - expect(utils.getDataFromLocalStorage('pbsr_' + ac)).to.equal('6'); - expect(utils.getDataFromLocalStorage('pbvi_' + ac)).to.equal('5'); - }); - expect('aaa').to.equal(respuesta.data.vs); - }); - }); - }); -}); diff --git a/test/spec/modules/etargetBidAdapter_spec.js b/test/spec/modules/etargetBidAdapter_spec.js index e4cccbf5cf33..ed512e55ea94 100644 --- a/test/spec/modules/etargetBidAdapter_spec.js +++ b/test/spec/modules/etargetBidAdapter_spec.js @@ -29,7 +29,7 @@ describe('etarget adapter', function () { it('should handle global request parameters', function () { let parsedUrl = parseUrl(spec.buildRequests([bids[0]]).url); - assert.equal(parsedUrl.path, '//sk.search.etargetnet.com/hb'); + assert.equal(parsedUrl.path, 'https://sk.search.etargetnet.com/hb'); }); it('should set correct request method', function () { diff --git a/test/spec/modules/eywamediaBidAdapter_spec.js b/test/spec/modules/eywamediaBidAdapter_spec.js deleted file mode 100644 index 945c0dd0d013..000000000000 --- a/test/spec/modules/eywamediaBidAdapter_spec.js +++ /dev/null @@ -1,253 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/eywamediaBidAdapter'; - -describe('EywamediaAdapter', function () { - let serverResponse, bidRequests, bidRequest, bidResponses; - const ENDPOINT = 'https://adtarbostg.eywamedia.com/auctions/prebidjs/3000'; - - bidRequests = [ - { - 'auctionId': 'fc917230-a5e1-4a42-b7d9-8fb776124e43', - 'sizes': [[300, 250]], - 'bidRequestsCount': 1, - 'params': { - 'publisherId': '1234_abcd' - }, - 'mediaTypes': { - 'banner': { - 'sizes': [[300, 250]] - } - }, - 'crumbs': { - 'pubcid': '8b640d4e-1f6d-4fd3-b63f-2570572d8100' - }, - 'bidId': '28b09d0543d671', - 'adUnitCode': 'div-gpt-ad-1460505748561-0', - 'transactionId': 'd909c39c-ecc9-41a4-897c-2d2fdfdf41b1', - 'src': 'client', - 'bidder': 'eywamedia', - 'bidderRequestId': '14d8cbc769114b' - }, - { - 'auctionId': 'fc917230-a5e1-4a42-b7d9-8fb776124e43', - 'sizes': [[728, 90]], - 'bidRequestsCount': 1, - 'params': { - 'publisherId': '1234_abcd' - }, - 'mediaTypes': { - 'banner': { - 'sizes': [[728, 90]] - } - }, - 'crumbs': { - 'pubcid': '8b640d4e-1f6d-4fd3-b63f-2570572d8100' - }, - 'bidId': '28b09d0543d672', - 'adUnitCode': 'div-gpt-ad-1460505748561-0', - 'transactionId': 'd909c39c-ecc9-41a4-897c-2d2fdfdf41b2', - 'src': 'client', - 'bidder': 'eywamedia', - 'bidderRequestId': '14d8cbc769114b' - } - ]; - - bidRequest = { - 'auctionId': 'c88115a4-7e71-43d0-9c96-a9b43ebd143d', - 'auctionStart': 1564725164517, - 'bidderCode': 'eywamedia', - 'bidderRequestId': '191afa18994fdd', - 'bids': [], - 'refererInfo': { - 'canonicalUrl': '', - 'numIframes': 0, - 'reachedTop': true, - 'referer': '' - }, - 'stack': [ - '' - ], - 'start': 1564725164520, - 'timeout': 3000 - }; - - let testBid = { - 'bidder': 'eywamedia', - 'params': { - 'publisherId': '1234_abcd' - } - }; - - describe('isBidRequestValid', function () { - it('should return true when required params found', function () { - assert(spec.isBidRequestValid(testBid)); - }); - - it('should return false when required params are missing', function () { - testBid.params = { - test: '231212312' - }; - assert.isFalse(spec.isBidRequestValid(testBid)); - }); - }); - - describe('buildRequests', function () { - it('should attempt to send bid requests to the endpoint via POST', function () { - const requests = spec.buildRequests(bidRequests, bidRequest); - expect(requests.method).to.equal('POST'); - expect(requests.url).to.be.equal(ENDPOINT); - }); - - it('should not blow up if crumbs is undefined', function () { - let bidArray = [ - { ...testBid, crumbs: undefined } - ] - expect(function () { spec.buildRequests(bidArray, bidRequest) }).not.to.throw() - }) - - it('should return true when required params found', function () { - testBid.params.publisherId = '1234_abcd'; - assert(spec.isBidRequestValid(testBid)); - }); - }); - - describe('interpretResponse', function () { - beforeEach(function () { - serverResponse = { - 'body': - [ - { - 'ad': '', - 'adSlot': '', - 'adUnitCode': 'div-gpt-ad-1460505748561-0', - 'adUrl': 'http://eywamedia.com', - 'bidId': '28b09d0543d671', - 'bidder': 'eywamedia', - 'bidderCode': 'eywamedia', - 'cpm': 1, - 'height': 250, - 'requestTimestamp': 1564725162, - 'respType': 'banner', - 'size': '300X250', - 'statusMessage': 'Bid available', - 'transactionId': 'd909c39c-ecc9-41a4-897c-2d2fdfdf41b1', - 'usesGenericKeys': true, - 'width': 300 - }, - { - 'ad': '', - 'adSlot': '', - 'adUnitCode': 'div-gpt-ad-1460505748561-1', - 'adUrl': 'http://eywamedia.com', - 'bidId': '28b09d0543d672', - 'bidder': 'eywamedia', - 'bidderCode': 'eywamedia', - 'cpm': 1, - 'height': 90, - 'requestTimestamp': 1564725164, - 'respType': 'banner', - 'size': '728X90', - 'statusMessage': 'Bid available', - 'transactionId': 'd909c39c-ecc9-41a4-897c-2d2fdfdf41b2', - 'usesGenericKeys': true, - 'width': 728 - } - ], - 'headers': 'header?' - }; - - bidRequest = { - 'data': - { - 'bidPayload': - [ - { - 'auctionId': 'fc917230-a5e1-4a42-b7d9-8fb776124e43', - 'sizes': [[300, 250]], - 'bidRequestsCount': 1, - 'params': { - 'publisherId': '1234_abcd' - }, - 'mediaTypes': { - 'banner': { - 'sizes': [[300, 250]] - } - }, - 'crumbs': { - 'pubcid': '8b640d4e-1f6d-4fd3-b63f-2570572d8100' - }, - 'bidId': '28b09d0543d671', - 'adUnitCode': 'div-gpt-ad-1460505748561-0', - 'transactionId': 'd909c39c-ecc9-41a4-897c-2d2fdfdf41b1', - 'src': 'client', - 'bidder': 'eywamedia', - 'bidderRequestId': '14d8cbc769114b' - }, - { - 'auctionId': 'fc917230-a5e1-4a42-b7d9-8fb776124e43', - 'sizes': [[728, 90]], - 'bidRequestsCount': 1, - 'params': { - 'publisherId': '1234_abcd' - }, - 'mediaTypes': { - 'banner': { - 'sizes': [[728, 90]] - } - }, - 'crumbs': { - 'pubcid': '8b640d4e-1f6d-4fd3-b63f-2570572d8100' - }, - 'bidId': '28b09d0543d672', - 'adUnitCode': 'div-gpt-ad-1460505748561-0', - 'transactionId': 'd909c39c-ecc9-41a4-897c-2d2fdfdf41b2', - 'src': 'client', - 'bidder': 'eywamedia', - 'bidderRequestId': '14d8cbc769114b' - } - ] - } - }; - bidResponses = [ - { - 'ad': '', - 'bidderCode': 'eywamedia', - 'cpm': 1, - 'creativeId': '28b09d0543d671', - 'currency': 'USD', - 'height': 250, - 'mediaType': 'banner', - 'netRevenue': true, - 'requestId': '28b09d0543d671', - 'transactionId': 'd909c39c-ecc9-41a4-897c-2d2fdfdf41b1', - 'ttl': 360, - 'width': 300 - }, - { - 'ad': '', - 'bidderCode': 'eywamedia', - 'cpm': 1, - 'creativeId': '28b09d0543d672', - 'currency': 'USD', - 'height': 90, - 'mediaType': 'banner', - 'netRevenue': true, - 'requestId': '28b09d0543d672', - 'transactionId': 'd909c39c-ecc9-41a4-897c-2d2fdfdf41b2', - 'ttl': 360, - 'width': 728 - } - ] - }); - - it('should respond with empty response when there is empty serverResponse', function () { - let result = spec.interpretResponse({ body: {} }, bidRequest); - assert.deepEqual(result, []); - }); - - it('should respond with multile response when there is multiple serverResponse', function () { - let result = spec.interpretResponse(serverResponse, bidRequest); - assert.deepEqual(result, bidResponses); - }); - }); -}); diff --git a/test/spec/modules/fairtradeBidAdapter_spec.js b/test/spec/modules/fairtradeBidAdapter_spec.js deleted file mode 100644 index ecd5db3c0511..000000000000 --- a/test/spec/modules/fairtradeBidAdapter_spec.js +++ /dev/null @@ -1,289 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/fairtradeBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; - -describe('FairTradeAdapter', function () { - const adapter = newBidder(spec); - - describe('inherited functions', function () { - it('exists and is a function', function () { - expect(adapter.callBids).to.exist.and.to.be.a('function'); - }); - }); - - describe('isBidRequestValid', function () { - let bid = { - 'bidder': 'fairtrade', - 'params': { - 'uid': '166' - }, - 'adUnitCode': 'adunit-code', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - }; - - it('should return true when required params found', function () { - expect(spec.isBidRequestValid(bid)).to.equal(true); - }); - - it('should return false when required params are not passed', function () { - let bid = Object.assign({}, bid); - delete bid.params; - bid.params = { - 'uid': 0 - }; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - }); - - describe('buildRequests', function () { - let bidRequests = [ - { - 'bidder': 'fairtrade', - 'params': { - 'uid': '165' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - }, - { - 'bidder': 'fairtrade', - 'params': { - 'uid': '165' - }, - 'adUnitCode': 'adunit-code-2', - 'sizes': [[728, 90]], - 'bidId': '3150ccb55da321', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - }, - { - 'bidder': 'fairtrade', - 'params': { - 'uid': '167' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '42dbe3a7168a6a', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - } - ]; - - it('should attach valid params to the tag', function () { - const request = spec.buildRequests([bidRequests[0]]); - const payload = request.data; - expect(payload).to.be.an('object'); - expect(payload).to.have.property('u').that.is.a('string'); - expect(payload).to.have.property('pt', 'net'); - expect(payload).to.have.property('auids', '165'); - expect(payload).to.have.property('r', '22edbae2733bf6'); - }); - - it('auids must not be duplicated', function () { - const request = spec.buildRequests(bidRequests); - const payload = request.data; - expect(payload).to.be.an('object'); - expect(payload).to.have.property('u').that.is.a('string'); - expect(payload).to.have.property('pt', 'net'); - expect(payload).to.have.property('auids', '165,167'); - expect(payload).to.have.property('r', '22edbae2733bf6'); - }); - - it('pt parameter must be "gross" if params.priceType === "gross"', function () { - bidRequests[1].params.priceType = 'gross'; - const request = spec.buildRequests(bidRequests); - const payload = request.data; - expect(payload).to.be.an('object'); - expect(payload).to.have.property('u').that.is.a('string'); - expect(payload).to.have.property('pt', 'gross'); - expect(payload).to.have.property('auids', '165,167'); - expect(payload).to.have.property('r', '22edbae2733bf6'); - delete bidRequests[1].params.priceType; - }); - - it('pt parameter must be "net" or "gross"', function () { - bidRequests[1].params.priceType = 'some'; - const request = spec.buildRequests(bidRequests); - const payload = request.data; - expect(payload).to.be.an('object'); - expect(payload).to.have.property('u').that.is.a('string'); - expect(payload).to.have.property('pt', 'net'); - expect(payload).to.have.property('auids', '165,167'); - expect(payload).to.have.property('r', '22edbae2733bf6'); - delete bidRequests[1].params.priceType; - }); - }); - - describe('interpretResponse', function () { - const responses = [ - {'bid': [{'price': 1.15, 'adm': '
test content 1
', 'auid': 165, 'h': 250, 'w': 300}], 'seat': '1'}, - {'bid': [{'price': 0.5, 'adm': '
test content 2
', 'auid': 166, 'h': 90, 'w': 728}], 'seat': '1'}, - {'bid': [{'price': 0, 'auid': 167, 'h': 250, 'w': 300}], 'seat': '1'}, - {'bid': [{'price': 0, 'adm': '
test content 4
', 'h': 250, 'w': 300}], 'seat': '1'}, - undefined, - {'bid': [], 'seat': '1'}, - {'seat': '1'}, - ]; - - it('should get correct bid response', function () { - const bidRequests = [ - { - 'bidder': 'fairtrade', - 'params': { - 'uid': '165' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '659423fff799cb', - 'bidderRequestId': '5f2009617a7c0a', - 'auctionId': '1cbd2feafe5e8b', - } - ]; - const request = spec.buildRequests(bidRequests); - const expectedResponse = [ - { - 'requestId': '659423fff799cb', - 'cpm': 1.15, - 'creativeId': 165, - 'dealId': undefined, - 'width': 300, - 'height': 250, - 'ad': '
test content 1
', - 'currency': 'USD', - 'netRevenue': true, - 'ttl': 360, - } - ]; - - const result = spec.interpretResponse({'body': {'seatbid': [responses[0]]}}, request); - expect(result).to.deep.equal(expectedResponse); - }); - - it('should get correct multi bid response', function () { - const bidRequests = [ - { - 'bidder': 'fairtrade', - 'params': { - 'uid': '165' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '300bfeb0d71a5b', - 'bidderRequestId': '2c2bb1972df9a', - 'auctionId': '1fa09aee5c8c99', - }, - { - 'bidder': 'fairtrade', - 'params': { - 'uid': '166' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '4dff80cc4ee346', - 'bidderRequestId': '2c2bb1972df9a', - 'auctionId': '1fa09aee5c8c99', - }, - { - 'bidder': 'fairtrade', - 'params': { - 'uid': '165' - }, - 'adUnitCode': 'adunit-code-2', - 'sizes': [[728, 90]], - 'bidId': '5703af74d0472a', - 'bidderRequestId': '2c2bb1972df9a', - 'auctionId': '1fa09aee5c8c99', - } - ]; - const request = spec.buildRequests(bidRequests); - const expectedResponse = [ - { - 'requestId': '300bfeb0d71a5b', - 'cpm': 1.15, - 'creativeId': 165, - 'dealId': undefined, - 'width': 300, - 'height': 250, - 'ad': '
test content 1
', - 'currency': 'USD', - 'netRevenue': true, - 'ttl': 360, - }, - { - 'requestId': '5703af74d0472a', - 'cpm': 1.15, - 'creativeId': 165, - 'dealId': undefined, - 'width': 300, - 'height': 250, - 'ad': '
test content 1
', - 'currency': 'USD', - 'netRevenue': true, - 'ttl': 360, - }, - { - 'requestId': '4dff80cc4ee346', - 'cpm': 0.5, - 'creativeId': 166, - 'dealId': undefined, - 'width': 728, - 'height': 90, - 'ad': '
test content 2
', - 'currency': 'USD', - 'netRevenue': true, - 'ttl': 360, - } - ]; - - const result = spec.interpretResponse({'body': {'seatbid': [responses[0], responses[1]]}}, request); - expect(result).to.deep.equal(expectedResponse); - }); - - it('handles wrong and nobid responses', function () { - const bidRequests = [ - { - 'bidder': 'fairtrade', - 'params': { - 'uid': '167' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '300bfeb0d7190gf', - 'bidderRequestId': '2c2bb1972d23af', - 'auctionId': '1fa09aee5c84d34', - }, - { - 'bidder': 'fairtrade', - 'params': { - 'uid': '168' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '300bfeb0d71321', - 'bidderRequestId': '2c2bb1972d23af', - 'auctionId': '1fa09aee5c84d34', - }, - { - 'bidder': 'fairtrade', - 'params': { - 'uid': '169' - }, - 'adUnitCode': 'adunit-code-2', - 'sizes': [[728, 90]], - 'bidId': '300bfeb0d7183bb', - 'bidderRequestId': '2c2bb1972d23af', - 'auctionId': '1fa09aee5c84d34', - } - ]; - const request = spec.buildRequests(bidRequests); - const result = spec.interpretResponse({'body': {'seatbid': responses.slice(2)}}, request); - expect(result.length).to.equal(0); - }); - }); -}); diff --git a/test/spec/modules/fidelityBidAdapter_spec.js b/test/spec/modules/fidelityBidAdapter_spec.js deleted file mode 100644 index e8e008103e6d..000000000000 --- a/test/spec/modules/fidelityBidAdapter_spec.js +++ /dev/null @@ -1,180 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/fidelityBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; - -describe('FidelityAdapter', function () { - const adapter = newBidder(spec); - - describe('inherited functions', function () { - it('exists and is a function', function () { - expect(adapter.callBids).to.exist.and.to.be.a('function'); - }); - }); - - describe('isBidRequestValid', function () { - let bid = { - 'bidder': 'fidelity', - 'params': { - 'zoneid': '37', - 'floor': '0.05', - 'server': 't.fidelity-media.com', - }, - 'adUnitCode': 'adunit-code', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - }; - - it('should return true when required params found', function () { - expect(spec.isBidRequestValid(bid)).to.equal(true); - }); - - it('should return true when required params found', function () { - let bid = Object.assign({}, bid); - delete bid.params; - bid.params = { - 'zoneid': '37', - }; - expect(spec.isBidRequestValid(bid)).to.equal(true); - }); - - it('should return false when required params are not passed', function () { - let bid = Object.assign({}, bid); - delete bid.params; - bid.params = { - 'zoneid': 0, - }; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - }); - - describe('buildRequests', function () { - let bidderRequest = { - bidderCode: 'fidelity', - requestId: 'c45dd708-a418-42ec-b8a7-b70a6c6fab0a', - bidderRequestId: '178e34bad3658f', - bids: [ - { - bidder: 'fidelity', - params: { - zoneid: '37', - floor: '0.05', - server: 't.fidelity-media.com', - }, - placementCode: '/19968336/header-bid-tag-0', - sizes: [[300, 250], [320, 50]], - bidId: '2ffb201a808da7', - bidderRequestId: '178e34bad3658f', - requestId: 'c45dd708-a418-42ec-b8a7-b70a6c6fab0a', - transactionId: 'd45dd707-a418-42ec-b8a7-b70a6c6fab0b' - } - ], - start: 1472239426002, - auctionStart: 1472239426000, - timeout: 5000 - }; - - it('should add source and verison to the tag', function () { - const [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); - const payload = request.data; - expect(payload.from).to.exist; - expect(payload.v).to.exist; - expect(payload.requestid).to.exist; - expect(payload.impid).to.exist; - expect(payload.zoneid).to.exist; - expect(payload.floor).to.exist; - expect(payload.charset).to.exist; - expect(payload.subid).to.exist; - expect(payload.flashver).to.exist; - expect(payload.tmax).to.exist; - expect(payload.defloc).to.exist; - }); - - it('should add gdpr consent information to the request', function () { - let consentString = 'BOJ8RZsOJ8RZsABAB8AAAAAZ+A=='; - bidderRequest.gdprConsent = { - gdprApplies: true, - consentString: consentString, - vendorData: { - vendorConsents: { - '408': 1 - }, - }, - }; - const [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); - const payload = request.data; - expect(payload.gdpr).to.exist.and.to.be.a('number'); - expect(payload.gdpr).to.equal(1); - expect(payload.consent_str).to.exist.and.to.be.a('string'); - expect(payload.consent_str).to.equal(consentString); - expect(payload.consent_given).to.exist.and.to.be.a('number'); - expect(payload.consent_given).to.equal(1); - }); - - it('sends bid request to ENDPOINT via GET', function () { - const [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); - expect(request.url).to.equal('//t.fidelity-media.com/delivery/hb.php'); - expect(request.method).to.equal('GET'); - }); - }) - - describe('interpretResponse', function () { - let response = { - 'id': '543210', - 'seatbid': [ { - 'bid': [ { - 'id': '1111111', - 'impid': 'bidId-123456-1', - 'price': 0.09, - 'adm': '', - 'width': 728, - 'height': 90, - } ] - } ] - }; - - it('should get correct bid response', function () { - let expectedResponse = [ - { - requestId: 'bidId-123456-1', - creativeId: 'bidId-123456-1', - cpm: 0.09, - width: 728, - height: 90, - ad: '', - netRevenue: true, - currency: 'USD', - ttl: 360, - } - ]; - - let result = spec.interpretResponse({ body: response }); - expect(Object.keys(result[0])).to.deep.equal(Object.keys(expectedResponse[0])); - }); - - it('handles nobid responses', function () { - let response = { - 'id': '543210', - 'seatbid': [ ] - }; - - let result = spec.interpretResponse({ body: response }); - expect(result.length).to.equal(0); - }); - }); - - describe('user sync', function () { - const syncUrl = '//x.fidelity-media.com/delivery/matches.php?type=iframe'; - - it('should register the sync iframe', function () { - expect(spec.getUserSyncs({})).to.be.undefined; - expect(spec.getUserSyncs({iframeEnabled: false})).to.be.undefined; - const options = spec.getUserSyncs({iframeEnabled: true}); - expect(options).to.not.be.undefined; - expect(options).to.have.lengthOf(1); - expect(options[0].type).to.equal('iframe'); - expect(options[0].url).to.equal(syncUrl); - }); - }); -}); diff --git a/test/spec/modules/freewheel-sspBidAdapter_spec.js b/test/spec/modules/freewheel-sspBidAdapter_spec.js deleted file mode 100644 index 45754d0250c5..000000000000 --- a/test/spec/modules/freewheel-sspBidAdapter_spec.js +++ /dev/null @@ -1,239 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/freewheel-sspBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; - -const ENDPOINT = '//ads.stickyadstv.com/www/delivery/swfIndex.php'; - -describe('freewheel-ssp BidAdapter Test', function () { - const adapter = newBidder(spec); - - describe('inherited functions', function () { - it('exists and is a function', function () { - expect(adapter.callBids).to.exist.and.to.be.a('function'); - }); - }); - - describe('isBidRequestValid', function () { - let bid = { - 'bidder': 'freewheel-ssp', - 'params': { - 'zoneId': '277225' - }, - 'adUnitCode': 'adunit-code', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - }; - - it('should return true when required params found', function () { - expect(spec.isBidRequestValid(bid)).to.equal(true); - }); - - it('should return false when required params are not passed', function () { - let bid = Object.assign({}, bid); - delete bid.params; - bid.params = { - wrong: 'missing zone id' - }; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - }); - - describe('buildRequests', function () { - let bidRequests = [ - { - 'bidder': 'freewheel-ssp', - 'params': { - 'zoneId': '277225', - 'gdpr_consented_providers': '123,345', - 'vastUrlParams': {'ownerId': 'kombRJ'} - }, - 'adUnitCode': 'adunit-code', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - 'gdprConsent': { - 'consentString': 'BOJ/P2HOJ/P2HABABMAAAAAZ+A==', - 'gdprApplies': true - } - } - ]; - - it('should add parameters to the tag', function () { - const request = spec.buildRequests(bidRequests, bidRequests[0]); - const payload = request.data; - expect(payload.reqType).to.equal('AdsSetup'); - expect(payload.protocolVersion).to.equal('2.0'); - expect(payload.zoneId).to.equal('277225'); - expect(payload.componentId).to.equal('mustang'); - expect(payload.ownerId).to.equal('kombRJ'); - expect(payload.playerSize).to.equal('300x600'); - expect(payload._fw_gdpr).to.equal(true); - expect(payload._fw_gdpr_consent).to.equal('BOJ/P2HOJ/P2HABABMAAAAAZ+A=='); - expect(payload._fw_gdpr_consented_providers).to.equal('123,345'); - }); - - it('sends bid request to ENDPOINT via GET', function () { - const request = spec.buildRequests(bidRequests, bidRequests[0]); - expect(request.url).to.contain(ENDPOINT); - expect(request.method).to.equal('GET'); - }); - }); - - describe('interpretResponse - formated', function () { - let intextBidRequests = [ - { - 'bidder': 'freewheel-ssp', - 'params': { - 'zoneId': '277225', - 'format': 'intext-roll' - }, - 'adUnitCode': 'adunit-code', - 'sizes': [[600, 250], [300, 600]], - 'bidId': '30b3other1c1838de1e', - 'bidderRequestId': '22edbae273other3bf6', - 'auctionId': '1d1a03079test0a475', - }, - { - 'bidder': 'stickyadstv', - 'params': { - 'zoneId': '277225', - 'format': 'test' - }, - 'adUnitCode': 'adunit-code', - 'sizes': [[300, 600]], - 'bidId': '2', - 'bidderRequestId': '3', - 'auctionId': '4', - } - ]; - - let expandBidRequests = [ - { - 'bidder': 'freewheel-ssp', - 'params': { - 'zoneId': '277225', - 'format': 'expand-banner', - 'vastUrlParams': {'ownerId': 'kombRJ'} - }, - 'adUnitCode': 'adunit-code', - 'sizes': [[600, 250], [300, 600]], - 'bidId': '30b3other1c1838de1e', - 'bidderRequestId': '22edbae273other3bf6', - 'auctionId': '1d1a03079test0a475', - } - ]; - - let bannerBidRequests = [ - { - 'bidder': 'freewheel-ssp', - 'params': { - 'zoneId': '277225' - }, - 'adUnitCode': 'adunit-code', - 'sizes': [[600, 250], [300, 600]], - 'bidId': '30b3other1c1838de1e', - 'bidderRequestId': '22edbae273other3bf6', - 'auctionId': '1d1a03079test0a475', - } - ]; - - let response = '' + - '' + - ' ' + - ' Adswizz' + - ' ' + - ' ' + - ' ' + - ' 00:00:09' + - ' ' + - ' ' + - ' ' + - ' ' + - ' ' + - ' ' + - ' ' + - ' 0.2000' + - ' ' + - ' ' + - ' ' + - ''; - - let ad = '
'; - let intextAd = '
'; - let expandAd = '
'; - - it('should get correct intext bid response', function () { - var request = spec.buildRequests(bannerBidRequests, bannerBidRequests[0]); - - let expectedResponse = [ - { - requestId: '30b31c1838de1e', - cpm: '0.2000', - width: 300, - height: 600, - creativeId: '28517153', - currency: 'EUR', - netRevenue: true, - ttl: 360, - ad: ad - } - ]; - - let result = spec.interpretResponse(response, request); - expect(Object.keys(result[0])).to.deep.equal(Object.keys(expectedResponse[0])); - }); - - it('should get correct expand bid response', function () { - var request = spec.buildRequests(expandBidRequests, expandBidRequests[0]); - - let expectedResponse = [ - { - requestId: '30b31c1838de1e', - cpm: '0.2000', - width: 300, - height: 600, - creativeId: '28517153', - currency: 'EUR', - netRevenue: true, - ttl: 360, - ad: expandAd - } - ]; - - let result = spec.interpretResponse(response, request); - expect(Object.keys(result[0])).to.deep.equal(Object.keys(expectedResponse[0])); - }); - - it('should get correct bid response with formated ad', function () { - var request = spec.buildRequests(intextBidRequests, intextBidRequests[0]); - - let expectedResponse = [ - { - requestId: '30b31c1838de1e', - cpm: '0.2000', - width: 300, - height: 600, - creativeId: '28517153', - currency: 'EUR', - netRevenue: true, - ttl: 360, - ad: intextAd - } - ]; - - let result = spec.interpretResponse(response, request); - expect(Object.keys(result[0])).to.deep.equal(Object.keys(expectedResponse[0])); - }); - - it('handles nobid responses', function () { - var reqest = spec.buildRequests(intextBidRequests, intextBidRequests[0]); - let response = ''; - - let result = spec.interpretResponse(response, reqest); - expect(result.length).to.equal(0); - }); - }); -}); diff --git a/test/spec/modules/fyberBidAdapter_spec.js b/test/spec/modules/fyberBidAdapter_spec.js deleted file mode 100644 index a16c069d2a0b..000000000000 --- a/test/spec/modules/fyberBidAdapter_spec.js +++ /dev/null @@ -1,154 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/fyberBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; -import bidRequest from '../../fixtures/video/bidRequest.json'; - -const bidId = '21b2499bf34cf8'; -const mock = { - bid: { - bidder: 'fyber', - params: { - appId: 'MyCompany_MyApp', - spotType: 'rectangle', - gdprPrivacyConsent: true, - qa: { - // url: 'http://ia-test08.inner-active.mobi:8080/simpleM2M/requestJsonAd', - cpm: 10 - }, - customParams: { - // referrer: 'referrer', - // page: 'aaaa', - portal: 7002 - // KEYWORDS: 'bbb' - } - } - }, - bidsRequest: [ - { - adUnitCode: '/19968336/header-bid-tag-1', - auctionId: 'f270d8dd-29c6-4aca-8648-7d722590b899', - bidId, - bidder: 'fyber', - bidderRequestId: '1bcd667e09f48e', - params: { - spotType: 'rectangle', - gdprPrivacyConsent: true, - qa: {cpm: 10}, - customParams: {portal: 7002}, - appId: 'MyCompany_MyApp' - }, - sizes: [[300, 250], [300, 600]], - transactionId: 'a0253346-df4e-4f1a-b004-1f50e8e6af69' - } - ], - validResponse: { - body: { - ad: { - html: '

Fyber Ad

' - }, - config: { - tracking: { - clicks: ['c1'], - impressions: ['i1'] - } - } - }, - headers: { - get(headerName) { - if (headerName === 'X-IA-Pricing-Value') { - return 10; - } - return headerName; - } - } - }, - invalidResponse: { - body: {}, - headers: { - get(headerName) { - return headerName; - } - } - } -}; - -describe('FyberAdapter', function () { - const adapter = newBidder(spec); - - describe('inherited functions', function () { - it('callBids exists and is a function', function () { - expect(adapter.callBids).to.exist.and.to.be.a('function'); - }); - }); - - describe('Verifies bidder code', function () { - it('Verifies bidder code', function () { - expect(spec.code).to.equal('fyber'); - }); - }); - - describe('isBidRequestValid', function () { - it('should return true when required params found', function () { - const bid = Object.assign({}, mock.bid); - expect(spec.isBidRequestValid(bid)).to.equal(true); - }); - - it('should return false when required params{spotType} not found', function () { - const bid = Object.assign({}, mock.bid); - delete bid.params.spotType; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - - it('should return false when required{appId} params not found', function () { - const bid = Object.assign({}, mock.bid); - delete bid.params.appId; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - }); - - describe('buildRequests', function () { - const bidsRequest = Object.assign([], mock.bidsRequest); - const requests = spec.buildRequests(bidsRequest); - - it('Verify only one build request', function () { - expect(requests.length).to.equal(1); - }); - - const request = requests[0]; - - it('Verify build request http method', function () { - expect(request.method).to.equal('GET'); - }); - - it('Verify build request bidId', function () { - expect(request.bidId).to.equal(bidId); - }); - }); - - describe('interpretResponse', function () { - const request = Object.assign([], mock.bidsRequest)[0]; - const validResponse = Object.assign({}, mock.validResponse); - const validResult = spec.interpretResponse(validResponse, request); - - it('Verify only one bid response', function () { - expect(validResult.length).to.equal(1); - }); - - const bidResponse = validResult[0]; - - it('Verify CPM', function () { - expect(bidResponse.cpm).to.equal(10000); - }); - - it('Verify requestId', function () { - expect(bidResponse.requestId).to.equal(bidId); - }); - - const invalidResponse = Object.assign({}, mock.invalidResponse); - const invalidResult = spec.interpretResponse(invalidResponse, request); - - it('Verify empty bid response', function () { - expect(invalidResult.length).to.equal(0); - }); - }); -}); diff --git a/test/spec/modules/gammaBidAdapter_spec.js b/test/spec/modules/gammaBidAdapter_spec.js deleted file mode 100644 index 99593e6e06fb..000000000000 --- a/test/spec/modules/gammaBidAdapter_spec.js +++ /dev/null @@ -1,105 +0,0 @@ -import * as utils from 'src/utils'; -import { expect } from 'chai'; -import { spec } from 'modules/gammaBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; - -describe('gammaBidAdapter', function() { - const adapter = newBidder(spec); - - let bid = { - 'bidder': 'gamma', - 'params': { - siteId: '1465446377', - zoneId: '1515999290' - }, - 'adUnitCode': 'adunit-code', - 'sizes': [ - [300, 250] - ], - 'bidId': '23beaa6af6cdde', - 'bidderRequestId': '19c0c1efdf37e7', - 'auctionId': '61466567-d482-4a16-96f0-fe5f25ffbdf1', - }; - let bidArray = [bid]; - - describe('isBidRequestValid', function () { - it('should return true when required params found', function () { - expect(spec.isBidRequestValid(bid)).to.equal(true); - }); - - it('should return false when require params are not passed', function () { - let bid = Object.assign({}, bid); - bid.params = {}; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - - it('should return false when params not passed correctly', function () { - bid.params.siteId = ''; - bid.params.zoneId = ''; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - }); - - describe('buildRequests', function () { - it('should attempt to send bid requests to the endpoint via GET', function () { - const requests = spec.buildRequests(bidArray); - requests.forEach(function(requestItem) { - expect(requestItem.method).to.equal('GET'); - expect(requestItem.url).to.match(new RegExp(`hb.gammaplatform.com`)); - }); - }); - }); - - describe('interpretResponse', function () { - let serverResponse; - - beforeEach(function () { - serverResponse = { - body: { - 'id': '23beaa6af6cdde', - 'bid': '5611802021800040585', - 'type': 'banner', - 'cur': 'USD', - 'seatbid': [{ - 'seat': '5611802021800040585', - 'bid': [{ - 'id': '1515999070', - 'impid': '1', - 'price': 0.45, - 'adm': '', - 'adid': '1515999070', - 'dealid': 'gax-paj2qarjf2g', - 'h': 250, - 'w': 300 - }] - }] - } - }; - }) - - it('should get the correct bid response', function () { - let expectedResponse = [{ - 'requestId': '23beaa6af6cdde', - 'cpm': 0.45, - 'width': 300, - 'height': 250, - 'creativeId': '1515999070', - 'dealId': 'gax-paj2qarjf2g', - 'currency': 'USD', - 'netRevenue': true, - 'ttl': 300, - 'ad': '' - }]; - let result = spec.interpretResponse(serverResponse); - expect(Object.keys(result)).to.deep.equal(Object.keys(expectedResponse)); - }); - - it('handles empty bid response', function () { - let response = { - body: {} - }; - let result = spec.interpretResponse(response); - expect(result.length).to.equal(0); - }); - }); -}); diff --git a/test/spec/modules/gamoshiBidAdapter_spec.js b/test/spec/modules/gamoshiBidAdapter_spec.js deleted file mode 100644 index 2d63d47a73e2..000000000000 --- a/test/spec/modules/gamoshiBidAdapter_spec.js +++ /dev/null @@ -1,543 +0,0 @@ -import {expect} from 'chai'; -import {spec} from 'modules/gamoshiBidAdapter'; -import {helper} from 'modules/gamoshiBidAdapter'; -import * as utils from 'src/utils'; -import {newBidder} from '../../../src/adapters/bidderFactory'; -import {deepClone} from 'src/utils'; - -const supplyPartnerId = '123'; -const adapter = newBidder(spec); -describe('GamoshiAdapter', function () { - describe('Get top Frame', function () { - it('check if you are in the top frame', function () { - expect(helper.getTopFrame()).to.equal(0); - }); - it('verify domain parsing', function () { - expect(helper.getTopWindowDomain('http://www.domain.com')).to.equal('www.domain.com'); - }); - }); - describe('Is String start with search ', function () { - it('check if a string started with', function () { - expect(helper.startsWith('gamoshi.com', 'gamo')).to.equal(true); - }); - }); - - describe('inherited functions', function () { - it('exists and is a function', function () { - expect(adapter.callBids).to.exist.and.to.be.a('function'); - }); - }); - - describe('isBidRequestValid', function () { - it('should validate supply-partner ID', function () { - expect(spec.isBidRequestValid({params: {}})).to.equal(false); - expect(spec.isBidRequestValid({params: {supplyPartnerId: 123}})).to.equal(false); - expect(spec.isBidRequestValid({params: {supplyPartnerId: '123'}})).to.equal(true); - }); - - it('should validate RTB endpoint', function () { - expect(spec.isBidRequestValid({params: {supplyPartnerId: '123'}})).to.equal(true); // RTB endpoint has a default - expect(spec.isBidRequestValid({params: {supplyPartnerId: '123', rtbEndpoint: 123}})).to.equal(false); - expect(spec.isBidRequestValid({ - params: { - supplyPartnerId: '123', - rtbEndpoint: 'https://some.url.com' - } - })).to.equal(true); - }); - - it('should validate bid floor', function () { - expect(spec.isBidRequestValid({params: {supplyPartnerId: '123'}})).to.equal(true); // bidfloor has a default - expect(spec.isBidRequestValid({params: {supplyPartnerId: '123', bidfloor: '123'}})).to.equal(false); - expect(spec.isBidRequestValid({params: {supplyPartnerId: '123', bidfloor: 0.1}})).to.equal(true); - }); - - it('should validate adpos', function () { - expect(spec.isBidRequestValid({params: {supplyPartnerId: '123'}})).to.equal(true); // adpos has a default - expect(spec.isBidRequestValid({params: {supplyPartnerId: '123', adpos: '123'}})).to.equal(false); - expect(spec.isBidRequestValid({params: {supplyPartnerId: '123', adpos: 0.1}})).to.equal(true); - }); - - it('should validate instl', function () { - expect(spec.isBidRequestValid({params: {supplyPartnerId: '123'}})).to.equal(true); // adpos has a default - expect(spec.isBidRequestValid({params: {supplyPartnerId: '123', instl: '123'}})).to.equal(false); - expect(spec.isBidRequestValid({params: {supplyPartnerId: '123', instl: -1}})).to.equal(false); - expect(spec.isBidRequestValid({params: {supplyPartnerId: '123', instl: 0}})).to.equal(true); - expect(spec.isBidRequestValid({params: {supplyPartnerId: '123', instl: 1}})).to.equal(true); - expect(spec.isBidRequestValid({params: {supplyPartnerId: '123', instl: 2}})).to.equal(false); - }); - }); - - describe('buildRequests', function () { - const bidRequest = { - 'adUnitCode': 'adunit-code', - 'auctionId': '1d1a030790a475', - 'mediaTypes': { - banner: {} - }, - 'params': { - 'supplyPartnerId': supplyPartnerId - }, - 'sizes': [[300, 250], [300, 600]], - 'transactionId': 'a123456789', - refererInfo: {referer: 'http://examplereferer.com'}, - gdprConsent: { - consentString: 'some string', - gdprApplies: true - } - }; - it('returns an array', function () { - let response; - response = spec.buildRequests([]); - expect(Array.isArray(response)).to.equal(true); - expect(response.length).to.equal(0); - response = spec.buildRequests([bidRequest], bidRequest); - expect(Array.isArray(response)).to.equal(true); - expect(response.length).to.equal(1); - const adUnit1 = Object.assign({}, utils.deepClone(bidRequest), {auctionId: '1', adUnitCode: 'a'}); - const adUnit2 = Object.assign({}, utils.deepClone(bidRequest), {auctionId: '1', adUnitCode: 'b'}); - response = spec.buildRequests([adUnit1, adUnit2], bidRequest); - expect(Array.isArray(response)).to.equal(true); - expect(response.length).to.equal(2); - }); - - it('targets correct endpoint', function () { - let response; - response = spec.buildRequests([bidRequest], bidRequest)[0]; - expect(response.method).to.equal('POST'); - expect(response.url).to.match(new RegExp(`^https://rtb\\.gamoshi\\.io/r/${supplyPartnerId}/bidr\\?rformat=open_rtb&reqformat=rtb_json&bidder=prebid$`, 'g')); - expect(response.data.id).to.equal(bidRequest.auctionId); - const bidRequestWithEndpoint = utils.deepClone(bidRequest); - bidRequestWithEndpoint.params.rtbEndpoint = 'https://rtb2.gamoshi.io/a12'; - response = spec.buildRequests([bidRequestWithEndpoint], bidRequest)[0]; - expect(response.url).to.match(new RegExp(`^https://rtb2\\.gamoshi\\.io/a12/r/${supplyPartnerId}/bidr\\?rformat=open_rtb&reqformat=rtb_json&bidder=prebid$`, 'g')); - }); - - it('builds request correctly', function () { - let stub = sinon.stub(utils, 'getTopWindowUrl').returns('http://www.test.com/page.html'); - let bidRequest2 = deepClone(bidRequest); - bidRequest2.refererInfo.referer = 'http://www.test.com/page.html'; - let response = spec.buildRequests([bidRequest], bidRequest2)[0]; - expect(response.data.site.domain).to.equal('www.test.com'); - expect(response.data.site.page).to.equal('http://www.test.com/page.html'); - expect(response.data.site.ref).to.equal('http://www.test.com/page.html'); - expect(response.data.imp.length).to.equal(1); - expect(response.data.imp[0].id).to.equal(bidRequest.transactionId); - expect(response.data.imp[0].instl).to.equal(0); - expect(response.data.imp[0].tagid).to.equal(bidRequest.adUnitCode); - expect(response.data.imp[0].bidfloor).to.equal(0); - expect(response.data.imp[0].bidfloorcur).to.equal('USD'); - const bidRequestWithInstlEquals1 = utils.deepClone(bidRequest); - bidRequestWithInstlEquals1.params.instl = 1; - response = spec.buildRequests([bidRequestWithInstlEquals1], bidRequest2)[0]; - expect(response.data.imp[0].instl).to.equal(bidRequestWithInstlEquals1.params.instl); - const bidRequestWithInstlEquals0 = utils.deepClone(bidRequest); - bidRequestWithInstlEquals0.params.instl = 1; - response = spec.buildRequests([bidRequestWithInstlEquals0], bidRequest2)[0]; - expect(response.data.imp[0].instl).to.equal(bidRequestWithInstlEquals0.params.instl); - const bidRequestWithBidfloorEquals1 = utils.deepClone(bidRequest); - bidRequestWithBidfloorEquals1.params.bidfloor = 1; - response = spec.buildRequests([bidRequestWithBidfloorEquals1], bidRequest2)[0]; - expect(response.data.imp[0].bidfloor).to.equal(bidRequestWithBidfloorEquals1.params.bidfloor); - stub.restore(); - }); - - it('builds request banner object correctly', function () { - let response; - const bidRequestWithBanner = utils.deepClone(bidRequest); - bidRequestWithBanner.mediaTypes = { - banner: { - sizes: [[300, 250], [120, 600]] - } - }; - response = spec.buildRequests([bidRequestWithBanner], bidRequest)[0]; - expect(response.data.imp[0].banner.w).to.equal(bidRequestWithBanner.mediaTypes.banner.sizes[0][0]); - expect(response.data.imp[0].banner.h).to.equal(bidRequestWithBanner.mediaTypes.banner.sizes[0][1]); - expect(response.data.imp[0].banner.pos).to.equal(0); - expect(response.data.imp[0].banner.topframe).to.equal(0); - const bidRequestWithPosEquals1 = utils.deepClone(bidRequestWithBanner); - bidRequestWithPosEquals1.params.pos = 1; - response = spec.buildRequests([bidRequestWithPosEquals1], bidRequest)[0]; - expect(response.data.imp[0].banner.pos).to.equal(bidRequestWithPosEquals1.params.pos); - }); - - it('builds request video object correctly', function () { - let response; - const bidRequestWithVideo = utils.deepClone(bidRequest); - bidRequestWithVideo.mediaTypes = { - video: { - playerSize: [302, 252] - } - }; - response = spec.buildRequests([bidRequestWithVideo], bidRequest)[0]; - expect(response.data.imp[0].video.w).to.equal(bidRequestWithVideo.mediaTypes.video.playerSize[0][0]); - expect(response.data.imp[0].video.h).to.equal(bidRequestWithVideo.mediaTypes.video.playerSize[0][1]); - expect(response.data.imp[0].video.pos).to.equal(0); - const bidRequestWithPosEquals1 = utils.deepClone(bidRequestWithVideo); - bidRequestWithPosEquals1.params.pos = 1; - response = spec.buildRequests([bidRequestWithPosEquals1], bidRequest)[0]; - expect(response.data.imp[0].video.pos).to.equal(bidRequestWithPosEquals1.params.pos); - }); - - it('builds request video object correctly with context', function () { - let response; - const bidRequestWithVideo = utils.deepClone(bidRequest); - bidRequestWithVideo.mediaTypes = { - video: { - context: 'instream' - } - }; - response = spec.buildRequests([bidRequestWithVideo], bidRequest)[0]; - expect(response.data.imp[0].video.ext.context).to.equal('instream'); - bidRequestWithVideo.mediaTypes.video.context = 'outstream'; - - const bidRequestWithPosEquals1 = utils.deepClone(bidRequestWithVideo); - bidRequestWithPosEquals1.mediaTypes.video.context = 'outstream'; - response = spec.buildRequests([bidRequestWithPosEquals1], bidRequest)[0]; - expect(response.data.imp[0].video.ext.context).to.equal('outstream'); - - const bidRequestWithPosEquals2 = utils.deepClone(bidRequestWithVideo); - bidRequestWithPosEquals2.mediaTypes.video.context = null; - response = spec.buildRequests([bidRequestWithPosEquals2], bidRequest)[0]; - expect(response.data.imp[0].video.ext.context).to.equal(null); - }); - - it('builds request video object correctly with multi-dimensions size array', function () { - let response; - const bidRequestWithVideo = utils.deepClone(bidRequest); - bidRequestWithVideo.mediaTypes.video = { - playerSize: [[304, 254], [305, 255]], - context: 'instream' - }; - - response = spec.buildRequests([bidRequestWithVideo], bidRequest)[0]; - expect(response.data.imp[1].video.ext.context).to.equal('instream'); - bidRequestWithVideo.mediaTypes.video.context = 'outstream'; - - const bidRequestWithPosEquals1 = utils.deepClone(bidRequestWithVideo); - bidRequestWithPosEquals1.mediaTypes.video.context = 'outstream'; - response = spec.buildRequests([bidRequestWithPosEquals1], bidRequest)[0]; - expect(response.data.imp[1].video.ext.context).to.equal('outstream'); - - const bidRequestWithPosEquals2 = utils.deepClone(bidRequestWithVideo); - bidRequestWithPosEquals2.mediaTypes.video.context = null; - response = spec.buildRequests([bidRequestWithPosEquals2], bidRequest)[0]; - expect(response.data.imp[1].video.ext.context).to.equal(null); - }); - - it('builds request with gdpr consent', function () { - let response = spec.buildRequests([bidRequest], bidRequest)[0]; - expect(response.data.ext.gdpr_consent).to.exist; - expect(response.data.ext).to.have.property('gdpr_consent'); - expect(response.data.ext.gdpr_consent.consent_string).to.equal('some string'); - expect(response.data.ext.gdpr_consent.consent_required).to.equal(true); - - expect(response.data.regs.ext.gdpr).to.exist; - expect(response.data.user.ext.consent).to.equal('some string'); - }); - - it('build request with ID5 Id', function () { - const bidRequestClone = utils.deepClone(bidRequest); - bidRequestClone.userId = {}; - bidRequestClone.userId.id5id = 'id5-user-id'; - let request = spec.buildRequests([bidRequestClone], bidRequestClone)[0]; - expect(request.data.user.ext.eids).to.deep.equal([{ - 'source': 'id5-sync.com', - 'uids': [{ - 'id': 'id5-user-id', - 'ext': { - 'rtiPartner': 'ID5ID' - } - }] - }]); - }); - - it('build request with unified Id', function () { - const bidRequestClone = utils.deepClone(bidRequest); - bidRequestClone.userId = {}; - bidRequestClone.userId.tdid = 'tdid-user-id'; - let request = spec.buildRequests([bidRequestClone], bidRequestClone)[0]; - expect(request.data.user.ext.eids).to.deep.equal([{ - 'source': 'adserver.org', - 'uids': [{ - 'id': 'tdid-user-id', - 'ext': { - 'rtiPartner': 'TDID' - } - }] - }]); - }); - }); - - describe('interpretResponse', () => { - const bannerBidRequest = { - 'adUnitCode': 'adunit-code', - 'auctionId': '1d1a030790a475', - 'mediaTypes': { - banner: {} - }, - 'params': { - 'supplyPartnerId': supplyPartnerId - }, - 'sizes': [[300, 250], [300, 600]], - 'transactionId': 'a123456789', - 'bidId': '111', - refererInfo: {referer: 'http://examplereferer.com'} - }; - - const videoBidRequest = { - 'adUnitCode': 'adunit-code', - 'auctionId': '1d1a030790a475', - 'mediaTypes': { - video: {} - }, - 'params': { - 'supplyPartnerId': supplyPartnerId - }, - 'sizes': [[300, 250], [300, 600]], - 'transactionId': 'a123456789', - 'bidId': '111', - refererInfo: {referer: 'http://examplereferer.com'} - }; - - const rtbResponse = { - 'id': 'imp_5b05b9fde4b09084267a556f', - 'bidid': 'imp_5b05b9fde4b09084267a556f', - 'cur': 'USD', - 'ext': { - 'utrk': [ - {'type': 'iframe', 'url': '//rtb.gamoshi.io/user/sync/1'}, - {'type': 'image', 'url': '//rtb.gamoshi.io/user/sync/2'} - ] - }, - 'seatbid': [ - { - 'seat': 'seat1', - 'group': 0, - 'bid': [ - { - 'id': '0', - 'impid': '1', - 'price': 2.016, - 'adid': '579ef31bfa788b9d2000d562', - 'nurl': 'https://rtb.gamoshi.io/pix/monitoring/win_notice/imp_5b05b9fde4b09084267a556f/im.gif?r=imp_5b05b9fde4b09084267a556f&i=1&a=579ef31bfa788b9d2000d562&b=0&p=${AUCTION_PRICE}', - 'adm': '', - 'adomain': ['aaa.com'], - 'cid': '579ef268fa788b9d2000d55c', - 'crid': '579ef31bfa788b9d2000d562', - 'attr': [], - 'h': 600, - 'w': 120, - 'ext': { - 'vast_url': 'http://my.vast.com', - 'utrk': [ - {'type': 'iframe', 'url': '//p.partner1.io/user/sync/1'} - ] - } - } - ] - }, - { - 'seat': 'seat2', - 'group': 0, - 'bid': [ - { - 'id': '1', - 'impid': '1', - 'price': 3, - 'adid': '542jlhdfd2112jnjf3x', - 'nurl': 'https://rtb.gamoshi.io/pix/monitoring/win_notice/imp_5b05b9fde4b09084267a556f/im.gif?r=imp_5b05b9fde4b09084267a556f&i=1&a=579ef31bfa788b9d2000d562&b=0&p=${AUCTION_PRICE}', - 'adm': ' ', - 'adomain': ['bbb.com'], - 'cid': 'fgdlwjh2498ydjhg1', - 'crid': 'kjh34297ydh2133d', - 'attr': [], - 'h': 250, - 'w': 300, - 'ext': { - 'utrk': [ - {'type': 'image', 'url': '//p.partner2.io/user/sync/1'} - ] - } - } - ] - } - ] - }; - - const TTL = 360; - - it('returns an empty array on missing response', function () { - let response; - - response = spec.interpretResponse(undefined, {bidRequest: bannerBidRequest}); - expect(Array.isArray(response)).to.equal(true); - expect(response.length).to.equal(0); - - response = spec.interpretResponse({}, {bidRequest: bannerBidRequest}); - expect(Array.isArray(response)).to.equal(true); - expect(response.length).to.equal(0); - }); - - it('aggregates banner bids from all seat bids', function () { - const response = spec.interpretResponse({body: rtbResponse}, {bidRequest: bannerBidRequest}); - expect(Array.isArray(response)).to.equal(true); - expect(response.length).to.equal(1); - const ad0 = response[0]; - expect(ad0.requestId).to.equal(bannerBidRequest.bidId); - expect(ad0.cpm).to.equal(rtbResponse.seatbid[1].bid[0].price); - expect(ad0.width).to.equal(rtbResponse.seatbid[1].bid[0].w); - expect(ad0.height).to.equal(rtbResponse.seatbid[1].bid[0].h); - expect(ad0.ttl).to.equal(TTL); - expect(ad0.creativeId).to.equal(rtbResponse.seatbid[1].bid[0].crid); - expect(ad0.netRevenue).to.equal(true); - expect(ad0.currency).to.equal(rtbResponse.seatbid[1].bid[0].cur || rtbResponse.cur || 'USD'); - expect(ad0.ad).to.equal(rtbResponse.seatbid[1].bid[0].adm); - expect(ad0.vastXml).to.be.an('undefined'); - expect(ad0.vastUrl).to.be.an('undefined'); - }); - - it('aggregates video bids from all seat bids', function () { - const response = spec.interpretResponse({body: rtbResponse}, {bidRequest: videoBidRequest}); - expect(Array.isArray(response)).to.equal(true); - expect(response.length).to.equal(1); - const ad0 = response[0]; - expect(ad0.requestId).to.equal(videoBidRequest.bidId); - expect(ad0.cpm).to.equal(rtbResponse.seatbid[0].bid[0].price); - expect(ad0.width).to.equal(rtbResponse.seatbid[0].bid[0].w); - expect(ad0.height).to.equal(rtbResponse.seatbid[0].bid[0].h); - expect(ad0.ttl).to.equal(TTL); - expect(ad0.creativeId).to.equal(rtbResponse.seatbid[0].bid[0].crid); - expect(ad0.netRevenue).to.equal(true); - expect(ad0.currency).to.equal(rtbResponse.seatbid[0].bid[0].cur || rtbResponse.cur || 'USD'); - expect(ad0.ad).to.be.an('undefined'); - expect(ad0.vastXml).to.equal(rtbResponse.seatbid[0].bid[0].adm); - expect(ad0.vastUrl).to.equal(rtbResponse.seatbid[0].bid[0].ext.vast_url); - }); - - it('aggregates user-sync pixels', function () { - const response = spec.getUserSyncs({}, [{body: rtbResponse}]); - expect(Array.isArray(response)).to.equal(true); - expect(response.length).to.equal(4); - expect(response[0].type).to.equal(rtbResponse.ext.utrk[0].type); - expect(response[0].url).to.equal(rtbResponse.ext.utrk[0].url + '?gc=missing'); - expect(response[1].type).to.equal(rtbResponse.ext.utrk[1].type); - expect(response[1].url).to.equal(rtbResponse.ext.utrk[1].url + '?gc=missing'); - expect(response[2].type).to.equal(rtbResponse.seatbid[0].bid[0].ext.utrk[0].type); - expect(response[2].url).to.equal(rtbResponse.seatbid[0].bid[0].ext.utrk[0].url + '?gc=missing'); - expect(response[3].type).to.equal(rtbResponse.seatbid[1].bid[0].ext.utrk[0].type); - expect(response[3].url).to.equal(rtbResponse.seatbid[1].bid[0].ext.utrk[0].url + '?gc=missing'); - }); - - it('supports configuring outstream renderers', function () { - const videoResponse = { - 'id': '64f32497-b2f7-48ec-9205-35fc39894d44', - 'bidid': 'imp_5c24924de4b0d106447af333', - 'cur': 'USD', - 'seatbid': [ - { - 'seat': '3668', - 'group': 0, - 'bid': [ - { - 'id': 'gb_1', - 'impid': 'afbb5852-7cea-4a81-aa9a-a41aab505c23', - 'price': 5.0, - 'adid': '1274', - 'nurl': 'https://rtb.gamoshi.io/pix/1275/win_notice/imp_5c24924de4b0d106447af333/im.gif?r=imp_5c24924de4b0d106447af333&i=afbb5852-7cea-4a81-aa9a-a41aab505c23&a=1274&b=gb_1&p=${AUCTION_PRICE}', - 'adomain': [], - 'adm': '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n', - 'cid': '3668', - 'crid': '1274', - 'cat': [], - 'attr': [], - 'h': 250, - 'w': 300, - 'ext': { - 'vast_url': 'https://rtb.gamoshi.io/pix/1275/vast_o/imp_5c24924de4b0d106447af333/im.xml?r=imp_5c24924de4b0d106447af333&i=afbb5852-7cea-4a81-aa9a-a41aab505c23&a=1274&b=gb_1&w=300&h=250&vatu=aHR0cHM6Ly9zdGF0aWMuZ2FtYmlkLmlvL2RlbW8vdmFzdC54bWw&vwarv', - 'imptrackers': [ - 'https://rtb.gamoshi.io/pix/1275/imp/imp_5c24924de4b0d106447af333/im.gif?r=imp_5c24924de4b0d106447af333&i=afbb5852-7cea-4a81-aa9a-a41aab505c23&a=1274&b=gb_1'] - } - } - ] - } - ], - 'ext': { - 'utrk': [{ - 'type': 'image', - 'url': 'https://rtb.gamoshi.io/pix/1275/scm?cb=1545900621675' - }] - } - }; - const videoRequest = deepClone(videoBidRequest); - videoRequest.mediaTypes.video.context = 'outstream'; - const result = spec.interpretResponse({body: videoResponse}, {bidRequest: videoRequest}); - expect(result[0].renderer).to.not.equal(undefined); - }); - - it('validates in/existing of gdpr consent', function () { - let videoResponse = { - 'id': '64f32497-b2f7-48ec-9205-35fc39894d44', - 'bidid': 'imp_5c24924de4b0d106447af333', - 'cur': 'USD', - 'seatbid': [ - { - 'seat': '3668', - 'group': 0, - 'bid': [ - { - 'id': 'gb_1', - 'impid': 'afbb5852-7cea-4a81-aa9a-a41aab505c23', - 'price': 5.0, - 'adid': '1274', - 'nurl': 'https://rtb.gamoshi.io/pix/1275/win_notice/imp_5c24924de4b0d106447af333/im.gif?r=imp_5c24924de4b0d106447af333&i=afbb5852-7cea-4a81-aa9a-a41aab505c23&a=1274&b=gb_1&p=${AUCTION_PRICE}', - 'adomain': [], - 'adm': '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n', - 'cid': '3668', - 'crid': '1274', - 'cat': [], - 'attr': [], - 'h': 250, - 'w': 300, - 'ext': { - 'vast_url': 'https://rtb.gamoshi.io/pix/1275/vast_o/imp_5c24924de4b0d106447af333/im.xml?r=imp_5c24924de4b0d106447af333&i=afbb5852-7cea-4a81-aa9a-a41aab505c23&a=1274&b=gb_1&w=300&h=250&vatu=aHR0cHM6Ly9zdGF0aWMuZ2FtYmlkLmlvL2RlbW8vdmFzdC54bWw&vwarv', - 'imptrackers': [ - 'https://rtb.gamoshi.io/pix/1275/imp/imp_5c24924de4b0d106447af333/im.gif?r=imp_5c24924de4b0d106447af333&i=afbb5852-7cea-4a81-aa9a-a41aab505c23&a=1274&b=gb_1'] - } - } - ] - } - ], - 'ext': { - 'utrk': [{ - 'type': 'image', - 'url': 'https://rtb.gamoshi.io/pix/1275/scm?cb=1545900621675' - }] - } - }; - let gdprConsent = { - gdprApplies: true, - consentString: 'consent string' - }; - let result = spec.getUserSyncs({}, [{body: videoResponse}], gdprConsent); - expect(result).to.be.an('array'); - expect(result.length).to.equal(1); - expect(result[0].type).to.equal('image'); - expect(result[0].url).to.equal('https://rtb.gamoshi.io/pix/1275/scm?cb=1545900621675&gc=consent%20string'); - - gdprConsent.gdprApplies = false; - result = spec.getUserSyncs({}, [{body: videoResponse}], gdprConsent); - expect(result).to.be.an('array'); - expect(result.length).to.equal(1); - expect(result[0].type).to.equal('image'); - expect(result[0].url).to.equal('https://rtb.gamoshi.io/pix/1275/scm?cb=1545900621675&gc=missing'); - - videoResponse.ext.utrk[0].url = 'https://rtb.gamoshi.io/pix/1275/scm'; - result = spec.getUserSyncs({}, [{body: videoResponse}], gdprConsent); - expect(result).to.be.an('array'); - expect(result.length).to.equal(1); - expect(result[0].type).to.equal('image'); - expect(result[0].url).to.equal('https://rtb.gamoshi.io/pix/1275/scm?gc=missing'); - }); - }); -}); diff --git a/test/spec/modules/getintentBidAdapter_spec.js b/test/spec/modules/getintentBidAdapter_spec.js index ebbda7e108e6..e743d85972cd 100644 --- a/test/spec/modules/getintentBidAdapter_spec.js +++ b/test/spec/modules/getintentBidAdapter_spec.js @@ -37,7 +37,7 @@ describe('GetIntent Adapter Tests:', function () { it('Verify build request', function () { const serverRequests = spec.buildRequests(bidRequests); let serverRequest = serverRequests[0]; - expect(serverRequest.url).to.equal('//px.adhigh.net/rtb/direct_banner'); + expect(serverRequest.url).to.equal('https://px.adhigh.net/rtb/direct_banner'); expect(serverRequest.method).to.equal('GET'); expect(serverRequest.data.bid_id).to.equal('bid12345'); expect(serverRequest.data.pid).to.equal('p1000'); @@ -51,7 +51,7 @@ describe('GetIntent Adapter Tests:', function () { it('Verify build video request', function () { const serverRequests = spec.buildRequests([videoBidRequest]); let serverRequest = serverRequests[0]; - expect(serverRequest.url).to.equal('//px.adhigh.net/rtb/direct_vast'); + expect(serverRequest.url).to.equal('https://px.adhigh.net/rtb/direct_vast'); expect(serverRequest.method).to.equal('GET'); expect(serverRequest.data.bid_id).to.equal('bid789'); expect(serverRequest.data.pid).to.equal('p1001'); @@ -98,7 +98,7 @@ describe('GetIntent Adapter Tests:', function () { currency: 'USD', size: '300x250', creative_id: '2000', - vast_url: '//vast.xml/url' + vast_url: 'https://vast.xml/url' }, headers: { } @@ -113,7 +113,7 @@ describe('GetIntent Adapter Tests:', function () { expect(bid.height).to.equal(250); expect(bid.requestId).to.equal('bid789'); expect(bid.mediaType).to.equal('video'); - expect(bid.vastUrl).to.equal('//vast.xml/url'); + expect(bid.vastUrl).to.equal('https://vast.xml/url'); }); it('Verify bidder code', function () { diff --git a/test/spec/modules/giantsBidAdapter_spec.js b/test/spec/modules/giantsBidAdapter_spec.js deleted file mode 100644 index bab2415745d4..000000000000 --- a/test/spec/modules/giantsBidAdapter_spec.js +++ /dev/null @@ -1,301 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/giantsBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; -import { deepClone } from 'src/utils'; -import * as utils from 'src/utils'; - -const ENDPOINT = '//d.admp.io/hb/multi?url='; - -describe('GiantsAdapter', function () { - const adapter = newBidder(spec); - - describe('inherited functions', function () { - it('exists and is a function', function () { - expect(adapter.callBids).to.exist.and.to.be.a('function'); - }); - }); - - describe('isBidRequestValid', function () { - let bid = { - 'bidder': 'giants', - 'params': { - 'zoneId': '584072408' - }, - 'adUnitCode': 'adunit-code', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - }; - - it('should return true when required params found', function () { - expect(spec.isBidRequestValid(bid)).to.equal(true); - }); - - it('should return false when required params are not passed', function () { - let bid = Object.assign({}, bid); - delete bid.params; - bid.params = { - 'zoneId': 0 - }; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - }); - - describe('buildRequests', function () { - let bidRequests = [ - { - 'bidder': 'giants', - 'params': { - 'zoneId': '584072408' - }, - 'adUnitCode': 'adunit-code', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - } - ]; - - it('should parse out private sizes', function () { - let bidRequest = Object.assign({}, - bidRequests[0], - { - params: { - zoneId: '584072408', - privateSizes: [300, 250] - } - } - ); - - const request = spec.buildRequests([bidRequest]); - const payload = JSON.parse(request.data); - - expect(payload.tags[0].private_sizes).to.exist; - expect(payload.tags[0].private_sizes).to.deep.equal([{width: 300, height: 250}]); - }); - - it('should add source and verison to the tag', function () { - const request = spec.buildRequests(bidRequests); - const payload = JSON.parse(request.data); - expect(payload.sdk).to.exist; - expect(payload.sdk).to.deep.equal({ - source: 'pbjs', - version: '$prebid.version$' - }); - }); - - it('should populate the ad_types array on all requests', function () { - ['banner', 'video', 'native'].forEach(type => { - const bidRequest = Object.assign({}, bidRequests[0]); - bidRequest.mediaTypes = {}; - bidRequest.mediaTypes[type] = {}; - - const request = spec.buildRequests([bidRequest]); - const payload = JSON.parse(request.data); - - expect(payload.tags[0].ad_types).to.deep.equal([type]); - }); - }); - - it('should populate the ad_types array on outstream requests', function () { - const bidRequest = Object.assign({}, bidRequests[0]); - bidRequest.mediaTypes = {}; - bidRequest.mediaTypes.video = {context: 'outstream'}; - - const request = spec.buildRequests([bidRequest]); - const payload = JSON.parse(request.data); - - expect(payload.tags[0].ad_types).to.deep.equal(['video']); - }); - - it('sends bid request to ENDPOINT via POST', function () { - const request = spec.buildRequests(bidRequests); - expect(request.url).to.equal(ENDPOINT + utils.getTopWindowUrl()); - expect(request.method).to.equal('POST'); - }); - - it('should attach valid video params to the tag', function () { - let bidRequest = Object.assign({}, - bidRequests[0], - { - params: { - zoneId: '584072408', - video: { - id: 123, - minduration: 100, - foobar: 'invalid' - } - } - } - ); - - const request = spec.buildRequests([bidRequest]); - const payload = JSON.parse(request.data); - expect(payload.tags[0].video).to.deep.equal({ - id: 123, - minduration: 100 - }); - }); - - it('sets minimum native asset params when not provided on adunit', function () { - let bidRequest = Object.assign({}, - bidRequests[0], - { - mediaType: 'native', - nativeParams: { - image: {required: true}, - } - } - ); - - const request = spec.buildRequests([bidRequest]); - const payload = JSON.parse(request.data); - - expect(payload.tags[0].native.layouts[0]).to.deep.equal({ - main_image: {required: true, sizes: [{}]}, - }); - }); - - it('does not overwrite native ad unit params with mimimum params', function () { - let bidRequest = Object.assign({}, - bidRequests[0], - { - mediaType: 'native', - nativeParams: { - image: { - aspect_ratios: [{ - min_width: 100, - ratio_width: 2, - ratio_height: 3, - }] - } - } - } - ); - - const request = spec.buildRequests([bidRequest]); - const payload = JSON.parse(request.data); - - expect(payload.tags[0].native.layouts[0]).to.deep.equal({ - main_image: { - required: true, - aspect_ratios: [{ - min_width: 100, - ratio_width: 2, - ratio_height: 3, - }] - }, - }); - }); - - it('should convert keyword params to proper form and attaches to request', function () { - let bidRequest = Object.assign({}, - bidRequests[0], - { - params: { - zoneId: '584072408', - keywords: { - single: 'val', - singleArr: ['val'], - singleArrNum: [5], - multiValMixed: ['value1', 2, 'value3'], - singleValNum: 123, - badValue: {'foo': 'bar'} // should be dropped - } - } - } - ); - - const request = spec.buildRequests([bidRequest]); - const payload = JSON.parse(request.data); - - expect(payload.tags[0].keywords).to.deep.equal([{ - 'key': 'single', - 'value': ['val'] - }, { - 'key': 'singleArr', - 'value': ['val'] - }, { - 'key': 'singleArrNum', - 'value': ['5'] - }, { - 'key': 'multiValMixed', - 'value': ['value1', '2', 'value3'] - }, { - 'key': 'singleValNum', - 'value': ['123'] - }]); - }); - - it('should add payment rules to the request', function () { - let bidRequest = Object.assign({}, - bidRequests[0], - { - params: { - zoneId: '584072408', - usePaymentRule: true - } - } - ); - - const request = spec.buildRequests([bidRequest]); - const payload = JSON.parse(request.data); - - expect(payload.tags[0].use_pmt_rule).to.equal(true); - }); - }) - - describe('interpretResponse', function () { - let response = { - 'version': '3.0.0', - 'tags': [ - { - 'uuid': '3db3773286ee59', - 'creative_id': '584944065', - 'height': 600, - 'width': 300, - 'zoneId': '584072408', - 'adUrl': '//d.admp.io/pbc/v1/cache-banner/f7aca005-8171-4299-90bf-0750a864a61c', - 'cpm': 0.5 - } - ] - }; - - it('should get correct bid response', function () { - let expectedResponse = [ - { - 'requestId': '3db3773286ee59', - 'cpm': 0.5, - 'creativeId': 29681110, - 'currency': 'USD', - 'netRevenue': true, - 'ttl': 300, - 'width': 300, - 'height': 250, - 'ad': '', - 'mediaType': 'banner' - } - ]; - let bidderRequest; - let result = spec.interpretResponse({ body: response }, {bidderRequest}); - expect(Object.keys(result[0])).to.have.members(Object.keys(expectedResponse[0])); - }); - - it('handles nobid responses', function () { - let response = { - 'version': '0.0.1', - 'tags': [{ - 'uuid': '84ab500420319d', - 'tag_id': 5976557, - 'auction_id': '297492697822162468', - 'nobid': true - }] - }; - let bidderRequest; - - let result = spec.interpretResponse({ body: response }, {bidderRequest}); - expect(result.length).to.equal(0); - }); - }); -}); diff --git a/test/spec/modules/gjirafaBidAdapter_spec.js b/test/spec/modules/gjirafaBidAdapter_spec.js deleted file mode 100644 index a18ea1b99c3f..000000000000 --- a/test/spec/modules/gjirafaBidAdapter_spec.js +++ /dev/null @@ -1,172 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/gjirafaBidAdapter'; - -describe('gjirafaAdapterTest', function () { - describe('bidRequestValidity', function () { - it('bidRequest with placementId, minCPM and minCPC params', function () { - expect(spec.isBidRequestValid({ - bidder: 'gjirafa', - params: { - placementId: 'test-div', - minCPM: 0.0001, - minCPC: 0.001 - } - })).to.equal(true); - }); - - it('bidRequest with only placementId param', function () { - expect(spec.isBidRequestValid({ - bidder: 'gjirafa', - params: { - placementId: 'test-div' - } - })).to.equal(true); - }); - - it('bidRequest with minCPM and minCPC params', function () { - expect(spec.isBidRequestValid({ - bidder: 'gjirafa', - params: { - minCPM: 0.0001, - minCPC: 0.001 - } - })).to.equal(true); - }); - - it('bidRequest with no placementId, minCPM or minCPC params', function () { - expect(spec.isBidRequestValid({ - bidder: 'gjirafa', - params: { - } - })).to.equal(false); - }); - }); - - describe('bidRequest', function () { - const bidRequests = [{ - 'bidder': 'gjirafa', - 'params': { - 'placementId': '71-3' - }, - 'adUnitCode': 'hb-leaderboard', - 'transactionId': 'b6b889bb-776c-48fd-bc7b-d11a1cf0425e', - 'sizes': [[728, 90], [980, 200], [980, 150], [970, 90], [970, 250]], - 'bidId': '10bdc36fe0b48c8', - 'bidderRequestId': '70deaff71c281d', - 'auctionId': 'f9012acc-b6b7-4748-9098-97252914f9dc' - }, - { - 'bidder': 'gjirafa', - 'params': { - 'minCPM': 0.0001, - 'minCPC': 0.001, - 'explicit': true - }, - 'adUnitCode': 'hb-inarticle', - 'transactionId': '8757194d-ea7e-4c06-abc0-cfe92bfc5295', - 'sizes': [[300, 250]], - 'bidId': '81a6dcb65e2bd9', - 'bidderRequestId': '70deaff71c281d', - 'auctionId': 'f9012acc-b6b7-4748-9098-97252914f9dc' - }]; - - const bidderRequest = { - 'bids': bidRequests, - 'gdprConsent': { - 'consentString': 'consentString', - 'gdprApplies': true - } - }; - - it('bidRequest HTTP method', function () { - const requests = spec.buildRequests(bidRequests); - requests.forEach(function(requestItem) { - expect(requestItem.method).to.equal('GET'); - }); - }); - - it('bidRequest url', function () { - const endpointUrl = 'https://gjc.gjirafa.com/Home/GetBid'; - const requests = spec.buildRequests(bidRequests); - requests.forEach(function(requestItem) { - expect(requestItem.url).to.match(new RegExp(`${endpointUrl}`)); - }); - }); - - it('bidRequest data', function () { - const requests = spec.buildRequests(bidRequests); - requests.forEach(function(requestItem) { - expect(requestItem.data).to.exist; - }); - }); - - it('bidRequest sizes', function () { - const requests = spec.buildRequests(bidRequests); - expect(requests[0].data.sizes).to.equal('728x90;980x200;980x150;970x90;970x250'); - expect(requests[1].data.sizes).to.equal('300x250'); - }); - - it('should add GDPR data', function () { - const requests = spec.buildRequests(bidRequests, bidderRequest); - expect(requests[0].data.consent_string).to.exist; - expect(requests[0].data.consent_required).to.exist; - expect(requests[1].data.consent_string).to.exist; - expect(requests[1].data.consent_required).to.exist; - }); - }); - - describe('interpretResponse', function () { - const bidRequest = { - 'method': 'GET', - 'url': 'https://gjc.gjirafa.com/Home/GetBid', - 'data': { - 'gjid': 2323007, - 'sizes': '728x90;980x200;980x150;970x90;970x250', - 'configId': '71-3', - 'minCPM': 0, - 'minCPC': 0, - 'allowExplicit': 0, - 'referrer': 'http://localhost:9999/integrationExamples/gpt/hello_world.html?pbjs_debug=true', - 'requestid': '26ee8fe87940da7', - 'bidid': '2962dbedc4768bf' - } - }; - - const bidResponse = { - body: [{ - 'CPM': 1, - 'Width': 728, - 'Height': 90, - 'Referrer': 'https://example.com/', - 'Ad': 'test ad', - 'CreativeId': '123abc', - 'NetRevenue': false, - 'Currency': 'EUR', - 'TTL': 360 - }], - headers: {} - }; - - it('all keys present', function () { - const result = spec.interpretResponse(bidResponse, bidRequest); - - let keys = [ - 'requestId', - 'cpm', - 'width', - 'height', - 'creativeId', - 'currency', - 'netRevenue', - 'ttl', - 'referrer', - 'ad' - ]; - - let resultKeys = Object.keys(result[0]); - resultKeys.forEach(function(key) { - expect(keys.indexOf(key) !== -1).to.equal(true); - }); - }) - }); -}); diff --git a/test/spec/modules/gridBidAdapter_spec.js b/test/spec/modules/gridBidAdapter_spec.js index d972ec25c8a0..e1411da6e5a9 100644 --- a/test/spec/modules/gridBidAdapter_spec.js +++ b/test/spec/modules/gridBidAdapter_spec.js @@ -47,7 +47,7 @@ describe('TheMediaGrid Adapter', function () { }); return res; } - const bidderRequest = {refererInfo: {referer: 'http://example.com'}}; + const bidderRequest = {refererInfo: {referer: 'https://example.com'}}; const referrer = bidderRequest.refererInfo.referer; let bidRequests = [ { diff --git a/test/spec/modules/gxoneBidAdapter_spec.js b/test/spec/modules/gxoneBidAdapter_spec.js deleted file mode 100644 index afeb2c781f59..000000000000 --- a/test/spec/modules/gxoneBidAdapter_spec.js +++ /dev/null @@ -1,293 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/gxoneBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; - -describe('GXOne Adapter', function () { - const adapter = newBidder(spec); - - describe('inherited functions', function () { - it('exists and is a function', function () { - expect(adapter.callBids).to.exist.and.to.be.a('function'); - }); - }); - - describe('isBidRequestValid', function () { - let bid = { - 'bidder': 'gxone', - 'params': { - 'uid': '4' - }, - 'adUnitCode': 'adunit-code', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - }; - - it('should return true when required params found', function () { - expect(spec.isBidRequestValid(bid)).to.equal(true); - }); - - it('should return false when required params are not passed', function () { - let bid = Object.assign({}, bid); - delete bid.params; - bid.params = { - 'uid': 0 - }; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - }); - - describe('buildRequests', function () { - function parseRequest(url) { - const res = {}; - url.split('&').forEach((it) => { - const couple = it.split('='); - res[couple[0]] = decodeURIComponent(couple[1]); - }); - return res; - } - let bidRequests = [ - { - 'bidder': 'gxone', - 'params': { - 'uid': '5' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - }, - { - 'bidder': 'gxone', - 'params': { - 'uid': '5' - }, - 'adUnitCode': 'adunit-code-2', - 'sizes': [[728, 90]], - 'bidId': '3150ccb55da321', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - }, - { - 'bidder': 'gxone', - 'params': { - 'uid': '6' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '42dbe3a7168a6a', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - } - ]; - - it('should attach valid params to the tag', function () { - const request = spec.buildRequests([bidRequests[0]]); - expect(request.data).to.be.an('string'); - const payload = parseRequest(request.data); - expect(payload).to.have.property('u').that.is.a('string'); - expect(payload).to.have.property('pt', 'net'); - expect(payload).to.have.property('auids', '5'); - }); - - it('auids must not be duplicated', function () { - const request = spec.buildRequests(bidRequests); - expect(request.data).to.be.an('string'); - const payload = parseRequest(request.data); - expect(payload).to.have.property('u').that.is.a('string'); - expect(payload).to.have.property('pt', 'net'); - expect(payload).to.have.property('auids', '5,6'); - }); - - it('pt parameter must be "gross" if params.priceType === "gross"', function () { - bidRequests[1].params.priceType = 'gross'; - const request = spec.buildRequests(bidRequests); - expect(request.data).to.be.an('string'); - const payload = parseRequest(request.data); - expect(payload).to.have.property('u').that.is.a('string'); - expect(payload).to.have.property('pt', 'gross'); - expect(payload).to.have.property('auids', '5,6'); - delete bidRequests[1].params.priceType; - }); - - it('pt parameter must be "net" or "gross"', function () { - bidRequests[1].params.priceType = 'some'; - const request = spec.buildRequests(bidRequests); - expect(request.data).to.be.an('string'); - const payload = parseRequest(request.data); - expect(payload).to.have.property('u').that.is.a('string'); - expect(payload).to.have.property('pt', 'net'); - expect(payload).to.have.property('auids', '5,6'); - delete bidRequests[1].params.priceType; - }); - }); - - describe('interpretResponse', function () { - const responses = [ - {'bid': [{'price': 1.15, 'adm': '
test content 1
', 'auid': 4, 'h': 250, 'w': 300}], 'seat': '1'}, - {'bid': [{'price': 0.5, 'adm': '
test content 2
', 'auid': 5, 'h': 90, 'w': 728}], 'seat': '1'}, - {'bid': [{'price': 0, 'auid': 6, 'h': 250, 'w': 300}], 'seat': '1'}, - {'bid': [{'price': 0, 'adm': '
test content 4
', 'h': 250, 'w': 300}], 'seat': '1'}, - undefined, - {'bid': [], 'seat': '1'}, - {'seat': '1'}, - ]; - - it('should get correct bid response', function () { - const bidRequests = [ - { - 'bidder': 'gxone', - 'params': { - 'uid': '4' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '659423fff799cb', - 'bidderRequestId': '5f2009617a7c0a', - 'auctionId': '1cbd2feafe5e8b', - } - ]; - const request = spec.buildRequests(bidRequests); - const expectedResponse = [ - { - 'requestId': '659423fff799cb', - 'cpm': 1.15, - 'creativeId': 4, - 'dealId': undefined, - 'width': 300, - 'height': 250, - 'ad': '
test content 1
', - 'currency': 'USD', - 'netRevenue': true, - 'ttl': 360, - } - ]; - - const result = spec.interpretResponse({'body': {'seatbid': [responses[0]]}}, request); - expect(result).to.deep.equal(expectedResponse); - }); - - it('should get correct multi bid response', function () { - const bidRequests = [ - { - 'bidder': 'gxone', - 'params': { - 'uid': '4' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '300bfeb0d71a5b', - 'bidderRequestId': '2c2bb1972df9a', - 'auctionId': '1fa09aee5c8c99', - }, - { - 'bidder': 'gxone', - 'params': { - 'uid': '5' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '4dff80cc4ee346', - 'bidderRequestId': '2c2bb1972df9a', - 'auctionId': '1fa09aee5c8c99', - }, - { - 'bidder': 'gxone', - 'params': { - 'uid': '4' - }, - 'adUnitCode': 'adunit-code-2', - 'sizes': [[728, 90]], - 'bidId': '5703af74d0472a', - 'bidderRequestId': '2c2bb1972df9a', - 'auctionId': '1fa09aee5c8c99', - } - ]; - const request = spec.buildRequests(bidRequests); - const expectedResponse = [ - { - 'requestId': '300bfeb0d71a5b', - 'cpm': 1.15, - 'creativeId': 4, - 'dealId': undefined, - 'width': 300, - 'height': 250, - 'ad': '
test content 1
', - 'currency': 'USD', - 'netRevenue': true, - 'ttl': 360, - }, - { - 'requestId': '5703af74d0472a', - 'cpm': 1.15, - 'creativeId': 4, - 'dealId': undefined, - 'width': 300, - 'height': 250, - 'ad': '
test content 1
', - 'currency': 'USD', - 'netRevenue': true, - 'ttl': 360, - }, - { - 'requestId': '4dff80cc4ee346', - 'cpm': 0.5, - 'creativeId': 5, - 'dealId': undefined, - 'width': 728, - 'height': 90, - 'ad': '
test content 2
', - 'currency': 'USD', - 'netRevenue': true, - 'ttl': 360, - } - ]; - - const result = spec.interpretResponse({'body': {'seatbid': [responses[0], responses[1]]}}, request); - expect(result).to.deep.equal(expectedResponse); - }); - - it('handles wrong and nobid responses', function () { - const bidRequests = [ - { - 'bidder': 'gxone', - 'params': { - 'uid': '6' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '300bfeb0d7190gf', - 'bidderRequestId': '2c2bb1972d23af', - 'auctionId': '1fa09aee5c84d34', - }, - { - 'bidder': 'gxone', - 'params': { - 'uid': '7' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '300bfeb0d71321', - 'bidderRequestId': '2c2bb1972d23af', - 'auctionId': '1fa09aee5c84d34', - }, - { - 'bidder': 'gxone', - 'params': { - 'uid': '8' - }, - 'adUnitCode': 'adunit-code-2', - 'sizes': [[728, 90]], - 'bidId': '300bfeb0d7183bb', - 'bidderRequestId': '2c2bb1972d23af', - 'auctionId': '1fa09aee5c84d34', - } - ]; - const request = spec.buildRequests(bidRequests); - const result = spec.interpretResponse({'body': {'seatbid': responses.slice(2)}}, request); - expect(result.length).to.equal(0); - }); - }); -}); diff --git a/test/spec/modules/hpmdnetworkBidAdapter_spec.js b/test/spec/modules/hpmdnetworkBidAdapter_spec.js index 37ec44f07c4a..8e400f20defe 100644 --- a/test/spec/modules/hpmdnetworkBidAdapter_spec.js +++ b/test/spec/modules/hpmdnetworkBidAdapter_spec.js @@ -51,7 +51,7 @@ describe('HPMDNetwork Adapter', function() { it('should build single POST request for multiple bids', function() { expect(bidRequest.method).to.equal('POST'); - expect(bidRequest.url).to.equal('//banner.hpmdnetwork.ru/bidder/request'); + expect(bidRequest.url).to.equal('https://banner.hpmdnetwork.ru/bidder/request'); expect(bidRequest.data).to.be.an('object'); expect(bidRequest.data.places).to.be.an('array'); expect(bidRequest.data.places).to.have.lengthOf(2); @@ -90,14 +90,14 @@ describe('HPMDNetwork Adapter', function() { { 'cpm': 20, 'currency': 'RUB', - 'displayUrl': '//banner.hpmdnetwork.ru/bidder/display?dbid=0&vbid=168', + 'displayUrl': 'https://banner.hpmdnetwork.ru/bidder/display?dbid=0&vbid=168', 'id': '1', 'creativeId': '11111', }, { 'cpm': 30, 'currency': 'RUB', - 'displayUrl': '//banner.hpmdnetwork.ru/bidder/display?dbid=0&vbid=170', + 'displayUrl': 'https://banner.hpmdnetwork.ru/bidder/display?dbid=0&vbid=170', 'id': '2', 'creativeId': '22222', 'width': 300, @@ -129,7 +129,7 @@ describe('HPMDNetwork Adapter', function() { expect(bids[0]).to.have.property('creativeId'); expect(bids[0].creativeId).to.equal('11111'); expect(bids[0].netRevenue).to.equal(true); - expect(bids[0].ad).to.include(''); + expect(bids[0].ad).to.include(''); }); it('should parse bid with sizes', function() { @@ -142,7 +142,7 @@ describe('HPMDNetwork Adapter', function() { expect(bids[1]).to.have.property('creativeId'); expect(bids[1].creativeId).to.equal('22222'); expect(bids[1].netRevenue).to.equal(true); - expect(bids[1].ad).to.include(''); + expect(bids[1].ad).to.include(''); }); }); }); diff --git a/test/spec/modules/huddledmassesBidAdapter_spec.js b/test/spec/modules/huddledmassesBidAdapter_spec.js deleted file mode 100644 index 7823ae53c129..000000000000 --- a/test/spec/modules/huddledmassesBidAdapter_spec.js +++ /dev/null @@ -1,119 +0,0 @@ -import {expect} from 'chai'; -import {spec} from '../../../modules/huddledmassesBidAdapter'; - -describe('HuddledmassesAdapter', function () { - let bid = { - bidId: '2dd581a2b6281d', - bidder: 'huddledmasses', - bidderRequestId: '145e1d6a7837c9', - params: { - placement_id: 0 - }, - placementCode: 'placementid_0', - auctionId: '74f78609-a92d-4cf1-869f-1b244bbfb5d2', - sizes: [[300, 250]], - transactionId: '3bb2f6da-87a6-4029-aeb0-bfe951372e62' - }; - - describe('isBidRequestValid', function () { - it('Should return true when placement_id can be cast to a number, and when at least one of the sizes passed is allowed', function () { - expect(spec.isBidRequestValid(bid)).to.be.true; - }); - it('Should return false when placement_id is not a number', function () { - bid.params.placement_id = 'aaa'; - expect(spec.isBidRequestValid(bid)).to.be.false; - }); - it('Should return false when the sizes are not allowed', function () { - bid.sizes = [[1, 1]]; - expect(spec.isBidRequestValid(bid)).to.be.false; - }); - }); - - describe('buildRequests', function () { - let serverRequest = spec.buildRequests([bid]); - it('Creates a ServerRequest object with method, URL and data', function () { - expect(serverRequest).to.exist; - expect(serverRequest.method).to.exist; - expect(serverRequest.url).to.exist; - expect(serverRequest.data).to.exist; - }); - it('Returns POST method', function () { - expect(serverRequest.method).to.equal('POST'); - }); - it('Returns valid URL', function () { - expect(serverRequest.url).to.equal('//huddledmassessupply.com/?c=o&m=multi'); - }); - it('Returns valid data if array of bids is valid', function () { - let data = serverRequest.data; - expect(data).to.be.an('object'); - expect(data).to.have.all.keys('deviceWidth', 'deviceHeight', 'language', 'secure', 'host', 'page', 'placements'); - expect(data.deviceWidth).to.be.a('number'); - expect(data.deviceHeight).to.be.a('number'); - expect(data.language).to.be.a('string'); - expect(data.secure).to.be.within(0, 1); - expect(data.host).to.be.a('string'); - expect(data.page).to.be.a('string'); - let placements = data['placements']; - for (let i = 0; i < placements.length; i++) { - let placement = placements[i]; - expect(placement).to.have.all.keys('placementId', 'bidId', 'sizes'); - expect(placement.placementId).to.be.a('number'); - expect(placement.bidId).to.be.a('string'); - expect(placement.sizes).to.be.an('array'); - } - }); - it('Returns empty data if no valid requests are passed', function () { - serverRequest = spec.buildRequests([]); - let data = serverRequest.data; - expect(data.placements).to.be.an('array').that.is.empty; - }); - }); - describe('interpretResponse', function () { - let resObject = { - body: [ { - requestId: '123', - cpm: 0.3, - width: 320, - height: 50, - ad: '

Hello ad

', - ttl: 1000, - creativeId: '123asd', - netRevenue: true, - currency: 'USD' - } ] - }; - let serverResponses = spec.interpretResponse(resObject); - it('Returns an array of valid server responses if response object is valid', function () { - expect(serverResponses).to.be.an('array').that.is.not.empty; - for (let i = 0; i < serverResponses.length; i++) { - let dataItem = serverResponses[i]; - expect(dataItem).to.have.all.keys('requestId', 'cpm', 'width', 'height', 'ad', 'ttl', 'creativeId', - 'netRevenue', 'currency'); - expect(dataItem.requestId).to.be.a('string'); - expect(dataItem.cpm).to.be.a('number'); - expect(dataItem.width).to.be.a('number'); - expect(dataItem.height).to.be.a('number'); - expect(dataItem.ad).to.be.a('string'); - expect(dataItem.ttl).to.be.a('number'); - expect(dataItem.creativeId).to.be.a('string'); - expect(dataItem.netRevenue).to.be.a('boolean'); - expect(dataItem.currency).to.be.a('string'); - } - it('Returns an empty array if invalid response is passed', function () { - serverResponses = spec.interpretResponse('invalid_response'); - expect(serverResponses).to.be.an('array').that.is.empty; - }); - }); - }); - - describe('getUserSyncs', function () { - let userSync = spec.getUserSyncs(); - it('Returns valid URL and type', function () { - expect(userSync).to.be.an('array').with.lengthOf(1); - expect(userSync[0].type).to.exist; - expect(userSync[0].url).to.exist; - expect(userSync[0].type).to.be.equal('image'); - expect(userSync[0].url).to.be.equal('//huddledmassessupply.com/?c=o&m=cookie'); - }); - }); -}); diff --git a/test/spec/modules/iasBidAdapter_spec.js b/test/spec/modules/iasBidAdapter_spec.js index 8197ee258567..7ac9d1906f52 100644 --- a/test/spec/modules/iasBidAdapter_spec.js +++ b/test/spec/modules/iasBidAdapter_spec.js @@ -44,7 +44,7 @@ describe('iasBidAdapter is an adapter that', function () { describe('given bid requests, returns a `ServerRequest` instance that', function () { let bidRequests, IAS_HOST; beforeEach(function () { - IAS_HOST = '//pixel.adsafeprotected.com/services/pub'; + IAS_HOST = 'https://pixel.adsafeprotected.com/services/pub'; bidRequests = [ { adUnitCode: 'one-div-id', diff --git a/test/spec/modules/imonomyBidAdapter_spec.js b/test/spec/modules/imonomyBidAdapter_spec.js index 206e227a3b17..91b907186c2c 100644 --- a/test/spec/modules/imonomyBidAdapter_spec.js +++ b/test/spec/modules/imonomyBidAdapter_spec.js @@ -44,7 +44,7 @@ describe('Imonomy Adapter Tests', function () { width: 300, height: 250, cpm: 0.51, - creative: '', + creative: '', ttl: 360, currency: 'USD', netRevenue: true, @@ -73,7 +73,7 @@ describe('Imonomy Adapter Tests', function () { var startTime = new Date().getTime(); const request = spec.buildRequests(bidsRequest); - expect(request.url).to.equal('//b.imonomy.com/openrtb/hb/14567718624'); + expect(request.url).to.equal('https://b.imonomy.com/openrtb/hb/14567718624'); expect(request.method).to.equal('POST'); const requestData = JSON.parse(request.data); @@ -159,6 +159,6 @@ describe('Imonomy Adapter Tests', function () { expect(options).to.not.be.undefined; expect(options).to.have.lengthOf(1); expect(options[0].type).to.equal('iframe'); - expect(options[0].url).to.equal('//b.imonomy.com/UserMatching/b/'); + expect(options[0].url).to.equal('https://b.imonomy.com/UserMatching/b/'); }); }); diff --git a/test/spec/modules/improvedigitalBidAdapter_spec.js b/test/spec/modules/improvedigitalBidAdapter_spec.js index 8ac8c8e85dfd..15b7e2ff3e88 100644 --- a/test/spec/modules/improvedigitalBidAdapter_spec.js +++ b/test/spec/modules/improvedigitalBidAdapter_spec.js @@ -316,17 +316,17 @@ describe('Improve Digital Adapter Tests', function () { 'id': '33e9500b21129f', 'advid': '5279', 'price': 1.45888594164456, - 'nurl': 'http://ice.360yield.com/imp_pixel?ic=wVmhKI07hCVyGC1sNdFp.6buOSiGYOw8jPyZLlcMY2RCwD4ek3Fy6.xUI7U002skGBs3objMBoNU-Frpvmb9js3NKIG0YZJgWaNdcpXY9gOXE9hY4-wxybCjVSNzhOQB-zic73hzcnJnKeoGgcfvt8fMy18-yD0aVdYWt4zbqdoITOkKNCPBEgbPFu1rcje-o7a64yZ7H3dKvtnIixXQYc1Ep86xGSBGXY6xW2KfUOMT6vnkemxO72divMkMdhR8cAuqIubbx-ZID8-xf5c9k7p6DseeBW0I8ionrlTHx.rGosgxhiFaMqtr7HiA7PBzKvPdeEYN0hQ8RYo8JzYL82hA91A3V2m9Ij6y0DfIJnnrKN8YORffhxmJ6DzwEl1zjrVFbD01bqB3Vdww8w8PQJSkKQkd313tr-atU8LS26fnBmOngEkVHwAr2WCKxuUvxHmuVBTA-Lgz7wKwMoOJCA3hFxMavVb0ZFB7CK0BUTVU6z0De92Q.FJKNCHLMbjX3vcAQ90=', + 'nurl': 'https://ice.360yield.com/imp_pixel?ic=wVmhKI07hCVyGC1sNdFp.6buOSiGYOw8jPyZLlcMY2RCwD4ek3Fy6.xUI7U002skGBs3objMBoNU-Frpvmb9js3NKIG0YZJgWaNdcpXY9gOXE9hY4-wxybCjVSNzhOQB-zic73hzcnJnKeoGgcfvt8fMy18-yD0aVdYWt4zbqdoITOkKNCPBEgbPFu1rcje-o7a64yZ7H3dKvtnIixXQYc1Ep86xGSBGXY6xW2KfUOMT6vnkemxO72divMkMdhR8cAuqIubbx-ZID8-xf5c9k7p6DseeBW0I8ionrlTHx.rGosgxhiFaMqtr7HiA7PBzKvPdeEYN0hQ8RYo8JzYL82hA91A3V2m9Ij6y0DfIJnnrKN8YORffhxmJ6DzwEl1zjrVFbD01bqB3Vdww8w8PQJSkKQkd313tr-atU8LS26fnBmOngEkVHwAr2WCKxuUvxHmuVBTA-Lgz7wKwMoOJCA3hFxMavVb0ZFB7CK0BUTVU6z0De92Q.FJKNCHLMbjX3vcAQ90=', 'h': 290, 'pid': 1053688, 'sync': [ - 'http://link1', - 'http://link2' + 'https://link1', + 'https://link2' ], 'crid': '422031', 'w': 600, 'cid': '99006', - 'adm': 'document.writeln(\"\\\"\\\"\\/<\\/a>\");document.writeln(\"<\\/improvedigital_ad_output_information>\");' + 'adm': 'document.writeln(\"\\\"\\\"\\/<\\/a>\");document.writeln(\"<\\/improvedigital_ad_output_information>\");' } ], 'debug': '' @@ -344,16 +344,16 @@ describe('Improve Digital Adapter Tests', function () { 'id': '1234', 'advid': '5280', 'price': 1.23, - 'nurl': 'http://link/imp_pixel?ic=wVmhKI07hCVyGC1sNdFp.6buOSiGYOw8jPyZLlcMY2RCwD4ek3Fy6.xUI7U002skGBs3objMBoNU-Frpvmb9js3NKIG0YZJgWaNdcpXY9gOXE9hY4-wxybCjVSNzhOQB-zic73hzcnJnKeoGgcfvt8fMy18-yD0aVdYWt4zbqdoITOkKNCPBEgbPFu1rcje-o7a64yZ7H3dKvtnIixXQYc1Ep86xGSBGXY6xW2KfUOMT6vnkemxO72divMkMdhR8cAuqIubbx-ZID8-xf5c9k7p6DseeBW0I8ionrlTHx.rGosgxhiFaMqtr7HiA7PBzKvPdeEYN0hQ8RYo8JzYL82hA91A3V2m9Ij6y0DfIJnnrKN8YORffhxmJ6DzwEl1zjrVFbD01bqB3Vdww8w8PQJSkKQkd313tr-atU8LS26fnBmOngEkVHwAr2WCKxuUvxHmuVBTA-Lgz7wKwMoOJCA3hFxMavVb0ZFB7CK0BUTVU6z0De92Q.FJKNCHLMbjX3vcAQ90=', + 'nurl': 'https://link/imp_pixel?ic=wVmhKI07hCVyGC1sNdFp.6buOSiGYOw8jPyZLlcMY2RCwD4ek3Fy6.xUI7U002skGBs3objMBoNU-Frpvmb9js3NKIG0YZJgWaNdcpXY9gOXE9hY4-wxybCjVSNzhOQB-zic73hzcnJnKeoGgcfvt8fMy18-yD0aVdYWt4zbqdoITOkKNCPBEgbPFu1rcje-o7a64yZ7H3dKvtnIixXQYc1Ep86xGSBGXY6xW2KfUOMT6vnkemxO72divMkMdhR8cAuqIubbx-ZID8-xf5c9k7p6DseeBW0I8ionrlTHx.rGosgxhiFaMqtr7HiA7PBzKvPdeEYN0hQ8RYo8JzYL82hA91A3V2m9Ij6y0DfIJnnrKN8YORffhxmJ6DzwEl1zjrVFbD01bqB3Vdww8w8PQJSkKQkd313tr-atU8LS26fnBmOngEkVHwAr2WCKxuUvxHmuVBTA-Lgz7wKwMoOJCA3hFxMavVb0ZFB7CK0BUTVU6z0De92Q.FJKNCHLMbjX3vcAQ90=', 'h': 400, 'pid': 1053688, 'sync': [ - 'http://link3' + 'https://link3' ], 'crid': '422033', 'w': 700, 'cid': '99006', - 'adm': 'document.writeln(\"\\\"\\\"\\/<\\/a>\");document.writeln(\"<\\/improvedigital_ad_output_information>\");' + 'adm': 'document.writeln(\"\\\"\\\"\\/<\\/a>\");document.writeln(\"<\\/improvedigital_ad_output_information>\");' } ], 'debug': '' @@ -370,12 +370,12 @@ describe('Improve Digital Adapter Tests', function () { id: '33e9500b21129f', advid: '5279', price: 1.45888594164456, - nurl: 'http://ice.360yield.com/imp_pixel?ic=wVm', + nurl: 'https://ice.360yield.com/imp_pixel?ic=wVm', h: 290, pid: 1053688, sync: [ - 'http://link1', - 'http://link2' + 'https://link1', + 'https://link2' ], crid: '422031', w: 600, @@ -470,7 +470,7 @@ describe('Improve Digital Adapter Tests', function () { { img: { type: 2, - url: 'http://blah.com/icon.jpg', + url: 'https://blah.com/icon.jpg', h: 30, w: 40 } @@ -479,23 +479,23 @@ describe('Improve Digital Adapter Tests', function () { { img: { type: 3, - url: 'http://blah.com/image.jpg', + url: 'https://blah.com/image.jpg', h: 200, w: 800 } } ], link: { - url: 'http://advertiser.com', + url: 'https://advertiser.com', clicktrackers: [ - 'http://click.tracker.com/click?impid=123' + 'https://click.tracker.com/click?impid=123' ] }, imptrackers: [ - 'http://imptrack1.com', - 'http://imptrack2.com' + 'https://imptrack1.com', + 'https://imptrack2.com' ], - jstracker: '', + jstracker: '', privacy: 'https://www.myprivacyurl.com' } } @@ -536,19 +536,19 @@ describe('Improve Digital Adapter Tests', function () { { event: 1, method: 1, - url: 'http://www.mytracker.com/imptracker' + url: 'https://www.mytracker.com/imptracker' }, { event: 1, method: 2, - url: 'http://www.mytracker.com/tracker.js' + url: 'https://www.mytracker.com/tracker.js' } ]; describe('interpretResponse', function () { let expectedBid = [ { - 'ad': '', + 'ad': '', 'adId': '33e9500b21129f', 'creativeId': '422031', 'cpm': 1.45888594164456, @@ -565,7 +565,7 @@ describe('Improve Digital Adapter Tests', function () { let expectedTwoBids = [ expectedBid[0], { - 'ad': '', + 'ad': '', 'adId': '1234', 'creativeId': '422033', 'cpm': 1.23, @@ -606,23 +606,23 @@ describe('Improve Digital Adapter Tests', function () { address: '123 Main Street, Anywhere USA', displayUrl: 'https://myurl.com', icon: { - url: 'http://blah.com/icon.jpg', + url: 'https://blah.com/icon.jpg', height: 30, width: 40 }, image: { - url: 'http://blah.com/image.jpg', + url: 'https://blah.com/image.jpg', height: 200, width: 800 }, - clickUrl: 'http://advertiser.com', - clickTrackers: ['http://click.tracker.com/click?impid=123'], + clickUrl: 'https://advertiser.com', + clickTrackers: ['https://click.tracker.com/click?impid=123'], impressionTrackers: [ - 'http://ice.360yield.com/imp_pixel?ic=wVm', - 'http://imptrack1.com', - 'http://imptrack2.com' + 'https://ice.360yield.com/imp_pixel?ic=wVm', + 'https://imptrack1.com', + 'https://imptrack2.com' ], - javascriptTrackers: '', + javascriptTrackers: '', privacyLink: 'https://www.myprivacyurl.com' } } @@ -751,10 +751,10 @@ describe('Improve Digital Adapter Tests', function () { const expectedBids = JSON.parse(JSON.stringify(expectedBidNative)); response.body.bid[0].native.eventtrackers = nativeEventtrackers; expectedBids[0].native.impressionTrackers = [ - 'http://ice.360yield.com/imp_pixel?ic=wVm', - 'http://www.mytracker.com/imptracker' + 'https://ice.360yield.com/imp_pixel?ic=wVm', + 'https://www.mytracker.com/imptracker' ]; - expectedBids[0].native.javascriptTrackers = ''; + expectedBids[0].native.javascriptTrackers = ''; bids = spec.interpretResponse(response); delete bids[0].ortbNative; expect(bids).to.deep.equal(expectedBids); @@ -778,9 +778,9 @@ describe('Improve Digital Adapter Tests', function () { it('should return user syncs', function () { const syncs = spec.getUserSyncs({ pixelEnabled: true }, serverResponses); const expected = [ - { type: 'image', url: 'http://link1' }, - { type: 'image', url: 'http://link2' }, - { type: 'image', url: 'http://link3' } + { type: 'image', url: 'https://link1' }, + { type: 'image', url: 'https://link2' }, + { type: 'image', url: 'https://link3' } ]; expect(syncs).to.deep.equal(expected); }); diff --git a/test/spec/modules/innityBidAdapter_spec.js b/test/spec/modules/innityBidAdapter_spec.js deleted file mode 100644 index 0132f093ca1e..000000000000 --- a/test/spec/modules/innityBidAdapter_spec.js +++ /dev/null @@ -1,100 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/innityBidAdapter'; - -describe('innityAdapterTest', function () { - describe('bidRequestValidity', function () { - it('bidRequest with pub ID and zone ID param', function () { - expect(spec.isBidRequestValid({ - bidder: 'innity', - params: { - 'pub': 267, - 'zone': 62546 - }, - })).to.equal(true); - }); - - it('bidRequest with no required params', function () { - expect(spec.isBidRequestValid({ - bidder: 'innity', - params: { - }, - })).to.equal(false); - }); - }); - - describe('bidRequest', function () { - const bidRequests = [{ - 'bidder': 'innity', - 'params': { - 'pub': 267, - 'zone': 62546 - }, - 'adUnitCode': 'div-gpt-ad-1460505748561-0', - 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', - 'sizes': [300, 250], - 'bidId': '51ef8751f9aead', - 'bidderRequestId': '418b37f85e772c', - 'auctionId': '18fd8b8b0bd757' - }]; - - it('bidRequest HTTP method', function () { - const requests = spec.buildRequests(bidRequests); - requests.forEach(function(requestItem) { - expect(requestItem.method).to.equal('GET'); - }); - }); - - it('bidRequest data', function () { - const requests = spec.buildRequests(bidRequests); - expect(requests[0].data.pub).to.equal(267); - expect(requests[0].data.zone).to.equal(62546); - expect(requests[0].data.width).to.equal('300'); - expect(requests[0].data.height).to.equal('250'); - expect(requests[0].data.callback_uid).to.equal('51ef8751f9aead'); - }); - }); - - describe('interpretResponse', function () { - const bidRequest = { - 'method': 'GET', - 'url': 'https://as.innity.com/synd/?', - 'data': { - 'ver': 2, - 'hb': 1, - 'output': 'js', - 'pub': 267, - 'zone': 62546, - 'width': '300', - 'height': '250', - 'callback': 'json', - 'callback_uid': '51ef8751f9aead', - 'url': 'https://example.com', - 'cb': '', - } - }; - - const bidResponse = { - body: { - 'cpm': 100, - 'width': '300', - 'height': '250', - 'creative_id': '148186', - 'callback_uid': '51ef8751f9aead', - 'tag': '', - }, - headers: {} - }; - - it('result is correct', function () { - const result = spec.interpretResponse(bidResponse, bidRequest); - expect(result[0].requestId).to.equal('51ef8751f9aead'); - expect(result[0].cpm).to.equal(1); - expect(result[0].width).to.equal('300'); - expect(result[0].height).to.equal('250'); - expect(result[0].creativeId).to.equal('148186'); - expect(result[0].currency).to.equal('USD'); - expect(result[0].ttl).to.equal(60); - expect(result[0].ad).to.equal(''); - }); - }); -}); diff --git a/test/spec/modules/inskinBidAdapter_spec.js b/test/spec/modules/inskinBidAdapter_spec.js deleted file mode 100644 index 896fe36d443c..000000000000 --- a/test/spec/modules/inskinBidAdapter_spec.js +++ /dev/null @@ -1,288 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/inskinBidAdapter'; -import { createBid } from 'src/bidfactory'; - -const ENDPOINT = 'https://mfad.inskinad.com/api/v2'; - -const REQUEST = { - 'bidderCode': 'inskin', - 'requestId': 'a4713c32-3762-4798-b342-4ab810ca770d', - 'bidderRequestId': '109f2a181342a9', - 'bidRequest': [{ - 'bidder': 'inskin', - 'params': { - 'networkId': 9874, - 'siteId': 730181 - }, - 'placementCode': 'div-gpt-ad-1487778092495-0', - 'sizes': [ - [728, 90], - [970, 90] - ], - 'bidId': '2b0f82502298c9', - 'bidderRequestId': '109f2a181342a9', - 'requestId': 'a4713c32-3762-4798-b342-4ab810ca770d' - }, - { - 'bidder': 'inskin', - 'params': { - 'networkId': 9874, - 'siteId': 730181 - }, - 'placementCode': 'div-gpt-ad-1487778092495-0', - 'sizes': [ - [728, 90], - [970, 90] - ], - 'bidId': '123', - 'bidderRequestId': '109f2a181342a9', - 'requestId': 'a4713c32-3762-4798-b342-4ab810ca770d' - }], - 'start': 1487883186070, - 'auctionStart': 1487883186069, - 'timeout': 3000 -}; - -const RESPONSE = { - 'headers': null, - 'body': { - 'user': { 'key': 'ue1-2d33e91b71e74929b4aeecc23f4376f1' }, - 'decisions': { - '2b0f82502298c9': { - 'adId': 2364764, - 'creativeId': 1950991, - 'flightId': 2788300, - 'campaignId': 542982, - 'clickUrl': 'https://mfad.inskinad.com/r', - 'impressionUrl': 'https://mfad.inskinad.com/i.gif', - 'contents': [{ - 'type': 'html', - 'body': '', - 'data': { - 'height': 90, - 'width': 728, - 'imageUrl': 'https://static.adzerk.net/Advertisers/b0ab77db8a7848c8b78931aed022a5ef.gif', - 'fileName': 'b0ab77db8a7848c8b78931aed022a5ef.gif' - }, - 'template': 'image' - }], - 'height': 90, - 'width': 728, - 'events': [], - 'pricing': {'price': 0.5, 'clearPrice': 0.5, 'revenue': 0.0005, 'rateType': 2, 'eCPM': 0.5} - }, - '123': { - 'adId': 2364764, - 'creativeId': 1950991, - 'flightId': 2788300, - 'campaignId': 542982, - 'clickUrl': 'https://mfad.inskinad.com/r', - 'impressionUrl': 'https://mfad.inskinad.com/i.gif', - 'contents': [{ - 'type': 'html', - 'body': '', - 'data': { - 'customData': { - 'pubCPM': 1 - }, - 'height': 90, - 'width': 728, - 'imageUrl': 'https://static.adzerk.net/Advertisers/b0ab77db8a7848c8b78931aed022a5ef.gif', - 'fileName': 'b0ab77db8a7848c8b78931aed022a5ef.gif' - }, - 'template': 'image' - }], - 'height': 90, - 'width': 728, - 'events': [], - 'pricing': {'price': 0.5, 'clearPrice': 0.5, 'revenue': 0.0005, 'rateType': 2, 'eCPM': 0.5} - } - } - } -}; - -describe('InSkin BidAdapter', function () { - let bidRequests; - let adapter = spec; - - beforeEach(function () { - bidRequests = [ - { - bidder: 'inskin', - params: { - networkId: '9874', - siteId: 'xxxxx' - }, - placementCode: 'header-bid-tag-1', - sizes: [[300, 250], [300, 600]], - bidId: '23acc48ad47af5', - requestId: '0fb4905b-9456-4152-86be-c6f6d259ba99', - bidderRequestId: '1c56ad30b9b8ca8', - transactionId: '92489f71-1bf2-49a0-adf9-000cea934729' - } - ]; - }); - - describe('bid request validation', function () { - it('should accept valid bid requests', function () { - let bid = { - bidder: 'inskin', - params: { - networkId: '9874', - siteId: 'xxxxx' - } - }; - expect(spec.isBidRequestValid(bid)).to.equal(true); - }); - - it('should accept valid bid requests with extra fields', function () { - let bid = { - bidder: 'inskin', - params: { - networkId: '9874', - siteId: 'xxxxx', - zoneId: 'xxxxx' - } - }; - expect(spec.isBidRequestValid(bid)).to.equal(true); - }); - - it('should reject bid requests without siteId', function () { - let bid = { - bidder: 'inskin', - params: { - networkId: '9874' - } - }; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - - it('should reject bid requests without networkId', function () { - let bid = { - bidder: 'inskin', - params: { - siteId: '9874' - } - }; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - }); - - describe('buildRequests validation', function () { - it('creates request data', function () { - let request = spec.buildRequests(bidRequests); - - expect(request).to.exist.and.to.be.a('object'); - }); - - it('request to inskin should contain a url', function () { - let request = spec.buildRequests(bidRequests); - - expect(request.url).to.have.string('inskinad.com'); - }); - - it('requires valid bids to make request', function () { - let request = spec.buildRequests([]); - expect(request.bidRequest).to.be.empty; - }); - - it('sends bid request to ENDPOINT via POST', function () { - let request = spec.buildRequests(bidRequests); - - expect(request.method).to.have.string('POST'); - }); - - it('should add gdpr consent information to the request', function () { - let consentString = 'BOJ8RZsOJ8RZsABAB8AAAAAZ+A=='; - let bidderRequest = { - 'bidderCode': 'inskin', - 'gdprConsent': { - consentString: consentString, - gdprApplies: true - } - }; - bidderRequest.bids = bidRequests; - - const request = spec.buildRequests(bidRequests, bidderRequest); - const payload = JSON.parse(request.data); - - expect(payload.consent.gdprConsentString).to.exist; - expect(payload.consent.gdprConsentRequired).to.exist; - expect(payload.consent.gdprConsentString).to.exist.and.to.equal(consentString); - expect(payload.consent.gdprConsentRequired).to.exist.and.to.be.true; - }); - }); - describe('interpretResponse validation', function () { - it('response should have valid bidderCode', function () { - let bidRequest = spec.buildRequests(REQUEST.bidRequest); - let bid = createBid(1, bidRequest.bidRequest[0]); - - expect(bid.bidderCode).to.equal('inskin'); - }); - - it('response should include objects for all bids', function () { - let bids = spec.interpretResponse(RESPONSE, REQUEST); - - expect(bids.length).to.equal(2); - }); - - it('registers bids', function () { - let bids = spec.interpretResponse(RESPONSE, REQUEST); - bids.forEach(b => { - expect(b).to.have.property('cpm'); - expect(b.cpm).to.be.above(0); - expect(b).to.have.property('requestId'); - expect(b).to.have.property('cpm'); - expect(b).to.have.property('width'); - expect(b).to.have.property('height'); - expect(b).to.have.property('ad'); - expect(b).to.have.property('currency', 'USD'); - expect(b).to.have.property('creativeId'); - expect(b).to.have.property('ttl', 360); - expect(b).to.have.property('netRevenue', true); - expect(b).to.have.property('referrer'); - }); - }); - - it('cpm is correctly set', function () { - let bids = spec.interpretResponse(RESPONSE, REQUEST); - - expect(bids[0].cpm).to.equal(0.5); - expect(bids[1].cpm).to.equal(1); - }); - - it('handles nobid responses', function () { - let EMPTY_RESP = Object.assign({}, RESPONSE, {'body': {'decisions': null}}) - let bids = spec.interpretResponse(EMPTY_RESP, REQUEST); - - expect(bids).to.be.empty; - }); - - it('handles no server response', function () { - let bids = spec.interpretResponse(null, REQUEST); - - expect(bids).to.be.empty; - }); - }); - describe('getUserSyncs', function () { - it('handles empty sync options', function () { - let opts = spec.getUserSyncs({}); - - expect(opts).to.be.empty; - }); - - it('should return two sync urls if pixel syncs are enabled', function () { - let syncOptions = {'pixelEnabled': true}; - let opts = spec.getUserSyncs(syncOptions); - - expect(opts.length).to.equal(2); - }); - - it('should return three sync urls if pixel and iframe syncs are enabled', function () { - let syncOptions = {'iframeEnabled': true, 'pixelEnabled': true}; - let opts = spec.getUserSyncs(syncOptions); - - expect(opts.length).to.equal(3); - }); - }); -}); diff --git a/test/spec/modules/interactiveOffersBidAdapter_spec.js b/test/spec/modules/interactiveOffersBidAdapter_spec.js deleted file mode 100644 index 8921a3027387..000000000000 --- a/test/spec/modules/interactiveOffersBidAdapter_spec.js +++ /dev/null @@ -1,177 +0,0 @@ -import {expect} from 'chai'; -import {spec} from 'modules/interactiveOffersBidAdapter'; - -describe('interactiveOffers adapter', function () { - describe('implementation', function () { - describe('for requests', function () { - it('should accept valid bid', function () { - let validBid = { - bidder: 'interactiveOffers', - params: { - pubId: '42' - } - }, - isValid = spec.isBidRequestValid(validBid); - - expect(isValid).to.equal(true); - }); - - it('should reject invalid bid', function () { - let invalidBid = { - bidder: 'interactiveOffers' - }, - isValid = spec.isBidRequestValid(invalidBid); - - expect(isValid).to.equal(false); - }); - }); - describe('for requests', function () { - it('should accept valid bid with optional params', function () { - let validBid = { - bidder: 'interactiveOffers', - params: { - pubId: '42', - loc: 'http://test.com/prebid', - tmax: 1500 - } - }, - isValid = spec.isBidRequestValid(validBid); - expect(isValid).to.equal(true); - - let buildRequest = spec.buildRequests([validBid])[0]; - let requestUrlCustomParams = buildRequest.data; - expect(requestUrlCustomParams).have.property('loc', 'http://test.com/prebid'); - expect(requestUrlCustomParams).have.property('tmax', 1500); - }); - - it('should accept valid bid without optional params', function () { - let validBid = { - bidder: 'interactiveOffers', - params: { - pubId: '42' - } - }, - isValid = spec.isBidRequestValid(validBid); - expect(isValid).to.equal(true); - - let buildRequest = spec.buildRequests([validBid])[0]; - let requestUrlCustomParams = buildRequest.data; - expect(requestUrlCustomParams).have.property('loc'); - expect(requestUrlCustomParams).have.property('tmax'); - }); - - it('should reject invalid bid without pubId', function () { - let invalidBid = { - bidder: 'interactiveOffers', - params: {} - }, - isValid = spec.isBidRequestValid(invalidBid); - - expect(isValid).to.equal(false); - }); - }); - describe('bid responses', function () { - it('should return complete bid response', function () { - let serverResponse = { - body: { - 'success': 'true', - 'message': 'Request Valid', - 'payloadData': { - bidId: '3842b02f7ec0fd', - cpm: 0.5, - width: 300, - height: 600, - ad: '
...
', - } - } - }; - - let bidRequests = [ - { - bidder: 'interactiveOffers', - params: { - pubId: '42' - } - } - ]; - let bids = spec.interpretResponse(serverResponse, {'bidRequest': bidRequests[0]}); - expect(bids).to.be.lengthOf(1); - expect(bids[0].cpm).to.equal(0.5); - expect(bids[0].width).to.equal(300); - expect(bids[0].height).to.equal(600); - expect(bids[0].currency).to.equal('USD'); - expect(bids[0].netRevenue).to.equal(true); - expect(bids[0].ad).to.have.length.above(1); - }); - - it('should return empty bid response', function () { - let bidRequests = [ - { - bidder: 'interactiveOffers', - params: { - pubId: '42' - } - } - ]; - let serverResponse = { - body: { - 'success': 'true', - 'message': 'Request Valid', - 'payloadData': { - bidId: '3842b02f7ec0fd', - cpm: 0 - } - } - }, - bids = spec.interpretResponse(serverResponse, {'bidRequest': bidRequests[0]}); - - expect(bids).to.be.lengthOf(0); - }); - - it('should return empty bid response with error', function () { - let bidRequests = [ - { - bidder: 'interactiveOffers', - params: { - pubId: '42' - } - } - ]; - let serverResponse = {body: {'success': 'false', 'message': 'Request Error'}}, - bids = spec.interpretResponse(serverResponse, {'bidRequest': bidRequests[0]}); - - expect(bids).to.be.lengthOf(0); - }); - - it('should return empty bid response without payload', function () { - let bidRequests = [ - { - bidder: 'interactiveOffers', - params: { - pubId: '42' - } - } - ]; - let serverResponse = {body: {'success': 'true', 'message': 'Empty Payload', 'payloadData': []}}, - bids = spec.interpretResponse(serverResponse, {'bidRequest': bidRequests[0]}); - - expect(bids).to.be.lengthOf(0); - }); - - it('should return empty bid response on empty body', function () { - let bidRequests = [ - { - bidder: 'interactiveOffers', - params: { - pubId: '42' - } - } - ]; - let serverResponse, - bids = spec.interpretResponse(serverResponse, {'bidRequest': bidRequests[0]}); - - expect(bids).to.be.lengthOf(0); - }); - }); - }); -}); diff --git a/test/spec/modules/invibesBidAdapter_spec.js b/test/spec/modules/invibesBidAdapter_spec.js index 57ca35e2b28c..3ca31c0abb41 100644 --- a/test/spec/modules/invibesBidAdapter_spec.js +++ b/test/spec/modules/invibesBidAdapter_spec.js @@ -4,8 +4,8 @@ import { spec, resetInvibes, stubDomainOptions } from 'modules/invibesBidAdapter describe('invibesBidAdapter:', function () { const BIDDER_CODE = 'invibes'; const PLACEMENT_ID = '12345'; - const ENDPOINT = '//bid.videostep.com/Bid/VideoAdContent'; - const SYNC_ENDPOINT = '//k.r66net.com/GetUserSync'; + const ENDPOINT = 'https://bid.videostep.com/Bid/VideoAdContent'; + const SYNC_ENDPOINT = 'https://k.r66net.com/GetUserSync'; let bidRequests = [ { diff --git a/test/spec/modules/iqmBidAdapter_spec.js b/test/spec/modules/iqmBidAdapter_spec.js deleted file mode 100644 index 5535c52af9b2..000000000000 --- a/test/spec/modules/iqmBidAdapter_spec.js +++ /dev/null @@ -1,219 +0,0 @@ -import {expect} from 'chai'; -import {spec} from 'modules/iqmBidAdapter' -import * as utils from 'src/utils'; - -describe('iqmBidAdapter', function () { - const ENDPOINT_URL = 'https://pbd.bids.iqm.com'; - const bidRequests = [{ - bidder: 'iqm', - params: { - position: 1, - tagId: 'tagId-1', - placementId: 'placementId-1', - pubId: 'pubId-1', - secure: true, - bidfloor: 0.5 - }, - placementCode: 'pcode000', - transactionId: 'tx000', - sizes: [[300, 250]], - bidId: 'bid000', - bidderRequestId: '117d765b87bed38', - requestId: 'req000' - }]; - - const bidResponses = { - body: { - id: 'req000', - seatbid: [{ - bid: [{ - nurl: 'nurl', - adm: '', - crid: 'cr-65981', - impid: 'bid000', - price: 0.99, - w: 300, - h: 250, - adomain: ['https://example.com'], - id: 'bid000', - ttl: 300 - }] - }] - }, - headers: {}}; - - const bidResponseEmptySeat = { - body: { - id: 'req000', - seatbid: [] - }, - headers: {} - }; - - const bidResponseEmptyBid = { - body: { - id: 'req000', - seatbid: [{ - bid: [] - }] - }, - headers: {} - }; - - const bidResponseNoImpId = { - body: { - id: 'req000', - seatbid: [{ - bid: [{ - nurl: 'nurl', - adm: '', - crid: 'cr-65981', - price: 0.99, - w: 300, - h: 250, - adomain: ['https://example.com'], - id: 'bid000', - ttl: 300 - }] - }] - }, - headers: {} - }; - - describe('Request verification', function () { - it('basic property verification', function () { - expect(spec.code).to.equal('iqm'); - expect(spec.aliases).to.be.an('array'); - // expect(spec.aliases).to.be.ofSize(1); - expect(spec.aliases).to.have.lengthOf(1); - }); - - describe('isBidRequestValid', function () { - let bid = { - 'bidder': 'iqm', - 'params': { - 'placementId': 'placementId', - 'tagId': 'tagId', - 'publisherId': 'pubId' - }, - 'adUnitCode': 'ad-unit-code', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475' - }; - - it('should return false for empty object', function () { - expect(spec.isBidRequestValid({})).to.equal(false); - }); - - it('should return false for request without param', function () { - let bid = Object.assign({}, bid); - delete bid.params; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - - it('should return false for invalid params', function () { - let bid = Object.assign({}, bid); - delete bid.params; - bid.params = { - 'placementId': 'placementId' - }; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - - it('should return true for proper request', function () { - expect(spec.isBidRequestValid(bid)).to.equal(true); - }); - }); - - describe('buildRequests', function () { - it('sends every bid request to ENDPOINT_URL via POST method', function () { - const requests = spec.buildRequests(bidRequests); - expect(requests[0].method).to.equal('POST'); - expect(requests[0].url).to.equal(ENDPOINT_URL); - // expect(requests[1].method).to.equal('POST'); - // expect(requests[1].url).to.equal(ENDPOINT_URL); - }); - - it('should send request data with every request', function () { - const requests = spec.buildRequests(bidRequests); - const data = requests[0].data; - expect(data.id).to.equal(bidRequests[0].requestId); - - expect(data.imp.id).to.equal(bidRequests[0].bidId); - expect(data.imp.bidfloor).to.equal(bidRequests[0].params.bidfloor); - expect(data.imp.secure).to.equal(1); - expect(data.imp.displaymanager).to.equal('Prebid.js'); - expect(data.imp.displaymanagerver).to.equal('v.1.0.0'); - expect(data.imp.mediatype).to.equal('banner'); - expect(data.imp.banner).to.deep.equal({ - w: 300, - h: 250 - }); - expect(data.publisherId).to.equal(utils.getBidIdParameter('publisherId', bidRequests[0].params)); - expect(data.tagId).to.equal(utils.getBidIdParameter('tagId', bidRequests[0].params)); - expect(data.placementId).to.equal(utils.getBidIdParameter('placementId', bidRequests[0].params)); - expect(data.device.w).to.equal(screen.width); - expect(data.device.h).to.equal(screen.height); - expect(data.device.make).to.equal(navigator.vendor ? navigator.vendor : ''); - expect(data.device.ua).to.equal(navigator.userAgent); - expect(data.device.dnt).to.equal(navigator.doNotTrack === '1' || window.doNotTrack === '1' || navigator.msDoNotTrack === '1' || navigator.doNotTrack === 'yes' ? 1 : 0); - expect(data.site).to.deep.equal({ - id: utils.getBidIdParameter('tagId', bidRequests[0].params), - page: utils.getTopWindowLocation().href, - domain: utils.getTopWindowLocation().host - }); - - expect(data.device.ua).to.equal(navigator.userAgent); - expect(data.device.h).to.equal(screen.height); - expect(data.device.w).to.equal(screen.width); - - expect(data.site.id).to.equal(bidRequests[0].params.tagId); - expect(data.site.page).to.equal(utils.getTopWindowLocation().href); - expect(data.site.domain).to.equal(utils.getTopWindowLocation().host); - }); - }); - - describe('interpretResponse', function () { - it('should handle no bid response', function () { - const response = spec.interpretResponse({ body: null }, { bidRequests }); - expect(response.length).to.equal(0); - }); - - it('should have at least one Seat Object', function () { - const request = spec.buildRequests(bidRequests); - const response = spec.interpretResponse(bidResponseEmptySeat, request); - expect(response.length).to.equal(0); - }); - - it('should have at least one Bid Object', function () { - const request = spec.buildRequests(bidRequests); - const response = spec.interpretResponse(bidResponseEmptyBid, request); - expect(response.length).to.equal(0); - }); - - it('should have impId in Bid Object', function () { - const request = spec.buildRequests(bidRequests); - const response = spec.interpretResponse(bidResponseNoImpId, request); - expect(response.length).to.equal(0); - }); - - it('should handle valid response', function () { - const request = spec.buildRequests(bidRequests); - const response = spec.interpretResponse(bidResponses, request); - expect(response).to.be.an('array').to.have.lengthOf(1); - - let bid = response[0]; - expect(bid).to.have.property('requestId', 'bid000'); - expect(bid).to.have.property('currency', 'USD'); - expect(bid).to.have.property('cpm', 0.99); - expect(bid).to.have.property('creativeId', 'cr-65981'); - expect(bid).to.have.property('width', 300); - expect(bid).to.have.property('height', 250); - expect(bid).to.have.property('ttl', 300); - expect(bid).to.have.property('ad', ''); - }); - }); - }); -}); diff --git a/test/spec/modules/ixBidAdapter_spec.js b/test/spec/modules/ixBidAdapter_spec.js index 245cf01610c1..f3fafed7b9ac 100644 --- a/test/spec/modules/ixBidAdapter_spec.js +++ b/test/spec/modules/ixBidAdapter_spec.js @@ -82,7 +82,7 @@ describe('IndexexchangeAdapter', function () { advbrandid: 303325, advbrand: 'OECTA' }, - adm: '
' + adm: '' } ], seat: '3970' @@ -126,8 +126,8 @@ describe('IndexexchangeAdapter', function () { vendorData: {} }, refererInfo: { - referer: 'http://www.prebid.org', - canonicalUrl: 'http://www.prebid.org/the/link/to/the/page' + referer: 'https://www.prebid.org', + canonicalUrl: 'https://www.prebid.org/the/link/to/the/page' } }; @@ -160,8 +160,8 @@ describe('IndexexchangeAdapter', function () { } ], site: { - ref: 'http://ref.com/ref.html', - page: 'http://page.com' + ref: 'https://ref.com/ref.html', + page: 'https://page.com' }, }), s: '21', @@ -775,7 +775,7 @@ describe('IndexexchangeAdapter', function () { width: 300, height: 250, mediaType: 'banner', - ad: '', + ad: '', currency: 'USD', ttl: 35, netRevenue: true, @@ -802,7 +802,7 @@ describe('IndexexchangeAdapter', function () { width: 300, height: 250, mediaType: 'banner', - ad: '', + ad: '', currency: 'USD', ttl: 35, netRevenue: true, @@ -828,7 +828,7 @@ describe('IndexexchangeAdapter', function () { width: 300, height: 250, mediaType: 'banner', - ad: '', + ad: '', currency: 'JPY', ttl: 35, netRevenue: true, @@ -855,7 +855,7 @@ describe('IndexexchangeAdapter', function () { width: 300, height: 250, mediaType: 'banner', - ad: '', + ad: '', currency: 'USD', ttl: 35, netRevenue: true, diff --git a/test/spec/modules/jcmBidAdapter_spec.js b/test/spec/modules/jcmBidAdapter_spec.js index 0b467e1ecfb1..fa6791674bcf 100644 --- a/test/spec/modules/jcmBidAdapter_spec.js +++ b/test/spec/modules/jcmBidAdapter_spec.js @@ -2,7 +2,7 @@ import { expect } from 'chai'; import { spec } from 'modules/jcmBidAdapter'; import { newBidder } from 'src/adapters/bidderFactory'; -const ENDPOINT = '//media.adfrontiers.com/'; +const ENDPOINT = 'https://media.adfrontiers.com/'; describe('jcmAdapter', function () { const adapter = newBidder(spec); @@ -124,7 +124,7 @@ describe('jcmAdapter', function () { expect(options).to.not.be.undefined; expect(options).to.have.lengthOf(1); expect(options[0].type).to.equal('iframe'); - expect(options[0].url).to.equal('//media.adfrontiers.com/hb/jcm_usersync.html'); + expect(options[0].url).to.equal('https://media.adfrontiers.com/hb/jcm_usersync.html'); }); it('Verifies sync image option', function () { @@ -133,7 +133,7 @@ describe('jcmAdapter', function () { expect(options).to.not.be.undefined; expect(options).to.have.lengthOf(1); expect(options[0].type).to.equal('image'); - expect(options[0].url).to.equal('//media.adfrontiers.com/hb/jcm_usersync.png'); + expect(options[0].url).to.equal('https://media.adfrontiers.com/hb/jcm_usersync.png'); }); }); }); diff --git a/test/spec/modules/komoonaBidAdapter_spec.js b/test/spec/modules/komoonaBidAdapter_spec.js index b6d17c7b20c1..ed84155b28d5 100644 --- a/test/spec/modules/komoonaBidAdapter_spec.js +++ b/test/spec/modules/komoonaBidAdapter_spec.js @@ -44,7 +44,7 @@ describe('Komoona.com Adapter Tests', function () { width: 300, height: 250, cpm: 0.51, - creative: '', + creative: '', ttl: 360, currency: 'USD', netRevenue: true, @@ -73,7 +73,7 @@ describe('Komoona.com Adapter Tests', function () { var startTime = new Date().getTime(); const request = spec.buildRequests(bidsRequest); - expect(request.url).to.equal('//bidder.komoona.com/v1/GetSBids'); + expect(request.url).to.equal('https://bidder.komoona.com/v1/GetSBids'); expect(request.method).to.equal('POST'); const requestData = JSON.parse(request.data); @@ -159,6 +159,6 @@ describe('Komoona.com Adapter Tests', function () { expect(options).to.not.be.undefined; expect(options).to.have.lengthOf(1); expect(options[0].type).to.equal('iframe'); - expect(options[0].url).to.equal('//s.komoona.com/sync/usync.html'); + expect(options[0].url).to.equal('https://s.komoona.com/sync/usync.html'); }); }); diff --git a/test/spec/modules/kummaBidAdapter_spec.js b/test/spec/modules/kummaBidAdapter_spec.js deleted file mode 100644 index 7d33bd085b5f..000000000000 --- a/test/spec/modules/kummaBidAdapter_spec.js +++ /dev/null @@ -1,335 +0,0 @@ -import {expect} from 'chai'; -import {spec} from 'modules/kummaBidAdapter'; -import {getTopWindowLocation} from 'src/utils'; -import {newBidder} from 'src/adapters/bidderFactory'; - -describe('Kumma Adapter Tests', function () { - const slotConfigs = [{ - placementCode: '/DfpAccount1/slot1', - sizes: [[300, 250]], - bidId: 'bid12345', - mediaType: 'banner', - params: { - pubId: '29521', - siteId: '26047', - placementId: '123', - bidFloor: '0.001', - ifa: 'IFA', - latitude: '40.712775', - longitude: '-74.005973' - } - }, { - placementCode: '/DfpAccount2/slot2', - sizes: [[728, 90]], - bidId: 'bid23456', - mediaType: 'banner', - params: { - pubId: '29521', - siteId: '26047', - placementId: '1234', - bidFloor: '0.000001', - } - }]; - const nativeSlotConfig = [{ - placementCode: '/DfpAccount1/slot3', - bidId: 'bid12345', - mediaType: 'native', - nativeParams: { - title: { required: true, len: 200 }, - body: {}, - image: { wmin: 100 }, - sponsoredBy: { }, - icon: { } - }, - params: { - pubId: '29521', - placementId: '123', - siteId: '26047' - } - }]; - const videoSlotConfig = [{ - placementCode: '/DfpAccount1/slot4', - sizes: [[640, 480]], - bidId: 'bid12345678', - mediaType: 'video', - video: { - skippable: true - }, - params: { - pubId: '29521', - placementId: '1234567', - siteId: '26047', - } - }]; - const appSlotConfig = [{ - placementCode: '/DfpAccount1/slot5', - bidId: 'bid12345', - params: { - pubId: '29521', - placementId: '1234', - app: { - id: '1111', - name: 'app name', - bundle: 'com.kumma.apps', - storeUrl: 'http://kumma.com/apps', - domain: 'kumma.com' - } - } - }]; - - it('Verify build request', function () { - const request = spec.buildRequests(slotConfigs); - expect(request.url).to.equal('//hb.kumma.com/'); - expect(request.method).to.equal('POST'); - const ortbRequest = JSON.parse(request.data); - // site object - expect(ortbRequest.site).to.not.equal(null); - expect(ortbRequest.site.publisher).to.not.equal(null); - expect(ortbRequest.site.publisher.id).to.equal('29521'); - expect(ortbRequest.site.ref).to.equal(window.top.document.referrer); - expect(ortbRequest.site.page).to.equal(getTopWindowLocation().href); - expect(ortbRequest.imp).to.have.lengthOf(2); - // device object - expect(ortbRequest.device).to.not.equal(null); - expect(ortbRequest.device.ua).to.equal(navigator.userAgent); - expect(ortbRequest.device.ifa).to.equal('IFA'); - expect(ortbRequest.device.geo.lat).to.equal('40.712775'); - expect(ortbRequest.device.geo.lon).to.equal('-74.005973'); - // slot 1 - expect(ortbRequest.imp[0].tagid).to.equal('123'); - expect(ortbRequest.imp[0].banner).to.not.equal(null); - expect(ortbRequest.imp[0].banner.w).to.equal(300); - expect(ortbRequest.imp[0].banner.h).to.equal(250); - expect(ortbRequest.imp[0].bidfloor).to.equal('0.001'); - // slot 2 - expect(ortbRequest.imp[1].tagid).to.equal('1234'); - expect(ortbRequest.imp[1].banner).to.not.equal(null); - expect(ortbRequest.imp[1].banner.w).to.equal(728); - expect(ortbRequest.imp[1].banner.h).to.equal(90); - expect(ortbRequest.imp[1].bidfloor).to.equal('0.000001'); - }); - - it('Verify parse response', function () { - const request = spec.buildRequests(slotConfigs); - const ortbRequest = JSON.parse(request.data); - const ortbResponse = { - seatbid: [{ - bid: [{ - impid: ortbRequest.imp[0].id, - price: 1.25, - adm: 'This is an Ad' - }] - }], - cur: 'USD' - }; - const bids = spec.interpretResponse({ body: ortbResponse }, request); - expect(bids).to.have.lengthOf(1); - // verify first bid - const bid = bids[0]; - expect(bid.cpm).to.equal(1.25); - expect(bid.ad).to.equal('This is an Ad'); - expect(bid.width).to.equal(300); - expect(bid.height).to.equal(250); - expect(bid.adId).to.equal('bid12345'); - expect(bid.creativeId).to.equal('bid12345'); - expect(bid.netRevenue).to.equal(true); - expect(bid.currency).to.equal('USD'); - expect(bid.ttl).to.equal(360); - }); - - it('Verify full passback', function () { - const request = spec.buildRequests(slotConfigs); - const bids = spec.interpretResponse({ body: null }, request) - expect(bids).to.have.lengthOf(0); - }); - - it('Verify Native request', function () { - const request = spec.buildRequests(nativeSlotConfig); - expect(request.url).to.equal('//hb.kumma.com/'); - expect(request.method).to.equal('POST'); - const ortbRequest = JSON.parse(request.data); - // native impression - expect(ortbRequest.imp[0].tagid).to.equal('123'); - const nativePart = ortbRequest.imp[0]['native']; - expect(nativePart).to.not.equal(null); - expect(nativePart.ver).to.equal('1.1'); - expect(nativePart.request).to.not.equal(null); - // native request assets - const nativeRequest = JSON.parse(ortbRequest.imp[0]['native'].request); - expect(nativeRequest).to.not.equal(null); - expect(nativeRequest.assets).to.have.lengthOf(5); - expect(nativeRequest.assets[0].id).to.equal(1); - expect(nativeRequest.assets[1].id).to.equal(2); - expect(nativeRequest.assets[2].id).to.equal(3); - expect(nativeRequest.assets[3].id).to.equal(4); - expect(nativeRequest.assets[4].id).to.equal(5); - expect(nativeRequest.assets[0].required).to.equal(1); - expect(nativeRequest.assets[0].title).to.not.equal(null); - expect(nativeRequest.assets[0].title.len).to.equal(200); - expect(nativeRequest.assets[1].title).to.be.undefined; - expect(nativeRequest.assets[1].data).to.not.equal(null); - expect(nativeRequest.assets[1].data.type).to.equal(2); - expect(nativeRequest.assets[1].data.len).to.equal(200); - expect(nativeRequest.assets[2].required).to.equal(0); - expect(nativeRequest.assets[3].img).to.not.equal(null); - expect(nativeRequest.assets[3].img.wmin).to.equal(50); - expect(nativeRequest.assets[3].img.hmin).to.equal(50); - expect(nativeRequest.assets[3].img.type).to.equal(1); - expect(nativeRequest.assets[4].img).to.not.equal(null); - expect(nativeRequest.assets[4].img.wmin).to.equal(100); - expect(nativeRequest.assets[4].img.hmin).to.equal(150); - expect(nativeRequest.assets[4].img.type).to.equal(3); - }); - - it('Verify Native response', function () { - const request = spec.buildRequests(nativeSlotConfig); - expect(request.url).to.equal('//hb.kumma.com/'); - expect(request.method).to.equal('POST'); - const ortbRequest = JSON.parse(request.data); - const nativeResponse = { - 'native': { - assets: [ - { id: 1, title: { text: 'Ad Title' } }, - { id: 2, data: { value: 'Test description' } }, - { id: 3, data: { value: 'Brand' } }, - { id: 4, img: { url: 'https://adx1public.s3.amazonaws.com/creatives_icon.png', w: 100, h: 100 } }, - { id: 5, img: { url: 'https://adx1public.s3.amazonaws.com/creatives_image.png', w: 300, h: 300 } } - ], - link: { url: 'http://brand.com/' } - } - }; - const ortbResponse = { - seatbid: [{ - bid: [{ - impid: ortbRequest.imp[0].id, - price: 1.25, - nurl: 'http://rtb.adx1.com/log', - adm: JSON.stringify(nativeResponse) - }] - }], - cur: 'USD', - }; - const bids = spec.interpretResponse({ body: ortbResponse }, request); - // verify bid - const bid = bids[0]; - expect(bid.cpm).to.equal(1.25); - expect(bid.adId).to.equal('bid12345'); - expect(bid.ad).to.be.undefined; - expect(bid.mediaType).to.equal('native'); - const nativeBid = bid['native']; - expect(nativeBid).to.not.equal(null); - expect(nativeBid.title).to.equal('Ad Title'); - expect(nativeBid.sponsoredBy).to.equal('Brand'); - expect(nativeBid.icon.url).to.equal('https://adx1public.s3.amazonaws.com/creatives_icon.png'); - expect(nativeBid.image.url).to.equal('https://adx1public.s3.amazonaws.com/creatives_image.png'); - expect(nativeBid.image.width).to.equal(300); - expect(nativeBid.image.height).to.equal(300); - expect(nativeBid.icon.width).to.equal(100); - expect(nativeBid.icon.height).to.equal(100); - expect(nativeBid.clickUrl).to.equal(encodeURIComponent('http://brand.com/')); - expect(nativeBid.impressionTrackers).to.have.lengthOf(1); - expect(nativeBid.impressionTrackers[0]).to.equal('http://rtb.adx1.com/log'); - }); - - it('Verify Video request', function () { - const request = spec.buildRequests(videoSlotConfig); - expect(request.url).to.equal('//hb.kumma.com/'); - expect(request.method).to.equal('POST'); - const videoRequest = JSON.parse(request.data); - // site object - expect(videoRequest.site).to.not.equal(null); - expect(videoRequest.site.publisher.id).to.equal('29521'); - expect(videoRequest.site.ref).to.equal(window.top.document.referrer); - expect(videoRequest.site.page).to.equal(getTopWindowLocation().href); - // device object - expect(videoRequest.device).to.not.equal(null); - expect(videoRequest.device.ua).to.equal(navigator.userAgent); - // slot 1 - expect(videoRequest.imp[0].tagid).to.equal('1234567'); - expect(videoRequest.imp[0].video).to.not.equal(null); - expect(videoRequest.imp[0].video.w).to.equal(640); - expect(videoRequest.imp[0].video.h).to.equal(480); - expect(videoRequest.imp[0].banner).to.equal(null); - expect(videoRequest.imp[0].native).to.equal(null); - }); - - it('Verify parse video response', function () { - const request = spec.buildRequests(videoSlotConfig); - const videoRequest = JSON.parse(request.data); - const videoResponse = { - seatbid: [{ - bid: [{ - impid: videoRequest.imp[0].id, - price: 1.90, - adm: 'http://vid.example.com/9876', - crid: '510511_754567308' - }] - }], - cur: 'USD' - }; - const bids = spec.interpretResponse({ body: videoResponse }, request); - expect(bids).to.have.lengthOf(1); - // verify first bid - const bid = bids[0]; - expect(bid.cpm).to.equal(1.90); - expect(bid.vastUrl).to.equal('http://vid.example.com/9876'); - expect(bid.crid).to.equal('510511_754567308'); - expect(bid.width).to.equal(640); - expect(bid.height).to.equal(480); - expect(bid.adId).to.equal('bid12345678'); - expect(bid.netRevenue).to.equal(true); - expect(bid.currency).to.equal('USD'); - expect(bid.ttl).to.equal(360); - }); - - it('Verifies bidder code', function () { - expect(spec.code).to.equal('kumma'); - }); - - it('Verifies supported media types', function () { - expect(spec.supportedMediaTypes).to.have.lengthOf(3); - expect(spec.supportedMediaTypes[0]).to.equal('banner'); - expect(spec.supportedMediaTypes[1]).to.equal('native'); - expect(spec.supportedMediaTypes[2]).to.equal('video'); - }); - - it('Verifies if bid request valid', function () { - expect(spec.isBidRequestValid(slotConfigs[0])).to.equal(true); - expect(spec.isBidRequestValid(slotConfigs[1])).to.equal(true); - expect(spec.isBidRequestValid(nativeSlotConfig[0])).to.equal(true); - expect(spec.isBidRequestValid(videoSlotConfig[0])).to.equal(true); - }); - - it('Verify app requests', function () { - const request = spec.buildRequests(appSlotConfig); - const ortbRequest = JSON.parse(request.data); - expect(ortbRequest.site).to.equal(null); - expect(ortbRequest.app).to.not.be.null; - expect(ortbRequest.app.publisher).to.not.equal(null); - expect(ortbRequest.app.publisher.id).to.equal('29521'); - expect(ortbRequest.app.id).to.equal('1111'); - expect(ortbRequest.app.name).to.equal('app name'); - expect(ortbRequest.app.bundle).to.equal('com.kumma.apps'); - expect(ortbRequest.app.storeurl).to.equal('http://kumma.com/apps'); - expect(ortbRequest.app.domain).to.equal('kumma.com'); - }); - - it('Verify GDPR', function () { - const bidderRequest = { - gdprConsent: { - gdprApplies: true, - consentString: 'serialized_gpdr_data' - } - }; - const request = spec.buildRequests(slotConfigs, bidderRequest); - expect(request.url).to.equal('//hb.kumma.com/'); - expect(request.method).to.equal('POST'); - const ortbRequest = JSON.parse(request.data); - expect(ortbRequest.user).to.not.equal(null); - expect(ortbRequest.user.ext).to.not.equal(null); - expect(ortbRequest.user.ext.consent).to.equal('serialized_gpdr_data'); - expect(ortbRequest.regs).to.not.equal(null); - expect(ortbRequest.regs.ext).to.not.equal(null); - expect(ortbRequest.regs.ext.gdpr).to.equal(1); - }); -}); diff --git a/test/spec/modules/lemmaBidAdapter_spec.js b/test/spec/modules/lemmaBidAdapter_spec.js deleted file mode 100644 index 624e763ebe1d..000000000000 --- a/test/spec/modules/lemmaBidAdapter_spec.js +++ /dev/null @@ -1,335 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/lemmaBidAdapter'; -import * as utils from 'src/utils'; -const constants = require('src/constants.json'); - -describe('lemmaBidAdapter', function() { - var bidRequests; - var videoBidRequests; - var bidResponses; - beforeEach(function() { - bidRequests = [{ - bidder: 'lemma', - mediaType: 'banner', - mediaTypes: { - banner: { - sizes: [ - [300, 250], - [300, 600] - ], - } - }, - params: { - pubId: 1001, - adunitId: 1, - currency: 'AUD', - geo: { - lat: '12.3', - lon: '23.7', - } - }, - sizes: [ - [300, 250], - [300, 600] - ] - }]; - videoBidRequests = [{ - code: 'video1', - mediaType: 'video', - mediaTypes: { - video: { - playerSize: [640, 480], - context: 'instream' - } - }, - bidder: 'lemma', - params: { - pubId: 1001, - adunitId: 1, - video: { - mimes: ['video/mp4', 'video/x-flv'], - skippable: true, - minduration: 5, - maxduration: 30 - } - } - }]; - bidResponses = { - 'body': { - 'id': '93D3BAD6-E2E2-49FB-9D89-920B1761C865', - 'seatbid': [{ - 'bid': [{ - 'id': '74858439-49D7-4169-BA5D-44A046315B2F', - 'impid': '22bddb28db77d', - 'price': 1.3, - 'adm': '

lemma"Connecting Advertisers and Publishers directly"

', - 'adomain': ['amazon.com'], - 'iurl': 'https://thetradedesk-t-general.s3.amazonaws.com/AdvertiserLogos/vgl908z.png', - 'cid': '22918', - 'crid': 'v55jutrh', - 'h': 250, - 'w': 300, - 'ext': {} - }] - }] - } - }; - }); - describe('implementation', function() { - describe('Bid validations', function() { - it('valid bid case', function() { - var validBid = { - bidder: 'lemma', - params: { - pubId: 1001, - adunitId: 1 - } - }, - isValid = spec.isBidRequestValid(validBid); - expect(isValid).to.equal(true); - }); - it('invalid bid case', function() { - var isValid = spec.isBidRequestValid(); - expect(isValid).to.equal(false); - }); - it('invalid bid case: pubId not passed', function() { - var validBid = { - bidder: 'lemma', - params: { - adunitId: 1 - } - }, - isValid = spec.isBidRequestValid(validBid); - expect(isValid).to.equal(false); - }); - it('invalid bid case: pubId is not number', function() { - var validBid = { - bidder: 'lemma', - params: { - pubId: '301', - adunitId: 1 - } - }, - isValid = spec.isBidRequestValid(validBid); - expect(isValid).to.equal(false); - }); - it('invalid bid case: adunitId is not passed', function() { - var validBid = { - bidder: 'lemma', - params: { - pubId: 1001 - } - }, - isValid = spec.isBidRequestValid(validBid); - expect(isValid).to.equal(false); - }); - it('invalid bid case: video bid request mimes is not passed', function() { - var validBid = { - bidder: 'lemma', - params: { - pubId: 1001, - adunitId: 1, - video: { - skippable: true, - minduration: 5, - maxduration: 30 - } - } - }, - isValid = spec.isBidRequestValid(validBid); - expect(isValid).to.equal(false); - validBid.params.video.mimes = []; - isValid = spec.isBidRequestValid(validBid); - expect(isValid).to.equal(false); - }); - }); - describe('Request formation', function() { - it('buildRequests function should not modify original bidRequests object', function() { - var originalBidRequests = utils.deepClone(bidRequests); - var request = spec.buildRequests(bidRequests); - expect(bidRequests).to.deep.equal(originalBidRequests); - }); - it('Endpoint checking', function() { - var request = spec.buildRequests(bidRequests); - expect(request.url).to.equal('//ads.lemmatechnologies.com/lemma/servad?pid=1001&aid=1'); - expect(request.method).to.equal('POST'); - }); - it('Request params check', function() { - var request = spec.buildRequests(bidRequests); - var data = JSON.parse(request.data); - expect(data.site.domain).to.be.a('string'); // domain should be set - expect(data.site.publisher.id).to.equal(bidRequests[0].params.pubId.toString()); // publisher Id - expect(data.imp[0].tagid).to.equal('1'); // tagid - expect(data.imp[0].bidfloorcur).to.equal(bidRequests[0].params.currency); - }); - it('Request params check without mediaTypes object', function() { - var bidRequests = [{ - bidder: 'lemma', - params: { - pubId: 1001, - adunitId: 1, - currency: 'AUD' - }, - sizes: [ - [300, 250], - [300, 600] - ] - }]; - var request = spec.buildRequests(bidRequests); - var data = JSON.parse(request.data); - expect(data.imp[0].banner.w).to.equal(300); // width - expect(data.imp[0].banner.h).to.equal(250); // height - expect(data.imp[0].banner.format).exist.and.to.be.an('array'); - expect(data.imp[0].banner.format[0]).exist.and.to.be.an('object'); - expect(data.imp[0].banner.format[0].w).to.equal(300); // width - expect(data.imp[0].banner.format[0].h).to.equal(600); // height - }); - it('Request params check: without tagId', function() { - delete bidRequests[0].params.adunitId; - var request = spec.buildRequests(bidRequests); - var data = JSON.parse(request.data); - expect(data.site.domain).to.be.a('string'); // domain should be set - expect(data.site.publisher.id).to.equal(bidRequests[0].params.pubId.toString()); // publisher Id - expect(data.imp[0].tagid).to.equal(undefined); // tagid - expect(data.imp[0].bidfloorcur).to.equal(bidRequests[0].params.currency); - }); - it('Request params multi size format object check', function() { - var bidRequests = [{ - bidder: 'lemma', - mediaTypes: { - banner: { - sizes: [ - [300, 250], - [300, 600] - ], - } - }, - params: { - pubId: 1001, - adunitId: 1, - currency: 'AUD' - }, - sizes: [ - [300, 250], - [300, 600] - ] - }]; - /* case 1 - size passed in adslot */ - var request = spec.buildRequests(bidRequests); - var data = JSON.parse(request.data); - expect(data.imp[0].banner.w).to.equal(300); // width - expect(data.imp[0].banner.h).to.equal(250); // height - /* case 2 - size passed in adslot as well as in sizes array */ - bidRequests[0].sizes = [ - [300, 600], - [300, 250] - ]; - bidRequests[0].mediaTypes = { - banner: { - sizes: [ - [300, 600], - [300, 250] - ] - } - }; - request = spec.buildRequests(bidRequests); - data = JSON.parse(request.data); - expect(data.imp[0].banner.w).to.equal(300); // width - expect(data.imp[0].banner.h).to.equal(600); // height - /* case 3 - size passed in sizes but not in adslot */ - bidRequests[0].params.adunitId = 1; - bidRequests[0].sizes = [ - [300, 250], - [300, 600] - ]; - bidRequests[0].mediaTypes = { - banner: { - sizes: [ - [300, 250], - [300, 600] - ] - } - }; - request = spec.buildRequests(bidRequests); - data = JSON.parse(request.data); - expect(data.imp[0].banner.w).to.equal(300); // width - expect(data.imp[0].banner.h).to.equal(250); // height - expect(data.imp[0].banner.format).exist.and.to.be.an('array'); - expect(data.imp[0].banner.format[0]).exist.and.to.be.an('object'); - expect(data.imp[0].banner.format[0].w).to.equal(300); // width - expect(data.imp[0].banner.format[0].h).to.equal(250); // height - }); - it('Request params currency check', function() { - var bidRequest = [{ - bidder: 'lemma', - mediaTypes: { - banner: { - sizes: [ - [300, 250], - [300, 600] - ], - } - }, - params: { - pubId: 1001, - adunitId: 1, - currency: 'AUD' - }, - sizes: [ - [300, 250], - [300, 600] - ] - }]; - /* case 1 - - currency specified in adunits - output: imp[0] use currency specified in bidRequests[0].params.currency - */ - var request = spec.buildRequests(bidRequest); - var data = JSON.parse(request.data); - expect(data.imp[0].bidfloorcur).to.equal(bidRequests[0].params.currency); - /* case 2 - - currency specified in adunit - output: imp[0] use default currency - USD - */ - delete bidRequest[0].params.currency; - request = spec.buildRequests(bidRequest); - data = JSON.parse(request.data); - expect(data.imp[0].bidfloorcur).to.equal('USD'); - }); - it('Request params check for video ad', function() { - var request = spec.buildRequests(videoBidRequests); - var data = JSON.parse(request.data); - expect(data.imp[0].video).to.exist; - expect(data.imp[0].tagid).to.equal('1'); - expect(data.imp[0]['video']['mimes']).to.exist.and.to.be.an('array'); - expect(data.imp[0]['video']['mimes'][0]).to.equal(videoBidRequests[0].params.video['mimes'][0]); - expect(data.imp[0]['video']['mimes'][1]).to.equal(videoBidRequests[0].params.video['mimes'][1]); - expect(data.imp[0]['video']['minduration']).to.equal(videoBidRequests[0].params.video['minduration']); - expect(data.imp[0]['video']['maxduration']).to.equal(videoBidRequests[0].params.video['maxduration']); - expect(data.imp[0]['video']['w']).to.equal(videoBidRequests[0].mediaTypes.video.playerSize[0]); - expect(data.imp[0]['video']['h']).to.equal(videoBidRequests[0].mediaTypes.video.playerSize[1]); - }); - describe('Response checking', function() { - it('should check for valid response values', function() { - var request = spec.buildRequests(bidRequests); - var data = JSON.parse(request.data); - var response = spec.interpretResponse(bidResponses, request); - expect(response).to.be.an('array').with.length.above(0); - expect(response[0].requestId).to.equal(bidResponses.body.seatbid[0].bid[0].impid); - expect(response[0].cpm).to.equal((bidResponses.body.seatbid[0].bid[0].price).toFixed(2)); - expect(response[0].width).to.equal(bidResponses.body.seatbid[0].bid[0].w); - expect(response[0].height).to.equal(bidResponses.body.seatbid[0].bid[0].h); - if (bidResponses.body.seatbid[0].bid[0].crid) { - expect(response[0].creativeId).to.equal(bidResponses.body.seatbid[0].bid[0].crid); - } else { - expect(response[0].creativeId).to.equal(bidResponses.body.seatbid[0].bid[0].id); - } - expect(response[0].dealId).to.equal(bidResponses.body.seatbid[0].bid[0].dealid); - expect(response[0].currency).to.equal('USD'); - expect(response[0].netRevenue).to.equal(false); - expect(response[0].ttl).to.equal(300); - }); - }); - }); - }); -}); diff --git a/test/spec/modules/lifestreetBidAdapter_spec.js b/test/spec/modules/lifestreetBidAdapter_spec.js deleted file mode 100644 index 7f8c5f6c44d7..000000000000 --- a/test/spec/modules/lifestreetBidAdapter_spec.js +++ /dev/null @@ -1,222 +0,0 @@ -import {expect} from 'chai'; -import * as utils from 'src/utils'; -import {spec} from 'modules/lifestreetBidAdapter'; -import {config} from 'src/config'; - -let getDefaultBidRequest = () => { - return { - bidderCode: 'lifestreet', - auctionId: 'd3e07445-ab06-44c8-a9dd-5ef9af06d2a6', - bidderRequestId: '7101db09af0dg2', - start: new Date().getTime(), - bids: [{ - bidder: 'lifestreet', - bidId: '84ab500420329d', - bidderRequestId: '7101db09af0dg2', - auctionId: 'd3e07445-ab06-44c8-a9dd-5ef9af06d2a6', - placementCode: 'foo', - params: getBidParams() - }] - }; -}; - -let getVASTAd = () => { - return ` - - - Lifestreet wrapper - - - - - - `; -}; - -let getBidParams = () => { - return { - slot: 'slot166704', - adkey: '78c', - ad_size: '160x600' - }; -}; - -let getDefaultBidResponse = (isBanner, noBid = 0) => { - let noBidContent = isBanner ? '{"advertisementAvailable": false}' : ''; - let content = isBanner ? '' : getVASTAd(); - return { - status: noBid ? 0 : 1, - cpm: 1.0, - width: 160, - height: 600, - creativeId: 'test', - dealId: 'test', - content: noBid ? noBidContent : content, - content_type: isBanner ? 'display' : 'vast_2_0' - }; -}; - -describe('LifestreetAdapter', function () { - const LIFESTREET_URL = '//ads.lfstmedia.com/gate/'; - const ADAPTER_VERSION = 'prebidJS-2.0'; - - describe('buildRequests()', function () { - it('method exists and is a function', function () { - expect(spec.buildRequests).to.exist.and.to.be.a('function'); - }); - - it('should not return request when no bids are present', function () { - let [request] = spec.buildRequests([]); - expect(request).to.be.undefined; - }); - - let bidRequest = getDefaultBidRequest(); - let [request] = spec.buildRequests(bidRequest.bids); - it('should return request for Lifestreet endpoint', function () { - expect(request.url).to.contain(LIFESTREET_URL); - }); - - it('should use json adapter', function () { - expect(request.url).to.contain('/prebid/'); - }); - - it('should contain slot', function () { - expect(request.url).to.contain('slot166704'); - }); - it('should contain adkey', function () { - expect(request.url).to.contain('adkey=78c'); - }); - it('should contain ad_size', function () { - expect(request.url).to.contain('ad_size=160x600'); - }); - - it('should contain location and rferrer paramters', function () { - expect(request.url).to.contain('__location='); - expect(request.url).to.contain('__referrer='); - }); - it('should contain info parameters', function () { - expect(request.url).to.contain('__wn='); - expect(request.url).to.contain('__sf='); - expect(request.url).to.contain('__fif='); - expect(request.url).to.contain('__if='); - expect(request.url).to.contain('__stamp='); - expect(request.url).to.contain('__pp='); - }); - - it('should contain HB enabled', function () { - expect(request.url).to.contain('__hb=1'); - }); - it('should include gzip', function () { - expect(request.url).to.contain('__gz=1'); - }); - it('should not contain __gdpr parameter', function () { - expect(request.url).to.not.contain('__gdpr'); - }); - it('should not contain __concent parameter', function () { - expect(request.url).to.not.contain('__consent'); - }); - - it('should contain the right version of adapter', function () { - expect(request.url).to.contain('__hbver=' + ADAPTER_VERSION); - }); - - it('should contain __gdpr and __consent parameters', function () { - const options = { - gdprConsent: { - gdprApplies: true, - consentString: 'test', - vendorData: {} - } - }; - let [request] = spec.buildRequests(bidRequest.bids, options); - expect(request.url).to.contain('__gdpr=1'); - expect(request.url).to.contain('__consent=test'); - }); - it('should contain __gdpr parameters', function () { - const options = { - gdprConsent: { - gdprApplies: true, - vendorData: {} - } - }; - let [request] = spec.buildRequests(bidRequest.bids, options); - expect(request.url).to.contain('__gdpr=1'); - expect(request.url).to.not.contain('__consent'); - }); - it('should contain __consent parameters', function () { - const options = { - gdprConsent: { - consentString: 'test', - vendorData: {} - } - }; - let [request] = spec.buildRequests(bidRequest.bids, options); - expect(request.url).to.not.contain('__gdpr'); - expect(request.url).to.contain('__consent=test'); - }); - }); - describe('interpretResponse()', function () { - it('should return formatted bid response with required properties', function () { - let bidRequest = getDefaultBidRequest().bids[0]; - let bidResponse = { body: getDefaultBidResponse(true) }; - let formattedBidResponse = spec.interpretResponse(bidResponse, bidRequest); - expect(formattedBidResponse).to.deep.equal([{ - requestId: bidRequest.bidId, - cpm: 1.0, - width: 160, - height: 600, - ad: '', - creativeId: 'test', - currency: 'USD', - dealId: 'test', - netRevenue: true, - ttl: 86400, - mediaType: 'banner' - }]); - }); - it('should return formatted VAST bid response with required properties', function () { - let bidRequest = getDefaultBidRequest().bids[0]; - let bidResponse = { body: getDefaultBidResponse(false) }; - let formattedBidResponse = spec.interpretResponse(bidResponse, bidRequest); - expect(formattedBidResponse).to.deep.equal([{ - requestId: bidRequest.bidId, - cpm: 1.0, - width: 160, - height: 600, - vastXml: getVASTAd(), - creativeId: 'test', - currency: 'USD', - dealId: 'test', - netRevenue: true, - ttl: 86400, - mediaType: 'video' - }]); - }); - it('should return formatted VAST bid response with vastUrl', function () { - let bidRequest = getDefaultBidRequest().bids[0]; - let bidResponse = { body: getDefaultBidResponse(false) }; - bidResponse.body.vastUrl = 'http://lifestreet.com'; // set vastUrl - let formattedBidResponse = spec.interpretResponse(bidResponse, bidRequest); - expect(formattedBidResponse).to.deep.equal([{ - requestId: bidRequest.bidId, - cpm: 1.0, - width: 160, - height: 600, - vastUrl: 'http://lifestreet.com', - creativeId: 'test', - currency: 'USD', - dealId: 'test', - netRevenue: true, - ttl: 86400, - mediaType: 'video' - }]); - }); - - it('should return no-bid', function () { - let bidRequest = getDefaultBidRequest().bids[0]; - let bidResponse = { body: getDefaultBidResponse(true, true) }; - let formattedBidResponse = spec.interpretResponse(bidResponse, bidRequest); - expect(formattedBidResponse).to.be.empty; - }); - }); -}); diff --git a/test/spec/modules/livewrappedAnalyticsAdapter_spec.js b/test/spec/modules/livewrappedAnalyticsAdapter_spec.js index 611ff95a036c..649b85b9c07c 100644 --- a/test/spec/modules/livewrappedAnalyticsAdapter_spec.js +++ b/test/spec/modules/livewrappedAnalyticsAdapter_spec.js @@ -258,7 +258,7 @@ describe('Livewrapped analytics adapter', function () { expect(requests.length).to.equal(1); let request = requests[0]; - expect(request.url).to.equal('//lwadm.com/analytics/10'); + expect(request.url).to.equal('https://lwadm.com/analytics/10'); let message = JSON.parse(request.requestBody); diff --git a/test/spec/modules/livewrappedBidAdapter_spec.js b/test/spec/modules/livewrappedBidAdapter_spec.js deleted file mode 100644 index 6db8bff4c3dd..000000000000 --- a/test/spec/modules/livewrappedBidAdapter_spec.js +++ /dev/null @@ -1,835 +0,0 @@ -import {expect} from 'chai'; -import {spec} from 'modules/livewrappedBidAdapter'; -import {config} from 'src/config'; -import * as utils from 'src/utils'; - -describe('Livewrapped adapter tests', function () { - let sandbox, - bidderRequest; - - beforeEach(function () { - sandbox = sinon.sandbox.create(); - - bidderRequest = { - bidderCode: 'livewrapped', - auctionId: 'c45dd708-a418-42ec-b8a7-b70a6c6fab0a', - bidderRequestId: '178e34bad3658f', - bids: [ - { - bidder: 'livewrapped', - params: { - adUnitId: '9E153CED-61BC-479E-98DF-24DC0D01BA37', - publisherId: '26947112-2289-405D-88C1-A7340C57E63E', - userId: 'user id', - url: 'http://www.domain.com', - seats: {'dsp': ['seat 1']} - }, - adUnitCode: 'panorama_d_1', - sizes: [[980, 240], [980, 120]], - bidId: '2ffb201a808da7', - bidderRequestId: '178e34bad3658f', - auctionId: 'F7557995-65F5-4682-8782-7D5D34D82A8C', - transactionId: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D' - } - ], - start: 1472239426002, - auctionStart: 1472239426000, - timeout: 5000 - }; - }); - - afterEach(function () { - sandbox.restore(); - }); - - describe('isBidRequestValid', function() { - it('should accept a request with id only as valid', function() { - let bid = {params: {adUnitId: '9E153CED-61BC-479E-98DF-24DC0D01BA37'}}; - - let result = spec.isBidRequestValid(bid); - - expect(result).to.be.true; - }); - - it('should accept a request with adUnitName and PublisherId as valid', function() { - let bid = {params: {adUnitName: 'panorama_d_1', publisherId: '26947112-2289-405D-88C1-A7340C57E63E'}}; - - let result = spec.isBidRequestValid(bid); - - expect(result).to.be.true; - }); - - it('should accept a request with adUnitCode and PublisherId as valid', function() { - let bid = {adUnitCode: 'panorama_d_1', params: {publisherId: '26947112-2289-405D-88C1-A7340C57E63E'}}; - - let result = spec.isBidRequestValid(bid); - - expect(result).to.be.true; - }); - - it('should accept a request with placementCode and PublisherId as valid', function() { - let bid = {placementCode: 'panorama_d_1', params: {publisherId: '26947112-2289-405D-88C1-A7340C57E63E'}}; - - let result = spec.isBidRequestValid(bid); - - expect(result).to.be.true; - }); - - it('should not accept a request with adUnitName, adUnitCode, placementCode but no PublisherId as valid', function() { - let bid = {placementCode: 'panorama_d_1', adUnitCode: 'panorama_d_1', params: {adUnitName: 'panorama_d_1'}}; - - let result = spec.isBidRequestValid(bid); - - expect(result).to.be.false; - }); - }); - - describe('buildRequests', function() { - it('should make a well-formed single request object', function() { - sandbox.stub(utils, 'isSafariBrowser').callsFake(() => false); - sandbox.stub(utils, 'cookiesAreEnabled').callsFake(() => true); - let result = spec.buildRequests(bidderRequest.bids, bidderRequest); - let data = JSON.parse(result.data); - - expect(result.url).to.equal('//lwadm.com/ad'); - - let expectedQuery = { - auctionId: 'F7557995-65F5-4682-8782-7D5D34D82A8C', - publisherId: '26947112-2289-405D-88C1-A7340C57E63E', - userId: 'user id', - url: 'http://www.domain.com', - seats: {'dsp': ['seat 1']}, - version: '1.1', - cookieSupport: true, - adRequests: [{ - adUnitId: '9E153CED-61BC-479E-98DF-24DC0D01BA37', - callerAdUnitId: 'panorama_d_1', - bidId: '2ffb201a808da7', - transactionId: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D', - formats: [{width: 980, height: 240}, {width: 980, height: 120}] - }] - }; - - expect(data).to.deep.equal(expectedQuery); - }); - - it('should make a well-formed multiple request object', function() { - sandbox.stub(utils, 'isSafariBrowser').callsFake(() => false); - sandbox.stub(utils, 'cookiesAreEnabled').callsFake(() => true); - let multiplebidRequest = clone(bidderRequest); - multiplebidRequest.bids.push(clone(bidderRequest.bids[0])); - multiplebidRequest.bids[1].adUnitCode = 'box_d_1'; - multiplebidRequest.bids[1].sizes = [[300, 250]]; - multiplebidRequest.bids[1].bidId = '3ffb201a808da7'; - delete multiplebidRequest.bids[1].params.adUnitId; - - let result = spec.buildRequests(multiplebidRequest.bids, multiplebidRequest); - let data = JSON.parse(result.data); - - expect(result.url).to.equal('//lwadm.com/ad'); - - let expectedQuery = { - auctionId: 'F7557995-65F5-4682-8782-7D5D34D82A8C', - publisherId: '26947112-2289-405D-88C1-A7340C57E63E', - userId: 'user id', - url: 'http://www.domain.com', - seats: {'dsp': ['seat 1']}, - version: '1.1', - cookieSupport: true, - adRequests: [{ - adUnitId: '9E153CED-61BC-479E-98DF-24DC0D01BA37', - callerAdUnitId: 'panorama_d_1', - bidId: '2ffb201a808da7', - transactionId: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D', - formats: [{width: 980, height: 240}, {width: 980, height: 120}] - }, { - callerAdUnitId: 'box_d_1', - bidId: '3ffb201a808da7', - transactionId: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D', - formats: [{width: 300, height: 250}] - }] - }; - - expect(data).to.deep.equal(expectedQuery); - }); - - it('should make a well-formed single request object with AdUnitName', function() { - sandbox.stub(utils, 'isSafariBrowser').callsFake(() => false); - sandbox.stub(utils, 'cookiesAreEnabled').callsFake(() => true); - let testbidRequest = clone(bidderRequest); - testbidRequest.bids[0].params.adUnitName = 'caller id 1'; - delete testbidRequest.bids[0].params.adUnitId; - let result = spec.buildRequests(testbidRequest.bids, testbidRequest); - let data = JSON.parse(result.data); - - expect(result.url).to.equal('//lwadm.com/ad'); - - let expectedQuery = { - auctionId: 'F7557995-65F5-4682-8782-7D5D34D82A8C', - publisherId: '26947112-2289-405D-88C1-A7340C57E63E', - userId: 'user id', - url: 'http://www.domain.com', - seats: {'dsp': ['seat 1']}, - version: '1.1', - cookieSupport: true, - adRequests: [{ - callerAdUnitId: 'caller id 1', - bidId: '2ffb201a808da7', - transactionId: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D', - formats: [{width: 980, height: 240}, {width: 980, height: 120}] - }] - }; - - expect(data).to.deep.equal(expectedQuery); - }); - - it('should make a well-formed single request object with less parameters', function() { - sandbox.stub(utils, 'isSafariBrowser').callsFake(() => false); - sandbox.stub(utils, 'cookiesAreEnabled').callsFake(() => true); - let testbidRequest = clone(bidderRequest); - delete testbidRequest.bids[0].params.userId; - delete testbidRequest.bids[0].params.seats; - delete testbidRequest.bids[0].params.adUnitId; - let result = spec.buildRequests(testbidRequest.bids, testbidRequest); - let data = JSON.parse(result.data); - - expect(result.url).to.equal('//lwadm.com/ad'); - - let expectedQuery = { - auctionId: 'F7557995-65F5-4682-8782-7D5D34D82A8C', - publisherId: '26947112-2289-405D-88C1-A7340C57E63E', - url: 'http://www.domain.com', - version: '1.1', - cookieSupport: true, - adRequests: [{ - callerAdUnitId: 'panorama_d_1', - bidId: '2ffb201a808da7', - transactionId: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D', - formats: [{width: 980, height: 240}, {width: 980, height: 120}] - }] - }; - - expect(data).to.deep.equal(expectedQuery); - }); - - it('should make a well-formed single request object with less parameters, no publisherId', function() { - sandbox.stub(utils, 'isSafariBrowser').callsFake(() => false); - sandbox.stub(utils, 'cookiesAreEnabled').callsFake(() => true); - let testbidRequest = clone(bidderRequest); - delete testbidRequest.bids[0].params.userId; - delete testbidRequest.bids[0].params.seats; - delete testbidRequest.bids[0].params.publisherId; - let result = spec.buildRequests(testbidRequest.bids, testbidRequest); - let data = JSON.parse(result.data); - - expect(result.url).to.equal('//lwadm.com/ad'); - - let expectedQuery = { - auctionId: 'F7557995-65F5-4682-8782-7D5D34D82A8C', - url: 'http://www.domain.com', - version: '1.1', - cookieSupport: true, - adRequests: [{ - adUnitId: '9E153CED-61BC-479E-98DF-24DC0D01BA37', - callerAdUnitId: 'panorama_d_1', - bidId: '2ffb201a808da7', - transactionId: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D', - formats: [{width: 980, height: 240}, {width: 980, height: 120}] - }] - }; - - expect(data).to.deep.equal(expectedQuery); - }); - - it('should make a well-formed single request object with app parameters', function() { - sandbox.stub(utils, 'isSafariBrowser').callsFake(() => false); - sandbox.stub(utils, 'cookiesAreEnabled').callsFake(() => true); - let testbidRequest = clone(bidderRequest); - delete testbidRequest.bids[0].params.userId; - delete testbidRequest.bids[0].params.seats; - delete testbidRequest.bids[0].params.adUnitId; - testbidRequest.bids[0].params.deviceId = 'deviceid'; - testbidRequest.bids[0].params.ifa = 'ifa'; - let result = spec.buildRequests(testbidRequest.bids, testbidRequest); - let data = JSON.parse(result.data); - - let expectedQuery = { - auctionId: 'F7557995-65F5-4682-8782-7D5D34D82A8C', - publisherId: '26947112-2289-405D-88C1-A7340C57E63E', - url: 'http://www.domain.com', - version: '1.1', - deviceId: 'deviceid', - ifa: 'ifa', - cookieSupport: true, - adRequests: [{ - callerAdUnitId: 'panorama_d_1', - bidId: '2ffb201a808da7', - transactionId: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D', - formats: [{width: 980, height: 240}, {width: 980, height: 120}] - }] - }; - - expect(data).to.deep.equal(expectedQuery); - }); - - it('should make a well-formed single request object with debug parameters', function() { - sandbox.stub(utils, 'isSafariBrowser').callsFake(() => false); - sandbox.stub(utils, 'cookiesAreEnabled').callsFake(() => true); - let testbidRequest = clone(bidderRequest); - delete testbidRequest.bids[0].params.userId; - delete testbidRequest.bids[0].params.seats; - delete testbidRequest.bids[0].params.adUnitId; - testbidRequest.bids[0].params.tid = 'tracking id'; - testbidRequest.bids[0].params.test = true; - let result = spec.buildRequests(testbidRequest.bids, testbidRequest); - let data = JSON.parse(result.data); - - let expectedQuery = { - auctionId: 'F7557995-65F5-4682-8782-7D5D34D82A8C', - publisherId: '26947112-2289-405D-88C1-A7340C57E63E', - url: 'http://www.domain.com', - version: '1.1', - tid: 'tracking id', - test: true, - cookieSupport: true, - adRequests: [{ - callerAdUnitId: 'panorama_d_1', - bidId: '2ffb201a808da7', - transactionId: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D', - formats: [{width: 980, height: 240}, {width: 980, height: 120}] - }] - }; - - expect(data).to.deep.equal(expectedQuery); - }); - - it('should make a well-formed single request object with optional parameters', function() { - sandbox.stub(utils, 'isSafariBrowser').callsFake(() => false); - sandbox.stub(utils, 'cookiesAreEnabled').callsFake(() => true); - let testbidRequest = clone(bidderRequest); - delete testbidRequest.bids[0].params.userId; - delete testbidRequest.bids[0].params.seats; - delete testbidRequest.bids[0].params.adUnitId; - testbidRequest.bids[0].params.options = {keyvalues: [{key: 'key', value: 'value'}]}; - let result = spec.buildRequests(testbidRequest.bids, testbidRequest); - let data = JSON.parse(result.data); - - let expectedQuery = { - auctionId: 'F7557995-65F5-4682-8782-7D5D34D82A8C', - publisherId: '26947112-2289-405D-88C1-A7340C57E63E', - url: 'http://www.domain.com', - version: '1.1', - cookieSupport: true, - adRequests: [{ - callerAdUnitId: 'panorama_d_1', - bidId: '2ffb201a808da7', - transactionId: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D', - formats: [{width: 980, height: 240}, {width: 980, height: 120}], - options: {keyvalues: [{key: 'key', value: 'value'}]} - }] - }; - - expect(data).to.deep.equal(expectedQuery); - }); - - it('should make a well-formed single request object with ad blocker revovered parameter', function() { - sandbox.stub(utils, 'getWindowTop').returns({ I12C: { Morph: 1 } }); - sandbox.stub(utils, 'isSafariBrowser').callsFake(() => false); - sandbox.stub(utils, 'cookiesAreEnabled').callsFake(() => true); - let testbidRequest = clone(bidderRequest); - delete testbidRequest.bids[0].params.userId; - delete testbidRequest.bids[0].params.seats; - delete testbidRequest.bids[0].params.adUnitId; - let result = spec.buildRequests(testbidRequest.bids, testbidRequest); - let data = JSON.parse(result.data); - - let expectedQuery = { - auctionId: 'F7557995-65F5-4682-8782-7D5D34D82A8C', - publisherId: '26947112-2289-405D-88C1-A7340C57E63E', - url: 'http://www.domain.com', - version: '1.1', - cookieSupport: true, - rcv: true, - adRequests: [{ - callerAdUnitId: 'panorama_d_1', - bidId: '2ffb201a808da7', - transactionId: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D', - formats: [{width: 980, height: 240}, {width: 980, height: 120}] - }] - }; - - expect(data).to.deep.equal(expectedQuery); - }); - - it('should pass gdpr true parameters', function() { - sandbox.stub(utils, 'isSafariBrowser').callsFake(() => false); - sandbox.stub(utils, 'cookiesAreEnabled').callsFake(() => true); - let testRequest = clone(bidderRequest); - testRequest.gdprConsent = { - gdprApplies: true, - consentString: 'test' - }; - let result = spec.buildRequests(testRequest.bids, testRequest); - let data = JSON.parse(result.data); - - expect(result.url).to.equal('//lwadm.com/ad'); - - let expectedQuery = { - auctionId: 'F7557995-65F5-4682-8782-7D5D34D82A8C', - publisherId: '26947112-2289-405D-88C1-A7340C57E63E', - userId: 'user id', - url: 'http://www.domain.com', - seats: {'dsp': ['seat 1']}, - version: '1.1', - cookieSupport: true, - gdprApplies: true, - gdprConsent: 'test', - adRequests: [{ - adUnitId: '9E153CED-61BC-479E-98DF-24DC0D01BA37', - callerAdUnitId: 'panorama_d_1', - bidId: '2ffb201a808da7', - transactionId: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D', - formats: [{width: 980, height: 240}, {width: 980, height: 120}] - }] - }; - - expect(data).to.deep.equal(expectedQuery); - }); - - it('should pass gdpr false parameters', function() { - sandbox.stub(utils, 'isSafariBrowser').callsFake(() => false); - sandbox.stub(utils, 'cookiesAreEnabled').callsFake(() => true); - let testRequest = clone(bidderRequest); - testRequest.gdprConsent = { - gdprApplies: false - }; - let result = spec.buildRequests(testRequest.bids, testRequest); - let data = JSON.parse(result.data); - - expect(result.url).to.equal('//lwadm.com/ad'); - - let expectedQuery = { - auctionId: 'F7557995-65F5-4682-8782-7D5D34D82A8C', - publisherId: '26947112-2289-405D-88C1-A7340C57E63E', - userId: 'user id', - url: 'http://www.domain.com', - seats: {'dsp': ['seat 1']}, - version: '1.1', - cookieSupport: true, - gdprApplies: false, - adRequests: [{ - adUnitId: '9E153CED-61BC-479E-98DF-24DC0D01BA37', - callerAdUnitId: 'panorama_d_1', - bidId: '2ffb201a808da7', - transactionId: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D', - formats: [{width: 980, height: 240}, {width: 980, height: 120}] - }] - }; - - expect(data).to.deep.equal(expectedQuery); - }); - - it('should pass no cookie support', function() { - sandbox.stub(utils, 'cookiesAreEnabled').callsFake(() => false); - sandbox.stub(utils, 'isSafariBrowser').callsFake(() => false); - let result = spec.buildRequests(bidderRequest.bids, bidderRequest); - let data = JSON.parse(result.data); - - expect(result.url).to.equal('//lwadm.com/ad'); - - let expectedQuery = { - auctionId: 'F7557995-65F5-4682-8782-7D5D34D82A8C', - publisherId: '26947112-2289-405D-88C1-A7340C57E63E', - userId: 'user id', - url: 'http://www.domain.com', - seats: {'dsp': ['seat 1']}, - version: '1.1', - cookieSupport: false, - adRequests: [{ - adUnitId: '9E153CED-61BC-479E-98DF-24DC0D01BA37', - callerAdUnitId: 'panorama_d_1', - bidId: '2ffb201a808da7', - transactionId: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D', - formats: [{width: 980, height: 240}, {width: 980, height: 120}] - }] - }; - - expect(data).to.deep.equal(expectedQuery); - }); - - it('should pass no cookie support Safari', function() { - sandbox.stub(utils, 'cookiesAreEnabled').callsFake(() => true); - sandbox.stub(utils, 'isSafariBrowser').callsFake(() => true); - let result = spec.buildRequests(bidderRequest.bids, bidderRequest); - let data = JSON.parse(result.data); - - expect(result.url).to.equal('//lwadm.com/ad'); - - let expectedQuery = { - auctionId: 'F7557995-65F5-4682-8782-7D5D34D82A8C', - publisherId: '26947112-2289-405D-88C1-A7340C57E63E', - userId: 'user id', - url: 'http://www.domain.com', - seats: {'dsp': ['seat 1']}, - version: '1.1', - cookieSupport: false, - adRequests: [{ - adUnitId: '9E153CED-61BC-479E-98DF-24DC0D01BA37', - callerAdUnitId: 'panorama_d_1', - bidId: '2ffb201a808da7', - transactionId: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D', - formats: [{width: 980, height: 240}, {width: 980, height: 120}] - }] - }; - - expect(data).to.deep.equal(expectedQuery); - }); - - it('should use params.url, then config pageUrl, then getTopWindowUrl', function() { - let testRequest = clone(bidderRequest); - sandbox.stub(utils, 'getTopWindowUrl').callsFake(() => 'http://www.topurl.com'); - - let result = spec.buildRequests(testRequest.bids, testRequest); - let data = JSON.parse(result.data); - - expect(data.url).to.equal('http://www.domain.com'); - - delete testRequest.bids[0].params.url; - - result = spec.buildRequests(testRequest.bids, testRequest); - data = JSON.parse(result.data); - - expect(data.url).to.equal('http://www.topurl.com'); - - let origGetConfig = config.getConfig; - sandbox.stub(config, 'getConfig').callsFake(function (key) { - if (key === 'pageUrl') { - return 'http://www.configurl.com'; - } - return origGetConfig.apply(config, arguments); - }); - - result = spec.buildRequests(testRequest.bids, testRequest); - data = JSON.parse(result.data); - - expect(data.url).to.equal('http://www.configurl.com'); - }); - - it('should make use of pubcid if available', function() { - sandbox.stub(utils, 'isSafariBrowser').callsFake(() => false); - sandbox.stub(utils, 'cookiesAreEnabled').callsFake(() => true); - let testbidRequest = clone(bidderRequest); - delete testbidRequest.bids[0].params.userId; - testbidRequest.bids[0].crumbs = {pubcid: 'pubcid 123'}; - let result = spec.buildRequests(testbidRequest.bids, testbidRequest); - let data = JSON.parse(result.data); - - expect(result.url).to.equal('//lwadm.com/ad'); - - let expectedQuery = { - auctionId: 'F7557995-65F5-4682-8782-7D5D34D82A8C', - publisherId: '26947112-2289-405D-88C1-A7340C57E63E', - userId: 'pubcid 123', - url: 'http://www.domain.com', - seats: {'dsp': ['seat 1']}, - version: '1.1', - cookieSupport: true, - adRequests: [{ - adUnitId: '9E153CED-61BC-479E-98DF-24DC0D01BA37', - callerAdUnitId: 'panorama_d_1', - bidId: '2ffb201a808da7', - transactionId: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D', - formats: [{width: 980, height: 240}, {width: 980, height: 120}] - }] - }; - - expect(data).to.deep.equal(expectedQuery); - }); - - it('should make userId take precedence over pubcid', function() { - sandbox.stub(utils, 'isSafariBrowser').callsFake(() => false); - sandbox.stub(utils, 'cookiesAreEnabled').callsFake(() => true); - let testbidRequest = clone(bidderRequest); - testbidRequest.bids[0].crumbs = {pubcid: 'pubcid 123'}; - let result = spec.buildRequests(testbidRequest.bids, testbidRequest); - let data = JSON.parse(result.data); - - expect(result.url).to.equal('//lwadm.com/ad'); - - let expectedQuery = { - auctionId: 'F7557995-65F5-4682-8782-7D5D34D82A8C', - publisherId: '26947112-2289-405D-88C1-A7340C57E63E', - userId: 'user id', - url: 'http://www.domain.com', - seats: {'dsp': ['seat 1']}, - version: '1.1', - cookieSupport: true, - adRequests: [{ - adUnitId: '9E153CED-61BC-479E-98DF-24DC0D01BA37', - callerAdUnitId: 'panorama_d_1', - bidId: '2ffb201a808da7', - transactionId: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D', - formats: [{width: 980, height: 240}, {width: 980, height: 120}] - }] - }; - - expect(data).to.deep.equal(expectedQuery); - }); - }); - - it('should make use of Id5-Id if available', function() { - sandbox.stub(utils, 'isSafariBrowser').callsFake(() => false); - sandbox.stub(utils, 'cookiesAreEnabled').callsFake(() => true); - let testbidRequest = clone(bidderRequest); - delete testbidRequest.bids[0].params.userId; - testbidRequest.bids[0].userId = {}; - testbidRequest.bids[0].userId.id5id = 'id5-user-id'; - let result = spec.buildRequests(testbidRequest.bids, testbidRequest); - let data = JSON.parse(result.data); - - expect(data.rtbData.user.ext.eids).to.deep.equal([{ - 'source': 'id5-sync.com', - 'uids': [{ - 'id': 'id5-user-id', - 'atype': 1 - }] - }]); - }); - - it('should make use of publisher common Id if available', function() { - sandbox.stub(utils, 'isSafariBrowser').callsFake(() => false); - sandbox.stub(utils, 'cookiesAreEnabled').callsFake(() => true); - let testbidRequest = clone(bidderRequest); - delete testbidRequest.bids[0].params.userId; - testbidRequest.bids[0].userId = {}; - testbidRequest.bids[0].userId.pubcid = 'publisher-common-id'; - let result = spec.buildRequests(testbidRequest.bids, testbidRequest); - let data = JSON.parse(result.data); - - expect(data.rtbData.user.ext.eids).to.deep.equal([{ - 'source': 'pubcommon', - 'uids': [{ - 'id': 'publisher-common-id', - 'atype': 1 - }] - }]); - }); - - describe('interpretResponse', function () { - it('should handle single success response', function() { - let lwResponse = { - ads: [ - { - id: '28e5ddf4-3c01-11e8-86a7-0a44794250d4', - callerId: 'site_outsider_0', - tag: 'ad', - width: 300, - height: 250, - cpmBid: 2.565917, - bidId: '32e50fad901ae89', - auctionId: '13e674db-d4d8-4e19-9d28-ff38177db8bf', - creativeId: '52cbd598-2715-4c43-a06f-229fc170f945:427077', - ttl: 120, - meta: undefined - } - ], - currency: 'USD' - }; - - let expectedResponse = [{ - requestId: '32e50fad901ae89', - bidderCode: 'livewrapped', - cpm: 2.565917, - width: 300, - height: 250, - ad: 'ad', - ttl: 120, - creativeId: '52cbd598-2715-4c43-a06f-229fc170f945:427077', - netRevenue: true, - currency: 'USD', - meta: undefined - }]; - - let bids = spec.interpretResponse({body: lwResponse}); - - expect(bids).to.deep.equal(expectedResponse); - }) - - it('should handle multiple success response', function() { - let lwResponse = { - ads: [ - { - id: '28e5ddf4-3c01-11e8-86a7-0a44794250d4', - callerId: 'site_outsider_0', - tag: 'ad1', - width: 300, - height: 250, - cpmBid: 2.565917, - bidId: '32e50fad901ae89', - auctionId: '13e674db-d4d8-4e19-9d28-ff38177db8bf', - creativeId: '52cbd598-2715-4c43-a06f-229fc170f945:427077', - ttl: 120, - meta: undefined - }, - { - id: '38e5ddf4-3c01-11e8-86a7-0a44794250d4', - callerId: 'site_outsider_1', - tag: 'ad2', - width: 980, - height: 240, - cpmBid: 3.565917, - bidId: '42e50fad901ae89', - auctionId: '13e674db-d4d8-4e19-9d28-ff38177db8bf', - creativeId: '62cbd598-2715-4c43-a06f-229fc170f945:427077', - ttl: 120, - meta: undefined - } - ], - currency: 'USD' - }; - - let expectedResponse = [{ - requestId: '32e50fad901ae89', - bidderCode: 'livewrapped', - cpm: 2.565917, - width: 300, - height: 250, - ad: 'ad1', - ttl: 120, - creativeId: '52cbd598-2715-4c43-a06f-229fc170f945:427077', - netRevenue: true, - currency: 'USD', - meta: undefined - }, { - requestId: '42e50fad901ae89', - bidderCode: 'livewrapped', - cpm: 3.565917, - width: 980, - height: 240, - ad: 'ad2', - ttl: 120, - creativeId: '62cbd598-2715-4c43-a06f-229fc170f945:427077', - netRevenue: true, - currency: 'USD', - meta: undefined - }]; - - let bids = spec.interpretResponse({body: lwResponse}); - - expect(bids).to.deep.equal(expectedResponse); - }) - - it('should return meta-data', function() { - let lwResponse = { - ads: [ - { - id: '28e5ddf4-3c01-11e8-86a7-0a44794250d4', - callerId: 'site_outsider_0', - tag: 'ad', - width: 300, - height: 250, - cpmBid: 2.565917, - bidId: '32e50fad901ae89', - auctionId: '13e674db-d4d8-4e19-9d28-ff38177db8bf', - creativeId: '52cbd598-2715-4c43-a06f-229fc170f945:427077', - ttl: 120, - meta: {metadata: 'metadata'} - } - ], - currency: 'USD' - }; - - let expectedResponse = [{ - requestId: '32e50fad901ae89', - bidderCode: 'livewrapped', - cpm: 2.565917, - width: 300, - height: 250, - ad: 'ad', - ttl: 120, - creativeId: '52cbd598-2715-4c43-a06f-229fc170f945:427077', - netRevenue: true, - currency: 'USD', - meta: {metadata: 'metadata'} - }]; - - let bids = spec.interpretResponse({body: lwResponse}); - - expect(bids).to.deep.equal(expectedResponse); - }) - }); - - describe('user sync', function () { - let serverResponses; - - beforeEach(function () { - serverResponses = [{ - body: { - pixels: [ - {type: 'Redirect', url: 'http://pixelsync'}, - {type: 'Iframe', url: 'http://iframesync'} - ] - } - }]; - }); - - it('should return empty if no server responses', function() { - let syncs = spec.getUserSyncs({ - pixelEnabled: true, - iframeEnabled: true - }, []); - - let expectedResponse = []; - - expect(syncs).to.deep.equal(expectedResponse) - }); - - it('should return empty if no user sync', function() { - let syncs = spec.getUserSyncs({ - pixelEnabled: true, - iframeEnabled: true - }, [{body: {}}]); - - let expectedResponse = []; - - expect(syncs).to.deep.equal(expectedResponse) - }); - - it('should returns pixel and iframe user sync', function() { - let syncs = spec.getUserSyncs({ - pixelEnabled: true, - iframeEnabled: true - }, serverResponses); - - let expectedResponse = [{type: 'image', url: 'http://pixelsync'}, {type: 'iframe', url: 'http://iframesync'}]; - - expect(syncs).to.deep.equal(expectedResponse) - }); - - it('should returns pixel only if iframe not supported user sync', function() { - let syncs = spec.getUserSyncs({ - pixelEnabled: true, - iframeEnabled: false - }, serverResponses); - - let expectedResponse = [{type: 'image', url: 'http://pixelsync'}]; - - expect(syncs).to.deep.equal(expectedResponse) - }); - - it('should returns iframe only if pixel not supported user sync', function() { - let syncs = spec.getUserSyncs({ - pixelEnabled: false, - iframeEnabled: true - }, serverResponses); - - let expectedResponse = [{type: 'iframe', url: 'http://iframesync'}]; - - expect(syncs).to.deep.equal(expectedResponse) - }); - }); -}); - -function clone(obj) { - return JSON.parse(JSON.stringify(obj)); -} diff --git a/test/spec/modules/lkqdBidAdapter_spec.js b/test/spec/modules/lkqdBidAdapter_spec.js index 73a4824f0efe..1c7f55d42426 100644 --- a/test/spec/modules/lkqdBidAdapter_spec.js +++ b/test/spec/modules/lkqdBidAdapter_spec.js @@ -173,7 +173,7 @@ https://t.lkqd.net/t?ev=3&tsid=662921&env=3&cb=761218674439&format=0&did=2&osid= ]]> - + - + @@ -194,7 +194,7 @@ https://t.lkqd.net/t?ev=9&tsid=662921&env=3&cb=761218674439&format=0&did=2&osid= 00:00:30 - + - + - + - + - + - + - + - + - + - + - + + ]]> diff --git a/test/spec/modules/logicadBidAdapter_spec.js b/test/spec/modules/logicadBidAdapter_spec.js index effb7334b69b..1cae535aee05 100644 --- a/test/spec/modules/logicadBidAdapter_spec.js +++ b/test/spec/modules/logicadBidAdapter_spec.js @@ -8,7 +8,7 @@ describe('LogicadAdapter', function () { bidId: '51ef8751f9aead', params: { tid: 'PJ2P', - page: 'http://www.logicad.com/' + page: 'https://www.logicad.com/' }, adUnitCode: 'div-gpt-ad-1460505748561-0', transactionId: 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', diff --git a/test/spec/modules/madvertiseBidAdapter_spec.js b/test/spec/modules/madvertiseBidAdapter_spec.js index b2a08410532c..e10a192355af 100644 --- a/test/spec/modules/madvertiseBidAdapter_spec.js +++ b/test/spec/modules/madvertiseBidAdapter_spec.js @@ -114,7 +114,7 @@ describe('madvertise adapater', function () { expect(req[0]).to.have.property('method'); expect(req[0].method).to.equal('GET'); expect(req[0]).to.have.property('url'); - expect(req[0].url).to.contain('//mobile.mng-ads.com/?rt=bid_request&v=1.0'); + expect(req[0].url).to.contain('https://mobile.mng-ads.com/?rt=bid_request&v=1.0'); expect(req[0].url).to.contain(`&s=test`); expect(req[0].url).to.contain(`&sizes[0]=728x90`); expect(req[0].url).to.contain(`&gdpr=1`); @@ -130,7 +130,7 @@ describe('madvertise adapater', function () { expect(req[0]).to.have.property('method'); expect(req[0].method).to.equal('GET'); expect(req[0]).to.have.property('url'); - expect(req[0].url).to.contain('//mobile.mng-ads.com/?rt=bid_request&v=1.0'); + expect(req[0].url).to.contain('https://mobile.mng-ads.com/?rt=bid_request&v=1.0'); expect(req[0].url).to.contain(`&s=test`); expect(req[0].url).to.contain(`&sizes[0]=728x90`); expect(req[0].url).not.to.contain(`&gdpr=1`); diff --git a/test/spec/modules/mantisBidAdapter_spec.js b/test/spec/modules/mantisBidAdapter_spec.js index df2c6bb9a13f..7caa9b29f6fc 100644 --- a/test/spec/modules/mantisBidAdapter_spec.js +++ b/test/spec/modules/mantisBidAdapter_spec.js @@ -48,10 +48,10 @@ describe('MantisAdapter', function () { ]; it('domain override', function () { - window.mantis_domain = 'http://foo'; + window.mantis_domain = 'https://foo'; const request = spec.buildRequests(bidRequests); - expect(request.url).to.include('http://foo'); + expect(request.url).to.include('https://foo'); delete window.mantis_domain; }); diff --git a/test/spec/modules/meazyBidAdapter_spec.js b/test/spec/modules/meazyBidAdapter_spec.js index 9abe37ece62f..123d53f2fa1b 100644 --- a/test/spec/modules/meazyBidAdapter_spec.js +++ b/test/spec/modules/meazyBidAdapter_spec.js @@ -4,7 +4,7 @@ import { spec } from 'modules/meazyBidAdapter'; import { newBidder } from 'src/adapters/bidderFactory'; const MEAZY_PID = '6910b7344ae566a1' -const VALID_ENDPOINT = `//rtb-filter.meazy.co/pbjs?host=${utils.getOrigin()}&api_key=${MEAZY_PID}`; +const VALID_ENDPOINT = `https://rtb-filter.meazy.co/pbjs?host=${utils.getOrigin()}&api_key=${MEAZY_PID}`; const bidderRequest = { refererInfo: { @@ -50,7 +50,7 @@ const bidContent = { const bidContentExt = { ...bidContent, ext: { - 'syncUrl': '//sync.meazy.co/sync/img?api_key=6910b7344ae566a1' + 'syncUrl': 'https://sync.meazy.co/sync/img?api_key=6910b7344ae566a1' } }; @@ -158,8 +158,8 @@ describe('meazyBidAdapter', function () { const syncOptionsEE = { pixelEnabled: true, iframeEnabled: true }; const syncOptionsFE = { pixelEnabled: true, iframeEnabled: false }; - const successIFrame = { type: 'iframe', url: '//sync.meazy.co/sync/iframe' }; - const successPixel = { type: 'image', url: '//sync.meazy.co/sync/img?api_key=6910b7344ae566a1' }; + const successIFrame = { type: 'iframe', url: 'https://sync.meazy.co/sync/iframe' }; + const successPixel = { type: 'image', url: 'https://sync.meazy.co/sync/img?api_key=6910b7344ae566a1' }; it('should return an empty array', function () { expect(spec.getUserSyncs(syncOptionsFF, [])).to.be.empty; diff --git a/test/spec/modules/mgidBidAdapter_spec.js b/test/spec/modules/mgidBidAdapter_spec.js index 4a9f25a29a75..07db18650c20 100644 --- a/test/spec/modules/mgidBidAdapter_spec.js +++ b/test/spec/modules/mgidBidAdapter_spec.js @@ -256,7 +256,7 @@ describe('Mgid bid adapter', function () { it('should return overwrite default bidurl', function () { let bid = Object.assign({}, bid); bid.params = { - bidUrl: '//newbidurl.com/', + bidUrl: 'https://newbidurl.com/', accountId: '1', placementId: '2', }; @@ -267,7 +267,7 @@ describe('Mgid bid adapter', function () { }; let bidRequests = [bid]; const request = spec.buildRequests(bidRequests); - expect(request.url).to.include('//newbidurl.com/1'); + expect(request.url).to.include('https://newbidurl.com/1'); }); it('should return overwrite default bidFloor', function () { let bid = Object.assign({}, bid); @@ -546,7 +546,7 @@ describe('Mgid bid adapter', function () { }); it('should push proper banner bid response', function () { let resp = { - body: {'id': '57c0c2b1b732ca', 'bidid': '57c0c2b1b732ca', 'cur': '', 'seatbid': [{'bid': [{'price': 1.5, 'h': 600, 'w': 300, 'id': '1', 'impid': '61e40632c53fc2', 'adid': '2898532/2419121/2592854/2499195', 'nurl': 'http: nurl', 'burl': 'http: burl', 'adm': 'html: adm', 'cid': '44082', 'crid': '2898532/2419121/2592854/2499195', 'cat': ['IAB7', 'IAB14', 'IAB18-3', 'IAB1-2']}], 'seat': '44082'}]} + body: {'id': '57c0c2b1b732ca', 'bidid': '57c0c2b1b732ca', 'cur': '', 'seatbid': [{'bid': [{'price': 1.5, 'h': 600, 'w': 300, 'id': '1', 'impid': '61e40632c53fc2', 'adid': '2898532/2419121/2592854/2499195', 'nurl': 'https nurl', 'burl': 'https burl', 'adm': 'html: adm', 'cid': '44082', 'crid': '2898532/2419121/2592854/2499195', 'cat': ['IAB7', 'IAB14', 'IAB18-3', 'IAB1-2']}], 'seat': '44082'}]} }; let bids = spec.interpretResponse(resp); expect(bids).to.deep.equal([ @@ -560,8 +560,8 @@ describe('Mgid bid adapter', function () { 'isBurl': true, 'mediaType': 'banner', 'netRevenue': true, - 'nurl': 'http: nurl', - 'burl': 'http: burl', + 'nurl': 'https nurl', + 'burl': 'https burl', 'requestId': '61e40632c53fc2', 'ttl': 300, 'width': 300, @@ -572,26 +572,26 @@ describe('Mgid bid adapter', function () { describe('interpretResponse native', function () { it('should not push proper native bid response if adm is missing', function () { let resp = { - body: {'id': '57c0c2b1b732ca', 'bidid': '57c0c2b1b732ca', 'cur': 'GBP', 'seatbid': [{'bid': [{'price': 1.5, 'h': 600, 'w': 300, 'id': '1', 'impid': '61e40632c53fc2', 'adid': '2898532/2419121/2592854/2499195', 'nurl': 'http: nurl', 'burl': 'http: burl', 'cid': '44082', 'crid': '2898532/2419121/2592854/2499195', 'cat': ['IAB7', 'IAB14', 'IAB18-3', 'IAB1-2'], 'ext': {'place': 0, 'crtype': 'native'}}], 'seat': '44082'}]} + body: {'id': '57c0c2b1b732ca', 'bidid': '57c0c2b1b732ca', 'cur': 'GBP', 'seatbid': [{'bid': [{'price': 1.5, 'h': 600, 'w': 300, 'id': '1', 'impid': '61e40632c53fc2', 'adid': '2898532/2419121/2592854/2499195', 'nurl': 'https nurl', 'burl': 'https burl', 'cid': '44082', 'crid': '2898532/2419121/2592854/2499195', 'cat': ['IAB7', 'IAB14', 'IAB18-3', 'IAB1-2'], 'ext': {'place': 0, 'crtype': 'native'}}], 'seat': '44082'}]} }; let bids = spec.interpretResponse(resp); expect(bids).to.deep.equal([]) }); it('should not push proper native bid response if assets is empty', function () { let resp = { - body: {'id': '57c0c2b1b732ca', 'bidid': '57c0c2b1b732ca', 'cur': 'GBP', 'seatbid': [{'bid': [{'price': 1.5, 'h': 600, 'w': 300, 'id': '1', 'impid': '61e40632c53fc2', 'adid': '2898532/2419121/2592854/2499195', 'nurl': 'http: nurl', 'burl': 'http: burl', 'adm': '{\"native\":{\"ver\":\"1.1\",\"link\":{\"url\":\"link_url\"},\"assets\":[],\"imptrackers\":[\"imptrackers1\"]}}', 'cid': '44082', 'crid': '2898532/2419121/2592854/2499195', 'cat': ['IAB7', 'IAB14', 'IAB18-3', 'IAB1-2'], 'ext': {'place': 0, 'crtype': 'native'}}], 'seat': '44082'}]} + body: {'id': '57c0c2b1b732ca', 'bidid': '57c0c2b1b732ca', 'cur': 'GBP', 'seatbid': [{'bid': [{'price': 1.5, 'h': 600, 'w': 300, 'id': '1', 'impid': '61e40632c53fc2', 'adid': '2898532/2419121/2592854/2499195', 'nurl': 'https nurl', 'burl': 'https burl', 'adm': '{\"native\":{\"ver\":\"1.1\",\"link\":{\"url\":\"link_url\"},\"assets\":[],\"imptrackers\":[\"imptrackers1\"]}}', 'cid': '44082', 'crid': '2898532/2419121/2592854/2499195', 'cat': ['IAB7', 'IAB14', 'IAB18-3', 'IAB1-2'], 'ext': {'place': 0, 'crtype': 'native'}}], 'seat': '44082'}]} }; let bids = spec.interpretResponse(resp); expect(bids).to.deep.equal([]) }); it('should push proper native bid response', function () { let resp = { - body: {'id': '57c0c2b1b732ca', 'bidid': '57c0c2b1b732ca', 'cur': 'GBP', 'seatbid': [{'bid': [{'price': 1.5, 'h': 600, 'w': 300, 'id': '1', 'impid': '61e40632c53fc2', 'adid': '2898532/2419121/2592854/2499195', 'nurl': 'http: nurl', 'burl': 'http: burl', 'adm': '{\"native\":{\"ver\":\"1.1\",\"link\":{\"url\":\"link_url\"},\"assets\":[{\"id\":1,\"required\":0,\"title\":{\"text\":\"title1\"}},{\"id\":2,\"required\":0,\"img\":{\"w\":80,\"h\":80,\"type\":3,\"url\":\"image_src\"}},{\"id\":3,\"required\":0,\"img\":{\"w\":50,\"h\":50,\"type\":1,\"url\":\"icon_src\"}},{\"id\":4,\"required\":0,\"data\":{\"type\":4,\"value\":\"sponsored\"}},{\"id\":5,\"required\":0,\"data\":{\"type\":6,\"value\":\"price1\"}},{\"id\":6,\"required\":0,\"data\":{\"type\":7,\"value\":\"price2\"}}],\"imptrackers\":[\"imptrackers1\"]}}', 'cid': '44082', 'crid': '2898532/2419121/2592854/2499195', 'cat': ['IAB7', 'IAB14', 'IAB18-3', 'IAB1-2'], 'ext': {'place': 0, 'crtype': 'native'}}], 'seat': '44082'}], ext: {'muidn': 'userid'}} + body: {'id': '57c0c2b1b732ca', 'bidid': '57c0c2b1b732ca', 'cur': 'GBP', 'seatbid': [{'bid': [{'price': 1.5, 'h': 600, 'w': 300, 'id': '1', 'impid': '61e40632c53fc2', 'adid': '2898532/2419121/2592854/2499195', 'nurl': 'https nurl', 'burl': 'https burl', 'adm': '{\"native\":{\"ver\":\"1.1\",\"link\":{\"url\":\"link_url\"},\"assets\":[{\"id\":1,\"required\":0,\"title\":{\"text\":\"title1\"}},{\"id\":2,\"required\":0,\"img\":{\"w\":80,\"h\":80,\"type\":3,\"url\":\"image_src\"}},{\"id\":3,\"required\":0,\"img\":{\"w\":50,\"h\":50,\"type\":1,\"url\":\"icon_src\"}},{\"id\":4,\"required\":0,\"data\":{\"type\":4,\"value\":\"sponsored\"}},{\"id\":5,\"required\":0,\"data\":{\"type\":6,\"value\":\"price1\"}},{\"id\":6,\"required\":0,\"data\":{\"type\":7,\"value\":\"price2\"}}],\"imptrackers\":[\"imptrackers1\"]}}', 'cid': '44082', 'crid': '2898532/2419121/2592854/2499195', 'cat': ['IAB7', 'IAB14', 'IAB18-3', 'IAB1-2'], 'ext': {'place': 0, 'crtype': 'native'}}], 'seat': '44082'}], ext: {'muidn': 'userid'}} }; let bids = spec.interpretResponse(resp); expect(bids).to.deep.equal([{ 'ad': '{\"native\":{\"ver\":\"1.1\",\"link\":{\"url\":\"link_url\"},\"assets\":[{\"id\":1,\"required\":0,\"title\":{\"text\":\"title1\"}},{\"id\":2,\"required\":0,\"img\":{\"w\":80,\"h\":80,\"type\":3,\"url\":\"image_src\"}},{\"id\":3,\"required\":0,\"img\":{\"w\":50,\"h\":50,\"type\":1,\"url\":\"icon_src\"}},{\"id\":4,\"required\":0,\"data\":{\"type\":4,\"value\":\"sponsored\"}},{\"id\":5,\"required\":0,\"data\":{\"type\":6,\"value\":\"price1\"}},{\"id\":6,\"required\":0,\"data\":{\"type\":7,\"value\":\"price2\"}}],\"imptrackers\":[\"imptrackers1\"]}}', - 'burl': 'http: burl', + 'burl': 'https burl', 'cpm': 1.5, 'creativeId': '2898532/2419121/2592854/2499195', 'currency': 'GBP', @@ -621,7 +621,7 @@ describe('Mgid bid adapter', function () { 'title': 'title1' }, 'netRevenue': true, - 'nurl': 'http: nurl', + 'nurl': 'https nurl', 'requestId': '61e40632c53fc2', 'ttl': 300, 'width': 0 @@ -629,7 +629,7 @@ describe('Mgid bid adapter', function () { }); it('should push proper native bid response', function () { let resp = { - body: {'id': '57c0c2b1b732ca', 'bidid': '57c0c2b1b732ca', 'cur': 'GBP', 'seatbid': [{'bid': [{'price': 1.5, 'h': 600, 'w': 300, 'id': '1', 'impid': '61e40632c53fc2', 'adid': '2898532/2419121/2592854/2499195', 'nurl': 'http: nurl', 'burl': 'http: burl', 'adm': '{\"native\":{\"ver\":\"1.1\",\"link\":{\"url\":\"link_url\"},\"assets\":[{\"id\":1,\"required\":0,\"title\":{\"text\":\"title1\"}},{\"id\":2,\"required\":0,\"img\":{\"w\":80,\"h\":80,\"type\":3,\"url\":\"image_src\"}},{\"id\":3,\"required\":0,\"img\":{\"w\":50,\"h\":50,\"type\":1,\"url\":\"icon_src\"}}],\"imptrackers\":[\"imptrackers1\"]}}', 'cid': '44082', 'crid': '2898532/2419121/2592854/2499195', 'cat': ['IAB7', 'IAB14', 'IAB18-3', 'IAB1-2'], 'ext': {'place': 0, 'crtype': 'native'}}], 'seat': '44082'}]} + body: {'id': '57c0c2b1b732ca', 'bidid': '57c0c2b1b732ca', 'cur': 'GBP', 'seatbid': [{'bid': [{'price': 1.5, 'h': 600, 'w': 300, 'id': '1', 'impid': '61e40632c53fc2', 'adid': '2898532/2419121/2592854/2499195', 'nurl': 'https nurl', 'burl': 'https burl', 'adm': '{\"native\":{\"ver\":\"1.1\",\"link\":{\"url\":\"link_url\"},\"assets\":[{\"id\":1,\"required\":0,\"title\":{\"text\":\"title1\"}},{\"id\":2,\"required\":0,\"img\":{\"w\":80,\"h\":80,\"type\":3,\"url\":\"image_src\"}},{\"id\":3,\"required\":0,\"img\":{\"w\":50,\"h\":50,\"type\":1,\"url\":\"icon_src\"}}],\"imptrackers\":[\"imptrackers1\"]}}', 'cid': '44082', 'crid': '2898532/2419121/2592854/2499195', 'cat': ['IAB7', 'IAB14', 'IAB18-3', 'IAB1-2'], 'ext': {'place': 0, 'crtype': 'native'}}], 'seat': '44082'}]} }; let bids = spec.interpretResponse(resp); expect(bids).to.deep.equal([ @@ -643,8 +643,8 @@ describe('Mgid bid adapter', function () { 'isBurl': true, 'mediaType': 'native', 'netRevenue': true, - 'nurl': 'http: nurl', - 'burl': 'http: burl', + 'nurl': 'https nurl', + 'burl': 'https burl', 'requestId': '61e40632c53fc2', 'ttl': 300, 'width': 0, diff --git a/test/spec/modules/microadBidAdapter_spec.js b/test/spec/modules/microadBidAdapter_spec.js index 32bf15d53b91..b80a69384258 100644 --- a/test/spec/modules/microadBidAdapter_spec.js +++ b/test/spec/modules/microadBidAdapter_spec.js @@ -61,14 +61,14 @@ describe('microadBidAdapter', () => { describe('buildRequests', () => { const bidderRequest = { refererInfo: { - canonicalUrl: 'http://example.com/to', - referer: 'http://example.com/from' + canonicalUrl: 'https://example.com/to', + referer: 'https://example.com/from' } }; const expectedResultTemplate = { spot: 'spot-code', - url: 'http://example.com/to', - referrer: 'http://example.com/from', + url: 'https://example.com/to', + referrer: 'https://example.com/from', bid_id: 'bid-id', transaction_id: 'transaction-id', media_types: 1 @@ -127,7 +127,7 @@ describe('microadBidAdapter', () => { it('should use window.location.href if there is no canonicalUrl', () => { const bidderRequestWithoutCanonicalUrl = { refererInfo: { - referer: 'http://example.com/from' + referer: 'https://example.com/from' } }; const requests = spec.buildRequests([bidRequestTemplate], bidderRequestWithoutCanonicalUrl); diff --git a/test/spec/modules/mobfoxBidAdapter_spec.js b/test/spec/modules/mobfoxBidAdapter_spec.js index 90125f3e0d05..d3178d77a1a1 100644 --- a/test/spec/modules/mobfoxBidAdapter_spec.js +++ b/test/spec/modules/mobfoxBidAdapter_spec.js @@ -75,7 +75,7 @@ describe('mobfox adapter tests', function () { body: { request: { clicktype: 'safari', - clickurl: 'http://tokyo-my.mobfox.com/exchange.click.php?h=494ef76d5b0287a8b5ac8724855cb5e0', + clickurl: 'https://tokyo-my.mobfox.com/exchange.click.php?h=494ef76d5b0287a8b5ac8724855cb5e0', cpmPrice: 50, htmlString: 'test', refresh: '30', @@ -104,7 +104,7 @@ describe('mobfox adapter tests', function () { expect(bidResponses[0].currency).to.equal('USD'); expect(bidResponses[0].height).to.equal('480'); expect(bidResponses[0].netRevenue).to.equal(true); - expect(bidResponses[0].referrer).to.equal('http://tokyo-my.mobfox.com/exchange.click.php?h=494ef76d5b0287a8b5ac8724855cb5e0'); + expect(bidResponses[0].referrer).to.equal('https://tokyo-my.mobfox.com/exchange.click.php?h=494ef76d5b0287a8b5ac8724855cb5e0'); expect(bidResponses[0].ttl).to.equal(360); expect(bidResponses[0].width).to.equal('320'); }); diff --git a/test/spec/modules/mytargetBidAdapter_spec.js b/test/spec/modules/mytargetBidAdapter_spec.js index 4e478fee1f0d..01a94e76d607 100644 --- a/test/spec/modules/mytargetBidAdapter_spec.js +++ b/test/spec/modules/mytargetBidAdapter_spec.js @@ -55,7 +55,7 @@ describe('MyTarget Adapter', function() { it('should build single POST request for multiple bids', function() { expect(bidRequest.method).to.equal('POST'); - expect(bidRequest.url).to.equal('//ad.mail.ru/hbid_prebid/'); + expect(bidRequest.url).to.equal('https://ad.mail.ru/hbid_prebid/'); expect(bidRequest.data).to.be.an('object'); expect(bidRequest.data.places).to.be.an('array'); expect(bidRequest.data.places).to.have.lengthOf(2); diff --git a/test/spec/modules/nanointeractiveBidAdapter_spec.js b/test/spec/modules/nanointeractiveBidAdapter_spec.js index a357327fe966..f999c2a46560 100644 --- a/test/spec/modules/nanointeractiveBidAdapter_spec.js +++ b/test/spec/modules/nanointeractiveBidAdapter_spec.js @@ -178,8 +178,8 @@ describe('nanointeractive adapter tests', function () { let sandbox; function getMocks() { - let mockOriginAddress = 'http://localhost'; - let mockRefAddress = 'http://some-ref.test'; + let mockOriginAddress = 'https://localhost'; + let mockRefAddress = 'https://some-ref.test'; return { 'windowLocationAddress': mockRefAddress, 'originAddress': mockOriginAddress, diff --git a/test/spec/modules/nasmediaAdmixerBidAdapter_spec.js b/test/spec/modules/nasmediaAdmixerBidAdapter_spec.js deleted file mode 100644 index dd6ed4686d1c..000000000000 --- a/test/spec/modules/nasmediaAdmixerBidAdapter_spec.js +++ /dev/null @@ -1,138 +0,0 @@ -import {expect} from 'chai'; -import {spec} from 'modules/nasmediaAdmixerBidAdapter'; -import {newBidder} from 'src/adapters/bidderFactory'; - -describe('nasmediaAdmixerBidAdapter', function () { - const adapter = newBidder(spec); - - describe('inherited functions', function () { - it('exists and is a function', function () { - expect(adapter.callBids).to.exist.and.to.be.a('function'); - }); - }); - - describe('isBidRequestValid', function () { - const bid = { - 'bidder': 'nasmediaAdmixer', - 'params': { - 'ax_key': 'ax_key' - }, - 'adUnitCode': 'adunit-code', - 'sizes': [[300, 250]], - 'bidId': '3361d01e67dbd6', - 'bidderRequestId': '2b60dcd392628a', - 'auctionId': '124cb070528662', - }; - - it('should return true when required params found', function () { - expect(spec.isBidRequestValid(bid)).to.equal(true); - }); - - it('should return false when required params are not passed', function () { - const bid = Object.assign({}, bid); - delete bid.params; - bid.params = { - 'ax_key': 0 - }; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - }); - - describe('buildRequests', function () { - const bidRequests = [ - { - 'bidder': 'nasmediaAdmixer', - 'params': { - 'ax_key': 'ajj7jba3' - }, - 'adUnitCode': 'adunit-code', - 'sizes': [[300, 250]], - 'bidId': '3361d01e67dbd6', - 'bidderRequestId': '2b60dcd392628a', - 'auctionId': '124cb070528662', - } - ]; - - it('sends bid request to url via GET', function () { - const request = spec.buildRequests(bidRequests)[0]; - expect(request.method).to.equal('GET'); - expect(request.url).to.match(new RegExp(`https://adn.admixer.co.kr`)); - }); - }); - - describe('interpretResponse', function () { - const response = { - 'body': { - 'bidder': 'nasmedia_admixer', - 'req_id': '861a8e7952c82c', - 'error_code': 0, - 'error_msg': 'OK', - 'body': [{ - 'ad_id': '20049', - 'width': 300, - 'height': 250, - 'currency': 'USD', - 'cpm': 1.769221, - 'ad': '' - }] - }, - 'headers': { - 'get': function () { - } - } - }; - - const bidRequest = { - 'bidder': 'nasmediaAdmixer', - 'params': { - 'ax_key': 'ajj7jba3', - }, - 'adUnitCode': 'adunit-code', - 'sizes': [[300, 250], [320, 480]], - 'bidId': '31300c8b9697cd', - 'bidderRequestId': '2bf570adcf83fa', - 'auctionId': '169827a33f03cc', - }; - - it('should get correct bid response', function () { - const expectedResponse = [ - { - 'requestId': '861a8e7952c82c', - 'cpm': 1.769221, - 'currency': 'USD', - 'width': 300, - 'height': 250, - 'ad': '', - 'creativeId': '20049', - 'ttl': 360, - 'netRevenue': false - } - ]; - - const result = spec.interpretResponse(response, bidRequest); - expect(result).to.have.lengthOf(1); - let resultKeys = Object.keys(result[0]); - expect(resultKeys.sort()).to.deep.equal(Object.keys(expectedResponse[0]).sort()); - resultKeys.forEach(function (k) { - if (k === 'ad') { - expect(result[0][k]).to.match(/$/); - } else { - expect(result[0][k]).to.equal(expectedResponse[0][k]); - } - }); - }); - - it('handles nobid responses', function () { - response.body = { - 'bidder': 'nasmedia_admixer', - 'req_id': '861a8e7952c82c', - 'error_code': 0, - 'error_msg': 'OK', - 'body': [] - }; - - const result = spec.interpretResponse(response, bidRequest); - expect(result).to.have.lengthOf(0); - }); - }); -}); diff --git a/test/spec/modules/oneplanetonlyBidAdapter_spec.js b/test/spec/modules/oneplanetonlyBidAdapter_spec.js deleted file mode 100644 index fbcec66ef519..000000000000 --- a/test/spec/modules/oneplanetonlyBidAdapter_spec.js +++ /dev/null @@ -1,100 +0,0 @@ -import {expect} from 'chai'; -import {spec} from '../../../modules/oneplanetonlyBidAdapter'; - -describe('OnePlanetOnlyAdapter', function () { - let bid = { - bidId: '51ef8751f9aead', - bidder: 'oneplanetonly', - params: { - siteId: '5', - adUnitId: '5-4587544', - }, - adUnitCode: 'div-gpt-ad-1460505748561-0', - transactionId: 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', - sizes: [[300, 250], [300, 600]], - bidderRequestId: '418b37f85e772c', - auctionId: '18fd8b8b0bd757' - }; - - describe('isBidRequestValid', function () { - it('Should return true if there are params.siteId and params.adUnitId parameters present', function () { - expect(spec.isBidRequestValid(bid)).to.be.true; - }); - it('Should return false if at least one of parameters is not present', function () { - delete bid.params.adUnitId; - expect(spec.isBidRequestValid(bid)).to.be.false; - }); - }); - - describe('buildRequests', function () { - let serverRequest = spec.buildRequests([bid]); - it('Creates a ServerRequest object with method, URL and data', function () { - expect(serverRequest).to.exist; - expect(serverRequest.method).to.exist; - expect(serverRequest.url).to.exist; - expect(serverRequest.data).to.exist; - }); - it('Returns POST method', function () { - expect(serverRequest.method).to.equal('POST'); - }); - it('Returns valid URL', function () { - expect(serverRequest.url).to.equal('//show.oneplanetonly.com/prebid?siteId=5'); - }); - it('Returns valid data if array of bids is valid', function () { - let data = serverRequest.data; - expect(data).to.be.an('object'); - expect(data).to.have.all.keys('id', 'ver', 'prebidVer', 'transactionId', 'currency', 'timeout', 'siteId', - 'domain', 'page', 'referrer', 'adUnits'); - - let adUnit = data.adUnits[0]; - expect(adUnit).to.have.keys('id', 'bidId', 'sizes'); - expect(adUnit.id).to.equal('5-4587544'); - expect(adUnit.bidId).to.equal('51ef8751f9aead'); - expect(adUnit.sizes).to.have.members(['300x250', '300x600']); - }); - it('Returns empty data if no valid requests are passed', function () { - serverRequest = spec.buildRequests([]); - let data = serverRequest.data; - expect(data.adUnits).to.be.an('array').that.is.empty; - }); - }); - describe('interpretResponse', function () { - it('Should interpret banner response', function () { - const serverResponse = { - body: { - bids: [{ - requestId: '51ef8751f9aead', - cpm: 0.4, - width: 300, - height: 250, - creativeId: '2', - currency: 'USD', - ad: 'Test', - ttl: 120, - }] - } - }; - let bannerResponses = spec.interpretResponse(serverResponse); - expect(bannerResponses).to.be.an('array').that.is.not.empty; - let bidObject = bannerResponses[0]; - expect(bidObject).to.have.all.keys('requestId', 'cpm', 'width', 'height', 'ad', 'ttl', 'creativeId', - 'netRevenue', 'currency'); - expect(bidObject.requestId).to.equal('51ef8751f9aead'); - expect(bidObject.cpm).to.equal(0.4); - expect(bidObject.width).to.equal(300); - expect(bidObject.height).to.equal(250); - expect(bidObject.ad).to.equal('Test'); - expect(bidObject.ttl).to.equal(120); - expect(bidObject.creativeId).to.equal('2'); - expect(bidObject.netRevenue).to.be.true; - expect(bidObject.currency).to.equal('USD'); - }); - it('Should return an empty array if invalid response is passed', function () { - const invalid = { - body: {} - }; - let serverResponses = spec.interpretResponse(invalid); - expect(serverResponses).to.be.an('array').that.is.empty; - }); - }); -}); diff --git a/test/spec/modules/open8BidAdapter_spec.js b/test/spec/modules/open8BidAdapter_spec.js index e26811ed71c2..7ef1c38abb20 100644 --- a/test/spec/modules/open8BidAdapter_spec.js +++ b/test/spec/modules/open8BidAdapter_spec.js @@ -1,7 +1,7 @@ import { spec } from 'modules/open8BidAdapter'; import { newBidder } from 'src/adapters/bidderFactory'; -const ENDPOINT = '//as.vt.open8.com/v1/control/prebid'; +const ENDPOINT = 'https://as.vt.open8.com/v1/control/prebid'; describe('Open8Adapter', function() { const adapter = newBidder(spec); @@ -58,9 +58,9 @@ describe('Open8Adapter', function() { userId: 'userid1234', impId: 'impid1234', media: 'TEST_MEDIA', - nurl: '//example/win', + nurl: 'https://example/win', isAdReturn: true, - syncPixels: ['//example/sync/pixel.gif'], + syncPixels: ['https://example/sync/pixel.gif'], syncIFs: [], ad: { bidId: 'TEST_BID_ID', @@ -73,13 +73,13 @@ describe('Open8Adapter', function() { fa: 5678, pr: 'pr1234', mr: 'mr1234', - nurl: '//example/win', + nurl: 'https://example/win', adType: 2, banner: { w: 300, h: 250, adm: '
', - imps: ['//example.com/imp'] + imps: ['https://example.com/imp'] } } }; @@ -89,7 +89,7 @@ describe('Open8Adapter', function() { impId: 'impid1234', media: 'TEST_MEDIA', isAdReturn: true, - syncPixels: ['//example/sync/pixel.gif'], + syncPixels: ['https://example/sync/pixel.gif'], syncIFs: [], ad: { bidId: 'TEST_BID_ID', @@ -102,10 +102,10 @@ describe('Open8Adapter', function() { fa: 5678, pr: 'pr1234', mr: 'mr1234', - nurl: '//example/win', + nurl: 'https://example/win', adType: 1, video: { - purl: '//playerexample.js', + purl: 'https://playerexample.js', vastXml: '', w: 320, h: 180 @@ -124,14 +124,14 @@ describe('Open8Adapter', function() { 'fa': 5678, 'pr': 'pr1234', 'mr': 'mr1234', - 'nurl': '//example/win', + 'nurl': 'https://example/win', 'requestId': 'requestid1234', 'cpm': 1234.56, 'creativeId': 'creativeid1234', 'dealId': 'TEST_DEAL_ID', 'width': 300, 'height': 250, - 'ad': "
", + 'ad': "
", 'mediaType': 'banner', 'currency': 'JPY', 'ttl': 360, @@ -154,7 +154,7 @@ describe('Open8Adapter', function() { 'fa': 5678, 'pr': 'pr1234', 'mr': 'mr1234', - 'nurl': '//example/win', + 'nurl': 'https://example/win', 'requestId': 'requestid1234', 'cpm': 1234.56, 'creativeId': 'creativeid1234', diff --git a/test/spec/modules/openxAnalyticsAdapter_spec.js b/test/spec/modules/openxAnalyticsAdapter_spec.js index 88ab3c4c5805..b47c8a99150c 100644 --- a/test/spec/modules/openxAnalyticsAdapter_spec.js +++ b/test/spec/modules/openxAnalyticsAdapter_spec.js @@ -198,7 +198,7 @@ describe('openx analytics adapter', function() { expect(requests.length).to.equal(1); const endpoint = requests[0].url.split('?')[0]; - expect(endpoint).to.equal('http://ads.openx.net/w/1.0/pban'); + expect(endpoint).to.equal('https://ads.openx.net/w/1.0/pban'); }); describe('hb.ct, hb.rid, dddid, hb.asiid, hb.pubid', function() { diff --git a/test/spec/modules/optimaticBidAdapter_spec.js b/test/spec/modules/optimaticBidAdapter_spec.js deleted file mode 100644 index 3dd7ca79cc70..000000000000 --- a/test/spec/modules/optimaticBidAdapter_spec.js +++ /dev/null @@ -1,178 +0,0 @@ -import { expect } from 'chai'; -import { spec, ENDPOINT } from 'modules/optimaticBidAdapter'; -import * as utils from 'src/utils'; - -describe('OptimaticBidAdapter', function () { - let bidRequest; - - beforeEach(function () { - bidRequest = { - bidder: 'optimatic', - params: { - placement: '2chy7Gc2eSQL', - bidfloor: 5.00 - }, - adUnitCode: 'adunit-code', - sizes: [ 640, 480 ], - bidId: '30b31c1838de1e', - bidderRequestId: '22edbae2733bf6', - auctionId: '1d1a030790a475' - }; - }); - - describe('spec.isBidRequestValid', function () { - it('should return true when the required params are passed', function () { - expect(spec.isBidRequestValid(bidRequest)).to.equal(true); - }); - - it('should return false when the "bidfloor" param is missing', function () { - bidRequest.params = { - placement: '2chy7Gc2eSQL' - }; - expect(spec.isBidRequestValid(bidRequest)).to.equal(false); - }); - - it('should return false when the "placement" param is missing', function () { - bidRequest.params = { - bidfloor: 5.00 - }; - expect(spec.isBidRequestValid(bidRequest)).to.equal(false); - }); - - it('should return false when no bid params are passed', function () { - bidRequest.params = {}; - expect(spec.isBidRequestValid(bidRequest)).to.equal(false); - }); - - it('should return false when a bid request is not passed', function () { - expect(spec.isBidRequestValid()).to.equal(false); - expect(spec.isBidRequestValid({})).to.equal(false); - }); - }); - - describe('spec.buildRequests', function () { - it('should create a POST request for every bid', function () { - const requests = spec.buildRequests([ bidRequest ]); - expect(requests[0].method).to.equal('POST'); - expect(requests[0].url).to.equal(ENDPOINT + bidRequest.params.placement); - }); - - it('should attach the bid request object', function () { - const requests = spec.buildRequests([ bidRequest ]); - expect(requests[0].bidRequest).to.equal(bidRequest); - }); - - it('should attach request data', function () { - const requests = spec.buildRequests([ bidRequest ]); - const data = requests[0].data; - const [ width, height ] = bidRequest.sizes; - expect(data.imp[0].video.w).to.equal(width); - expect(data.imp[0].video.h).to.equal(height); - expect(data.imp[0].bidfloor).to.equal(bidRequest.params.bidfloor); - }); - - it('must parse bid size from a nested array', function () { - const width = 640; - const height = 480; - bidRequest.sizes = [[ width, height ]]; - const requests = spec.buildRequests([ bidRequest ]); - const data = requests[0].data; - expect(data.imp[0].video.w).to.equal(width); - expect(data.imp[0].video.h).to.equal(height); - }); - - it('must parse bid size from a string', function () { - const width = 640; - const height = 480; - bidRequest.sizes = `${width}x${height}`; - const requests = spec.buildRequests([ bidRequest ]); - const data = requests[0].data; - expect(data.imp[0].video.w).to.equal(width); - expect(data.imp[0].video.h).to.equal(height); - }); - - it('must handle an empty bid size', function () { - bidRequest.sizes = []; - const requests = spec.buildRequests([ bidRequest ]); - const data = requests[0].data; - expect(data.imp[0].video.w).to.equal(undefined); - expect(data.imp[0].video.h).to.equal(undefined); - }); - }); - - describe('spec.interpretResponse', function () { - it('should return no bids if the response is not valid', function () { - const bidResponse = spec.interpretResponse({ body: null }, { bidRequest }); - expect(bidResponse.length).to.equal(0); - }); - - it('should return no bids if the response "nurl" and "adm" are missing', function () { - const serverResponse = {seatbid: [{bid: [{price: 5.01}]}]}; - const bidResponse = spec.interpretResponse({ body: serverResponse }, { bidRequest }); - expect(bidResponse.length).to.equal(0); - }); - - it('should return no bids if the response "price" is missing', function () { - const serverResponse = {seatbid: [{bid: [{adm: ''}]}]}; - const bidResponse = spec.interpretResponse({ body: serverResponse }, { bidRequest }); - expect(bidResponse.length).to.equal(0); - }); - - it('should return a valid bid response with just "adm"', function () { - const serverResponse = {seatbid: [{bid: [{id: 1, price: 5.01, adm: ''}]}], cur: 'USD'}; - const bidResponse = spec.interpretResponse({ body: serverResponse }, { bidRequest }); - let o = { - requestId: bidRequest.bidId, - bidderCode: spec.code, - cpm: serverResponse.seatbid[0].bid[0].price, - creativeId: serverResponse.seatbid[0].bid[0].id, - vastXml: serverResponse.seatbid[0].bid[0].adm, - width: 640, - height: 480, - mediaType: 'video', - currency: 'USD', - ttl: 300, - netRevenue: true - }; - expect(bidResponse).to.deep.equal(o); - }); - - it('should return a valid bid response with just "nurl"', function () { - const serverResponse = {seatbid: [{bid: [{id: 1, price: 5.01, nurl: 'https://mg-bid-win.optimatic.com/win/134eb262-948a-463e-ad93-bc8b622d399c?wp=${AUCTION_PRICE}'}]}], cur: 'USD'}; - const bidResponse = spec.interpretResponse({ body: serverResponse }, { bidRequest }); - let o = { - requestId: bidRequest.bidId, - bidderCode: spec.code, - cpm: serverResponse.seatbid[0].bid[0].price, - creativeId: serverResponse.seatbid[0].bid[0].id, - vastUrl: serverResponse.seatbid[0].bid[0].nurl, - width: 640, - height: 480, - mediaType: 'video', - currency: 'USD', - ttl: 300, - netRevenue: true - }; - expect(bidResponse).to.deep.equal(o); - }); - - it('should return a valid bid response with "nurl" when both nurl and adm exist', function () { - const serverResponse = {seatbid: [{bid: [{id: 1, price: 5.01, adm: '', nurl: 'https://mg-bid-win.optimatic.com/win/134eb262-948a-463e-ad93-bc8b622d399c?wp=${AUCTION_PRICE}'}]}], cur: 'USD'}; - const bidResponse = spec.interpretResponse({ body: serverResponse }, { bidRequest }); - let o = { - requestId: bidRequest.bidId, - bidderCode: spec.code, - cpm: serverResponse.seatbid[0].bid[0].price, - creativeId: serverResponse.seatbid[0].bid[0].id, - vastUrl: serverResponse.seatbid[0].bid[0].nurl, - width: 640, - height: 480, - mediaType: 'video', - currency: 'USD', - ttl: 300, - netRevenue: true - }; - expect(bidResponse).to.deep.equal(o); - }); - }); -}); diff --git a/test/spec/modules/orbidderBidAdapter_spec.js b/test/spec/modules/orbidderBidAdapter_spec.js index 1b76de9841a7..9e7d10d7b047 100644 --- a/test/spec/modules/orbidderBidAdapter_spec.js +++ b/test/spec/modules/orbidderBidAdapter_spec.js @@ -31,7 +31,7 @@ describe('orbidderBidAdapter', () => { return spec.buildRequests(buildRequest, { ...bidderRequest || {}, refererInfo: { - referer: 'http://localhost:9876/' + referer: 'https://localhost:9876/' } })[0]; }; @@ -99,7 +99,7 @@ describe('orbidderBidAdapter', () => { it('sends correct bid parameters', () => { // we add one, because we add referer information from bidderRequest object expect(Object.keys(request.data).length).to.equal(Object.keys(defaultBidRequest).length + 1); - expect(request.data.pageUrl).to.equal('http://localhost:9876/'); + expect(request.data.pageUrl).to.equal('https://localhost:9876/'); // expect(request.data.referrer).to.equal(''); Object.keys(defaultBidRequest).forEach((key) => { expect(defaultBidRequest[key]).to.equal(request.data[key]); diff --git a/test/spec/modules/orbitsoftBidAdapter_spec.js b/test/spec/modules/orbitsoftBidAdapter_spec.js deleted file mode 100644 index 18ba9a6e8f3d..000000000000 --- a/test/spec/modules/orbitsoftBidAdapter_spec.js +++ /dev/null @@ -1,248 +0,0 @@ -import {expect} from 'chai'; -import {spec} from 'modules/orbitsoftBidAdapter'; - -const ENDPOINT_URL = 'https://orbitsoft.com/php/ads/hb.phps'; -describe('Orbitsoft adapter', function () { - describe('implementation', function () { - describe('for requests', function () { - it('should accept valid bid', function () { - let validBid = { - bidder: 'orbitsoft', - params: { - placementId: '123', - requestUrl: ENDPOINT_URL - } - }, - isValid = spec.isBidRequestValid(validBid); - - expect(isValid).to.equal(true); - }); - - it('should reject invalid bid', function () { - let invalidBid = { - bidder: 'orbitsoft' - }, - isValid = spec.isBidRequestValid(invalidBid); - - expect(isValid).to.equal(false); - }); - }); - describe('for requests', function () { - it('should accept valid bid with styles', function () { - let validBid = { - bidder: 'orbitsoft', - params: { - placementId: '123', - requestUrl: ENDPOINT_URL, - style: { - title: { - family: 'Tahoma', - size: 'medium', - weight: 'normal', - style: 'normal', - color: '0053F9' - }, - description: { - family: 'Tahoma', - size: 'medium', - weight: 'normal', - style: 'normal', - color: '0053F9' - }, - url: { - family: 'Tahoma', - size: 'medium', - weight: 'normal', - style: 'normal', - color: '0053F9' - }, - colors: { - background: 'ffffff', - border: 'E0E0E0', - link: '5B99FE' - } - } - } - }, - isValid = spec.isBidRequestValid(validBid); - expect(isValid).to.equal(true); - - let buildRequest = spec.buildRequests([validBid])[0]; - let requestUrl = buildRequest.url; - let requestUrlParams = buildRequest.data; - expect(requestUrl).to.equal(ENDPOINT_URL); - expect(requestUrlParams).have.property('f1', 'Tahoma'); - expect(requestUrlParams).have.property('fs1', 'medium'); - expect(requestUrlParams).have.property('w1', 'normal'); - expect(requestUrlParams).have.property('s1', 'normal'); - expect(requestUrlParams).have.property('c3', '0053F9'); - expect(requestUrlParams).have.property('f2', 'Tahoma'); - expect(requestUrlParams).have.property('fs2', 'medium'); - expect(requestUrlParams).have.property('w2', 'normal'); - expect(requestUrlParams).have.property('s2', 'normal'); - expect(requestUrlParams).have.property('c4', '0053F9'); - expect(requestUrlParams).have.property('f3', 'Tahoma'); - expect(requestUrlParams).have.property('fs3', 'medium'); - expect(requestUrlParams).have.property('w3', 'normal'); - expect(requestUrlParams).have.property('s3', 'normal'); - expect(requestUrlParams).have.property('c5', '0053F9'); - expect(requestUrlParams).have.property('c2', 'ffffff'); - expect(requestUrlParams).have.property('c1', 'E0E0E0'); - expect(requestUrlParams).have.property('c6', '5B99FE'); - }); - - it('should accept valid bid with custom params', function () { - let validBid = { - bidder: 'orbitsoft', - params: { - placementId: '123', - requestUrl: ENDPOINT_URL, - customParams: { - cacheBuster: 'bf4d7c1', - clickUrl: 'http://testclickurl.com' - } - } - }, - isValid = spec.isBidRequestValid(validBid); - expect(isValid).to.equal(true); - - let buildRequest = spec.buildRequests([validBid])[0]; - let requestUrlCustomParams = buildRequest.data; - expect(requestUrlCustomParams).have.property('c.cacheBuster', 'bf4d7c1'); - expect(requestUrlCustomParams).have.property('c.clickUrl', 'http://testclickurl.com'); - }); - - it('should reject invalid bid without requestUrl', function () { - let invalidBid = { - bidder: 'orbitsoft', - params: { - placementId: '123' - } - }, - isValid = spec.isBidRequestValid(invalidBid); - - expect(isValid).to.equal(false); - }); - - it('should reject invalid bid without placementId', function () { - let invalidBid = { - bidder: 'orbitsoft', - params: { - requestUrl: ENDPOINT_URL - } - }, - isValid = spec.isBidRequestValid(invalidBid); - - expect(isValid).to.equal(false); - }); - }); - describe('bid responses', function () { - it('should return complete bid response', function () { - let serverResponse = { - body: { - callback_uid: '265b29b70cc106', - cpm: 0.5, - width: 240, - height: 240, - content_url: 'https://orbitsoft.com/php/ads/hb.html', - } - }; - - let bidRequests = [ - { - bidder: 'orbitsoft', - params: { - placementId: '123', - requestUrl: ENDPOINT_URL - } - } - ]; - let bids = spec.interpretResponse(serverResponse, {'bidRequest': bidRequests[0]}); - expect(bids).to.be.lengthOf(1); - expect(bids[0].cpm).to.equal(0.5); - expect(bids[0].width).to.equal(240); - expect(bids[0].height).to.equal(240); - expect(bids[0].currency).to.equal('USD'); - expect(bids[0].netRevenue).to.equal(true); - expect(bids[0].adUrl).to.have.length.above(1); - expect(bids[0].adUrl).to.have.string('https://orbitsoft.com/php/ads/hb.html'); - }); - - it('should return empty bid response', function () { - let bidRequests = [ - { - bidder: 'orbitsoft', - params: { - placementId: '123', - requestUrl: ENDPOINT_URL - } - } - ]; - let serverResponse = { - body: { - callback_uid: '265b29b70cc106', - cpm: 0 - } - }, - bids = spec.interpretResponse(serverResponse, {'bidRequest': bidRequests[0]}); - - expect(bids).to.be.lengthOf(0); - }); - - it('should return empty bid response on incorrect size', function () { - let bidRequests = [ - { - bidder: 'orbitsoft', - params: { - placementId: '123', - requestUrl: ENDPOINT_URL - } - } - ]; - let serverResponse = { - body: { - callback_uid: '265b29b70cc106', - cpm: 1.5, - width: 0, - height: 0 - } - }, - bids = spec.interpretResponse(serverResponse, {'bidRequest': bidRequests[0]}); - - expect(bids).to.be.lengthOf(0); - }); - - it('should return empty bid response with error', function () { - let bidRequests = [ - { - bidder: 'orbitsoft', - params: { - placementId: '123', - requestUrl: ENDPOINT_URL - } - } - ]; - let serverResponse = {error: 'error'}, - bids = spec.interpretResponse(serverResponse, {'bidRequest': bidRequests[0]}); - - expect(bids).to.be.lengthOf(0); - }); - - it('should return empty bid response on empty body', function () { - let bidRequests = [ - { - bidder: 'orbitsoft', - params: { - placementId: '123', - requestUrl: ENDPOINT_URL - } - } - ]; - let serverResponse = {}, - bids = spec.interpretResponse(serverResponse, {'bidRequest': bidRequests[0]}); - - expect(bids).to.be.lengthOf(0); - }); - }); - }); -}); diff --git a/test/spec/modules/ozoneBidAdapter_spec.js b/test/spec/modules/ozoneBidAdapter_spec.js index a0b51ff7a9ff..4ea3474d2b99 100644 --- a/test/spec/modules/ozoneBidAdapter_spec.js +++ b/test/spec/modules/ozoneBidAdapter_spec.js @@ -170,10 +170,10 @@ var validResponse = { 'id': '677903815252395017', 'impid': '2899ec066a91ff8', 'price': 0.5, - 'adm': '', + 'adm': '', 'adid': '98493581', 'adomain': [ - 'http://prebid.org' + 'https://prebid.org' ], 'iurl': 'https://fra1-ib.adnxs.com/cr?id=98493581', 'cid': '9325', @@ -225,10 +225,10 @@ var validOutstreamResponse = { 'id': '677903815252395017', 'impid': '2899ec066a91ff8', 'price': 0.5, - 'adm': '', + 'adm': '', 'adid': '98493581', 'adomain': [ - 'http://prebid.org' + 'https://prebid.org' ], 'iurl': 'https://fra1-ib.adnxs.com/cr?id=98493581', 'cid': '9325', diff --git a/test/spec/modules/padsquadBidAdapter_spec.js b/test/spec/modules/padsquadBidAdapter_spec.js index aba1efea32fe..88c9680c888d 100644 --- a/test/spec/modules/padsquadBidAdapter_spec.js +++ b/test/spec/modules/padsquadBidAdapter_spec.js @@ -50,7 +50,7 @@ const RESPONSE = { 'adm': '', 'adid': '144762342', 'adomain': [ - 'http://dummydomain.com' + 'https://dummydomain.com' ], 'iurl': 'iurl', 'cid': '109', @@ -79,7 +79,7 @@ const RESPONSE = { 'adm': '', 'adid': '144762342', 'adomain': [ - 'http://dummydomain.com' + 'https://dummydomain.com' ], 'iurl': 'iurl', 'cid': '109', diff --git a/test/spec/modules/papyrusBidAdapter_spec.js b/test/spec/modules/papyrusBidAdapter_spec.js index 289da56379a2..f3c6f42f5b28 100644 --- a/test/spec/modules/papyrusBidAdapter_spec.js +++ b/test/spec/modules/papyrusBidAdapter_spec.js @@ -1,7 +1,7 @@ import { expect } from 'chai'; import { spec } from 'modules/papyrusBidAdapter'; -const ENDPOINT = '//prebid.papyrus.global'; +const ENDPOINT = 'https://prebid.papyrus.global'; const BIDDER_CODE = 'papyrus'; describe('papyrus Adapter', function () { diff --git a/test/spec/modules/peak226BidAdapter_spec.js b/test/spec/modules/peak226BidAdapter_spec.js deleted file mode 100644 index 8b8157225bb1..000000000000 --- a/test/spec/modules/peak226BidAdapter_spec.js +++ /dev/null @@ -1,114 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/peak226BidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; - -const URL = 'a.ad216.com/header_bid'; - -describe('PeakAdapter', function () { - const adapter = newBidder(spec); - - describe('isBidRequestValid', function () { - it('should return true when required params found', function () { - const bid = { - params: { - uid: 123 - } - }; - - expect(spec.isBidRequestValid(bid)).to.equal(true); - }); - - it('should return false when required params are not passed', function () { - const bid = { - params: {} - }; - - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - }); - - // xdescribe('buildRequests', function () { - // const bidRequests = [ - // { - // params: { - // uid: '1234' - // } - // } - // ]; - - // it('sends bid request to URL via GET', function () { - // const request = spec.buildRequests(bidRequests); - - // expect(request.url).to.equal(`${URL}?uids=1234`); - // expect(request.method).to.equal('GET'); - // }); - // }); - - describe('interpretResponse', function () { - it('should handle empty response', function () { - let bids = spec.interpretResponse( - {}, - { - bidsMap: {} - } - ); - - expect(bids).to.be.lengthOf(0); - }); - - it('should handle no seatbid returned', function () { - let response = {}; - - let bids = spec.interpretResponse( - { body: response }, - { - bidsMap: {} - } - ); - - expect(bids).to.be.lengthOf(0); - }); - - it('should handle empty seatbid returned', function () { - let response = { seatbid: [] }; - - let bids = spec.interpretResponse( - { body: response }, - { - bidsMap: {} - } - ); - - expect(bids).to.be.lengthOf(0); - }); - - it('should handle seatbid returned bids', function () { - const bidsMap = { 1: [{ bidId: 11 }] }; - const bid = { - price: 0.2, - auid: 1, - h: 250, - w: 300, - adm: 'content' - }; - const response = { - seatbid: [ - { - seat: 'foo', - bid: [bid] - } - ] - }; - - let bids = spec.interpretResponse({ body: response }, { bidsMap }); - - expect(bids).to.be.lengthOf(1); - - expect(bids[0].cpm).to.equal(bid.price); - expect(bids[0].width).to.equal(bid.w); - expect(bids[0].height).to.equal(bid.h); - expect(bids[0].ad).to.equal(bid.adm); - expect(bids[0].bidderCode).to.equal(spec.code); - }); - }); -}); diff --git a/test/spec/modules/platformioBidAdapter_spec.js b/test/spec/modules/platformioBidAdapter_spec.js deleted file mode 100644 index 4ef2dc1bba03..000000000000 --- a/test/spec/modules/platformioBidAdapter_spec.js +++ /dev/null @@ -1,335 +0,0 @@ -import {expect} from 'chai'; -import {spec} from 'modules/platformioBidAdapter'; -import {getTopWindowLocation} from 'src/utils'; -import {newBidder} from 'src/adapters/bidderFactory'; - -describe('Platform.io Adapter Tests', function () { - const slotConfigs = [{ - placementCode: '/DfpAccount1/slot1', - bidId: 'bid12345', - mediaType: 'banner', - params: { - pubId: '29521', - siteId: '26047', - placementId: '123', - size: '300x250', - bidFloor: '0.001', - ifa: 'IFA', - latitude: '40.712775', - longitude: '-74.005973' - } - }, { - placementCode: '/DfpAccount2/slot2', - bidId: 'bid23456', - mediaType: 'banner', - params: { - pubId: '29521', - siteId: '26047', - placementId: '1234', - size: '728x90', - bidFloor: '0.000001', - } - }]; - const nativeSlotConfig = [{ - placementCode: '/DfpAccount1/slot3', - bidId: 'bid12345', - mediaType: 'native', - nativeParams: { - title: { required: true, len: 200 }, - body: {}, - image: { wmin: 100 }, - sponsoredBy: { }, - icon: { } - }, - params: { - pubId: '29521', - placementId: '123', - siteId: '26047' - } - }]; - const videoSlotConfig = [{ - placementCode: '/DfpAccount1/slot4', - bidId: 'bid12345678', - mediaType: 'video', - video: { - skippable: true - }, - params: { - pubId: '29521', - placementId: '1234567', - siteId: '26047', - size: '640x480' - } - }]; - const appSlotConfig = [{ - placementCode: '/DfpAccount1/slot5', - bidId: 'bid12345', - params: { - pubId: '29521', - placementId: '1234', - app: { - id: '1111', - name: 'app name', - bundle: 'io.platform.apps', - storeUrl: 'http://platform.io/apps', - domain: 'platform.io' - } - } - }]; - - it('Verify build request', function () { - const request = spec.buildRequests(slotConfigs); - expect(request.url).to.equal('//piohbdisp.hb.adx1.com/'); - expect(request.method).to.equal('POST'); - const ortbRequest = JSON.parse(request.data); - // site object - expect(ortbRequest.site).to.not.equal(null); - expect(ortbRequest.site.publisher).to.not.equal(null); - expect(ortbRequest.site.publisher.id).to.equal('29521'); - expect(ortbRequest.site.ref).to.equal(window.top.document.referrer); - expect(ortbRequest.site.page).to.equal(getTopWindowLocation().href); - expect(ortbRequest.imp).to.have.lengthOf(2); - // device object - expect(ortbRequest.device).to.not.equal(null); - expect(ortbRequest.device.ua).to.equal(navigator.userAgent); - expect(ortbRequest.device.ifa).to.equal('IFA'); - expect(ortbRequest.device.geo.lat).to.equal('40.712775'); - expect(ortbRequest.device.geo.lon).to.equal('-74.005973'); - // slot 1 - expect(ortbRequest.imp[0].tagid).to.equal('123'); - expect(ortbRequest.imp[0].banner).to.not.equal(null); - expect(ortbRequest.imp[0].banner.w).to.equal(300); - expect(ortbRequest.imp[0].banner.h).to.equal(250); - expect(ortbRequest.imp[0].bidfloor).to.equal('0.001'); - // slot 2 - expect(ortbRequest.imp[1].tagid).to.equal('1234'); - expect(ortbRequest.imp[1].banner).to.not.equal(null); - expect(ortbRequest.imp[1].banner.w).to.equal(728); - expect(ortbRequest.imp[1].banner.h).to.equal(90); - expect(ortbRequest.imp[1].bidfloor).to.equal('0.000001'); - }); - - it('Verify parse response', function () { - const request = spec.buildRequests(slotConfigs); - const ortbRequest = JSON.parse(request.data); - const ortbResponse = { - seatbid: [{ - bid: [{ - impid: ortbRequest.imp[0].id, - price: 1.25, - adm: 'This is an Ad' - }] - }], - cur: 'USD' - }; - const bids = spec.interpretResponse({ body: ortbResponse }, request); - expect(bids).to.have.lengthOf(1); - // verify first bid - const bid = bids[0]; - expect(bid.cpm).to.equal(1.25); - expect(bid.ad).to.equal('This is an Ad'); - expect(bid.width).to.equal(300); - expect(bid.height).to.equal(250); - expect(bid.adId).to.equal('bid12345'); - expect(bid.creativeId).to.equal('bid12345'); - expect(bid.netRevenue).to.equal(true); - expect(bid.currency).to.equal('USD'); - expect(bid.ttl).to.equal(360); - }); - - it('Verify full passback', function () { - const request = spec.buildRequests(slotConfigs); - const bids = spec.interpretResponse({ body: null }, request) - expect(bids).to.have.lengthOf(0); - }); - - it('Verify Native request', function () { - const request = spec.buildRequests(nativeSlotConfig); - expect(request.url).to.equal('//piohbdisp.hb.adx1.com/'); - expect(request.method).to.equal('POST'); - const ortbRequest = JSON.parse(request.data); - // native impression - expect(ortbRequest.imp[0].tagid).to.equal('123'); - const nativePart = ortbRequest.imp[0]['native']; - expect(nativePart).to.not.equal(null); - expect(nativePart.ver).to.equal('1.1'); - expect(nativePart.request).to.not.equal(null); - // native request assets - const nativeRequest = JSON.parse(ortbRequest.imp[0]['native'].request); - expect(nativeRequest).to.not.equal(null); - expect(nativeRequest.assets).to.have.lengthOf(5); - expect(nativeRequest.assets[0].id).to.equal(1); - expect(nativeRequest.assets[1].id).to.equal(2); - expect(nativeRequest.assets[2].id).to.equal(3); - expect(nativeRequest.assets[3].id).to.equal(4); - expect(nativeRequest.assets[4].id).to.equal(5); - expect(nativeRequest.assets[0].required).to.equal(1); - expect(nativeRequest.assets[0].title).to.not.equal(null); - expect(nativeRequest.assets[0].title.len).to.equal(200); - expect(nativeRequest.assets[1].title).to.be.undefined; - expect(nativeRequest.assets[1].data).to.not.equal(null); - expect(nativeRequest.assets[1].data.type).to.equal(2); - expect(nativeRequest.assets[1].data.len).to.equal(200); - expect(nativeRequest.assets[2].required).to.equal(0); - expect(nativeRequest.assets[3].img).to.not.equal(null); - expect(nativeRequest.assets[3].img.wmin).to.equal(50); - expect(nativeRequest.assets[3].img.hmin).to.equal(50); - expect(nativeRequest.assets[3].img.type).to.equal(1); - expect(nativeRequest.assets[4].img).to.not.equal(null); - expect(nativeRequest.assets[4].img.wmin).to.equal(100); - expect(nativeRequest.assets[4].img.hmin).to.equal(150); - expect(nativeRequest.assets[4].img.type).to.equal(3); - }); - - it('Verify Native response', function () { - const request = spec.buildRequests(nativeSlotConfig); - expect(request.url).to.equal('//piohbdisp.hb.adx1.com/'); - expect(request.method).to.equal('POST'); - const ortbRequest = JSON.parse(request.data); - const nativeResponse = { - 'native': { - assets: [ - { id: 1, title: { text: 'Ad Title' } }, - { id: 2, data: { value: 'Test description' } }, - { id: 3, data: { value: 'Brand' } }, - { id: 4, img: { url: 'https://adx1public.s3.amazonaws.com/creatives_icon.png', w: 100, h: 100 } }, - { id: 5, img: { url: 'https://adx1public.s3.amazonaws.com/creatives_image.png', w: 300, h: 300 } } - ], - link: { url: 'http://brand.com/' } - } - }; - const ortbResponse = { - seatbid: [{ - bid: [{ - impid: ortbRequest.imp[0].id, - price: 1.25, - nurl: 'http://rtb.adx1.com/log', - adm: JSON.stringify(nativeResponse) - }] - }], - cur: 'USD', - }; - const bids = spec.interpretResponse({ body: ortbResponse }, request); - // verify bid - const bid = bids[0]; - expect(bid.cpm).to.equal(1.25); - expect(bid.adId).to.equal('bid12345'); - expect(bid.ad).to.be.undefined; - expect(bid.mediaType).to.equal('native'); - const nativeBid = bid['native']; - expect(nativeBid).to.not.equal(null); - expect(nativeBid.title).to.equal('Ad Title'); - expect(nativeBid.sponsoredBy).to.equal('Brand'); - expect(nativeBid.icon.url).to.equal('https://adx1public.s3.amazonaws.com/creatives_icon.png'); - expect(nativeBid.image.url).to.equal('https://adx1public.s3.amazonaws.com/creatives_image.png'); - expect(nativeBid.image.width).to.equal(300); - expect(nativeBid.image.height).to.equal(300); - expect(nativeBid.icon.width).to.equal(100); - expect(nativeBid.icon.height).to.equal(100); - expect(nativeBid.clickUrl).to.equal(encodeURIComponent('http://brand.com/')); - expect(nativeBid.impressionTrackers).to.have.lengthOf(1); - expect(nativeBid.impressionTrackers[0]).to.equal('http://rtb.adx1.com/log'); - }); - - it('Verify Video request', function () { - const request = spec.buildRequests(videoSlotConfig); - expect(request.url).to.equal('//piohbdisp.hb.adx1.com/'); - expect(request.method).to.equal('POST'); - const videoRequest = JSON.parse(request.data); - // site object - expect(videoRequest.site).to.not.equal(null); - expect(videoRequest.site.publisher.id).to.equal('29521'); - expect(videoRequest.site.ref).to.equal(window.top.document.referrer); - expect(videoRequest.site.page).to.equal(getTopWindowLocation().href); - // device object - expect(videoRequest.device).to.not.equal(null); - expect(videoRequest.device.ua).to.equal(navigator.userAgent); - // slot 1 - expect(videoRequest.imp[0].tagid).to.equal('1234567'); - expect(videoRequest.imp[0].video).to.not.equal(null); - expect(videoRequest.imp[0].video.w).to.equal(640); - expect(videoRequest.imp[0].video.h).to.equal(480); - expect(videoRequest.imp[0].banner).to.equal(null); - expect(videoRequest.imp[0].native).to.equal(null); - }); - - it('Verify parse video response', function () { - const request = spec.buildRequests(videoSlotConfig); - const videoRequest = JSON.parse(request.data); - const videoResponse = { - seatbid: [{ - bid: [{ - impid: videoRequest.imp[0].id, - price: 1.90, - adm: 'http://vid.example.com/9876', - crid: '510511_754567308' - }] - }], - cur: 'USD' - }; - const bids = spec.interpretResponse({ body: videoResponse }, request); - expect(bids).to.have.lengthOf(1); - // verify first bid - const bid = bids[0]; - expect(bid.cpm).to.equal(1.90); - expect(bid.vastUrl).to.equal('http://vid.example.com/9876'); - expect(bid.crid).to.equal('510511_754567308'); - expect(bid.width).to.equal(640); - expect(bid.height).to.equal(480); - expect(bid.adId).to.equal('bid12345678'); - expect(bid.netRevenue).to.equal(true); - expect(bid.currency).to.equal('USD'); - expect(bid.ttl).to.equal(360); - }); - - it('Verifies bidder code', function () { - expect(spec.code).to.equal('platformio'); - }); - - it('Verifies supported media types', function () { - expect(spec.supportedMediaTypes).to.have.lengthOf(3); - expect(spec.supportedMediaTypes[0]).to.equal('banner'); - expect(spec.supportedMediaTypes[1]).to.equal('native'); - expect(spec.supportedMediaTypes[2]).to.equal('video'); - }); - - it('Verifies if bid request valid', function () { - expect(spec.isBidRequestValid(slotConfigs[0])).to.equal(true); - expect(spec.isBidRequestValid(slotConfigs[1])).to.equal(true); - expect(spec.isBidRequestValid(nativeSlotConfig[0])).to.equal(true); - expect(spec.isBidRequestValid(videoSlotConfig[0])).to.equal(true); - }); - - it('Verify app requests', function () { - const request = spec.buildRequests(appSlotConfig); - const ortbRequest = JSON.parse(request.data); - expect(ortbRequest.site).to.equal(null); - expect(ortbRequest.app).to.not.be.null; - expect(ortbRequest.app.publisher).to.not.equal(null); - expect(ortbRequest.app.publisher.id).to.equal('29521'); - expect(ortbRequest.app.id).to.equal('1111'); - expect(ortbRequest.app.name).to.equal('app name'); - expect(ortbRequest.app.bundle).to.equal('io.platform.apps'); - expect(ortbRequest.app.storeurl).to.equal('http://platform.io/apps'); - expect(ortbRequest.app.domain).to.equal('platform.io'); - }); - - it('Verify GDPR', function () { - const bidderRequest = { - gdprConsent: { - gdprApplies: true, - consentString: 'serialized_gpdr_data' - } - }; - const request = spec.buildRequests(slotConfigs, bidderRequest); - expect(request.url).to.equal('//piohbdisp.hb.adx1.com/'); - expect(request.method).to.equal('POST'); - const ortbRequest = JSON.parse(request.data); - expect(ortbRequest.user).to.not.equal(null); - expect(ortbRequest.user.ext).to.not.equal(null); - expect(ortbRequest.user.ext.consent).to.equal('serialized_gpdr_data'); - expect(ortbRequest.regs).to.not.equal(null); - expect(ortbRequest.regs.ext).to.not.equal(null); - expect(ortbRequest.regs.ext.gdpr).to.equal(1); - }); -}); diff --git a/test/spec/modules/playgroundxyzBidAdapter_spec.js b/test/spec/modules/playgroundxyzBidAdapter_spec.js deleted file mode 100644 index a90564003f4b..000000000000 --- a/test/spec/modules/playgroundxyzBidAdapter_spec.js +++ /dev/null @@ -1,213 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/playgroundxyzBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; -import { deepClone } from 'src/utils'; - -const URL = 'https://ads.playground.xyz/host-config/prebid?v=2'; -const GDPR_CONSENT = 'XYZ-CONSENT'; - -describe('playgroundxyzBidAdapter', function () { - const adapter = newBidder(spec); - - describe('inherited functions', function () { - it('exists and is a function', function () { - expect(adapter.callBids).to.exist.and.to.be.a('function'); - }); - }); - - describe('isBidRequestValid', function () { - let bid = { - 'bidder': 'playgroundxyz', - 'params': { - 'placementId': '10433394' - }, - 'adUnitCode': 'adunit-code', - 'sizes': [[300, 250], [320, 50]], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - }; - - it('should return true when required params found', function () { - expect(spec.isBidRequestValid(bid)).to.equal(true); - }); - - it('should return false when required params are not passed', function () { - let bid = Object.assign({}, bid); - delete bid.params; - bid.params = { - 'placementId': 0 - }; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - }); - - describe('buildRequests', function () { - let bidRequests = [ - { - 'bidder': 'playgroundxyz', - 'params': { - 'placementId': '10433394' - }, - 'adUnitCode': 'adunit-code', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - } - ]; - - it('sends bid request to ENDPOINT via POST', function () { - let bidRequest = Object.assign([], bidRequests); - - const request = spec.buildRequests(bidRequest); - const data = JSON.parse(request.data); - const banner = data.imp[0].banner; - - expect(Object.keys(data.imp[0].ext)).to.have.members(['appnexus', 'pxyz']); - expect([banner.w, banner.h]).to.deep.equal([300, 250]); - expect(banner.format).to.deep.equal([{w: 300, h: 250}, {w: 300, h: 600}]); - expect(request.url).to.equal(URL); - expect(request.method).to.equal('POST'); - }); - }) - - describe('interpretResponse', function () { - let response = { - 'id': 'bidd_id', - 'seatbid': [ { - 'bid': [ - { - 'id': '4434762738980910431', - 'impid': '221f2bdc1fbc31', - 'price': 1, - 'adid': '91673066', - 'adm': '', - 'adomain': [ 'pg.xyz' ], - 'iurl': 'http://pgxyz.com/cr?id=91673066', - 'cid': 'c_id', - 'crid': 'c_rid', - 'h': 50, - 'w': 320, - 'ext': { - 'appnexus': { - 'brand_id': 1, - 'auction_id': 1087655594852566000, - 'bidder_id': 2, - 'bid_ad_type': 0 - } - } - } - ], - 'seat': '4321' - }], - 'bidid': '6894227111893743356', - 'cur': 'AUD' - }; - - let bidderRequest = { - 'bidderCode': 'playgroundxyz' - }; - - it('should get correct bid response', function () { - let expectedResponse = [ - { - 'requestId': '221f2bdc1fbc31', - 'cpm': 1, - 'creativeId': 91673066, - 'width': 300, - 'height': 50, - 'ad': '', - 'mediaType': 'banner', - 'currency': 'AUD', - 'ttl': 300, - 'netRevenue': true - } - ]; - let result = spec.interpretResponse({ body: response }, {bidderRequest}); - expect(Object.keys(result[0])).to.have.members(Object.keys(expectedResponse[0])); - }); - - it('handles nobid response', function () { - const response = undefined; - let result = spec.interpretResponse({ body: response }, {bidderRequest}); - expect(result.length).to.equal(0); - }); - }); - - describe('buildRequests', function () { - let bidRequests = [ - { - 'bidder': 'playgroundxyz', - 'params': { - 'publisherId': 'PUB_FAKE' - }, - 'adUnitCode': 'adunit-code', - 'sizes': [[300, 250]], - 'bidId': '321db112312as', - 'bidderRequestId': '23edabce2731sd6', - 'auctionId': '12as040790a475' - } - ]; - - it('should not populate GDPR', function () { - let bidRequest = Object.assign([], bidRequests); - const request = spec.buildRequests(bidRequest); - let data = JSON.parse(request.data); - expect(data).to.not.have.property('user'); - expect(data).to.not.have.property('regs'); - }); - - it('should populate GDPR and consent string when consetString is presented but not gdpApplies', function () { - let bidRequest = Object.assign([], bidRequests); - const request = spec.buildRequests(bidRequest, {gdprConsent: {consentString: GDPR_CONSENT}}); - let data = JSON.parse(request.data); - expect(data.regs.ext.gdpr).to.equal(0); - expect(data.user.ext.consent).to.equal('XYZ-CONSENT'); - }); - - it('should populate GDPR and consent string when gdpr is set to true', function () { - let bidRequest = Object.assign([], bidRequests); - const request = spec.buildRequests(bidRequest, {gdprConsent: {gdprApplies: true, consentString: GDPR_CONSENT}}); - let data = JSON.parse(request.data); - expect(data.regs.ext.gdpr).to.equal(1); - expect(data.user.ext.consent).to.equal('XYZ-CONSENT'); - }); - - it('should populate GDPR and consent string when gdpr is set to false', function () { - let bidRequest = Object.assign([], bidRequests); - const request = spec.buildRequests(bidRequest, {gdprConsent: {gdprApplies: false, consentString: GDPR_CONSENT}}); - let data = JSON.parse(request.data); - expect(data.regs.ext.gdpr).to.equal(0); - expect(data.user.ext.consent).to.equal('XYZ-CONSENT'); - }); - }); - - describe('getUserSyncs', function () { - const syncUrl = '//ib.adnxs.com/getuidnb?https://ads.playground.xyz/usersync?partner=appnexus&uid=$UID'; - - describe('when iframeEnabled is true', function () { - const syncOptions = { - 'iframeEnabled': true - } - it('should return one image type user sync pixel', function () { - let result = spec.getUserSyncs(syncOptions); - expect(result.length).to.equal(1); - expect(result[0].type).to.equal('image') - expect(result[0].url).to.equal(syncUrl); - }); - }); - - describe('when iframeEnabled is false', function () { - const syncOptions = { - 'iframeEnabled': false - } - it('should return one image type user sync pixel', function () { - let result = spec.getUserSyncs(syncOptions); - expect(result.length).to.equal(1); - expect(result[0].type).to.equal('image') - expect(result[0].url).to.equal(syncUrl); - }); - }); - }) -}); diff --git a/test/spec/modules/polluxBidAdapter_spec.js b/test/spec/modules/polluxBidAdapter_spec.js deleted file mode 100644 index 22c7f470f83f..000000000000 --- a/test/spec/modules/polluxBidAdapter_spec.js +++ /dev/null @@ -1,207 +0,0 @@ -import {expect} from 'chai'; -import {spec} from 'modules/polluxBidAdapter'; -import {utils} from 'src/utils'; -import {newBidder} from 'src/adapters/bidderFactory'; -import { parseQS } from 'src/url'; - -describe('POLLUX Bid Adapter tests', function () { - // ad units setup - const setup_single_bid = [{ - placementCode: 'div-gpt-ad-1460505661587-0', - bidId: '789s6354sfg856', - bidderUrl: '//adn.polluxnetwork.com/prebid/v1', - sizes: [[728, 90], [300, 250]], - params: {zone: '1806,276'} - }]; - const setup_multi_bid = [{ - placementCode: 'div-gpt-ad-1460505661639-0', - bidId: '21fe992ca48d55', - sizes: [[300, 250]], - params: {zone: '1806'} - }, { - placementCode: 'div-gpt-ad-1460505661812-0', - bidId: '23kljh54390534', - sizes: [[728, 90]], - params: {zone: '276'} - }]; - - it('TEST: verify buildRequests no valid bid requests', function () { - let request = spec.buildRequests(false); - expect(request).to.not.equal(null); - expect(request).to.not.have.property('method'); - expect(request).to.not.have.property('url'); - expect(request).to.not.have.property('data'); - request = spec.buildRequests([]); - expect(request).to.not.equal(null); - expect(request).to.not.have.property('method'); - expect(request).to.not.have.property('url'); - expect(request).to.not.have.property('data'); - request = spec.buildRequests({}); - expect(request).to.not.equal(null); - expect(request).to.not.have.property('method'); - expect(request).to.not.have.property('url'); - expect(request).to.not.have.property('data'); - request = spec.buildRequests(null); - expect(request).to.not.equal(null); - expect(request).to.not.have.property('method'); - expect(request).to.not.have.property('url'); - expect(request).to.not.have.property('data'); - }); - - it('TEST: verify buildRequests single bid', function () { - const request = spec.buildRequests(setup_single_bid); - expect(request.method).to.equal('POST'); - const requested_bids = JSON.parse(request.data); - // bids request - expect(requested_bids).to.not.equal(null); - expect(requested_bids).to.have.lengthOf(1); - // bid objects - expect(requested_bids[0]).to.not.equal(null); - expect(requested_bids[0]).to.have.property('bidId'); - expect(requested_bids[0]).to.have.property('sizes'); - expect(requested_bids[0]).to.have.property('zones'); - // bid 0 - expect(requested_bids[0].bidId).to.equal('789s6354sfg856'); - expect(requested_bids[0].sizes).to.not.equal(null); - expect(requested_bids[0].sizes).to.have.lengthOf(2); - expect(requested_bids[0].sizes[0][0]).to.equal(728); - expect(requested_bids[0].sizes[0][1]).to.equal(90); - expect(requested_bids[0].sizes[1][0]).to.equal(300); - expect(requested_bids[0].sizes[1][1]).to.equal(250); - expect(requested_bids[0].zones).to.equal('1806,276'); - }); - - it('TEST: verify buildRequests multi bid', function () { - const request = spec.buildRequests(setup_multi_bid); - expect(request.method).to.equal('POST'); - const requested_bids = JSON.parse(request.data); - // bids request - expect(requested_bids).to.not.equal(null); - expect(requested_bids).to.have.lengthOf(2); - // bid objects - expect(requested_bids[0]).to.not.equal(null); - expect(requested_bids[0]).to.have.property('bidId'); - expect(requested_bids[0]).to.have.property('sizes'); - expect(requested_bids[0]).to.have.property('zones'); - expect(requested_bids[1]).to.not.equal(null); - expect(requested_bids[1]).to.have.property('bidId'); - expect(requested_bids[1]).to.have.property('sizes'); - expect(requested_bids[1]).to.have.property('zones'); - // bid 0 - expect(requested_bids[0].bidId).to.equal('21fe992ca48d55'); - expect(requested_bids[0].sizes).to.not.equal(null); - expect(requested_bids[0].sizes).to.have.lengthOf(1); - expect(requested_bids[0].sizes[0][0]).to.equal(300); - expect(requested_bids[0].sizes[0][1]).to.equal(250); - expect(requested_bids[0].zones).to.equal('1806'); - // bid 1 - expect(requested_bids[1].bidId).to.equal('23kljh54390534'); - expect(requested_bids[1].sizes).to.not.equal(null); - expect(requested_bids[1].sizes).to.have.lengthOf(1); - expect(requested_bids[1].sizes[0][0]).to.equal(728); - expect(requested_bids[1].sizes[0][1]).to.equal(90); - expect(requested_bids[1].zones).to.equal('276'); - }); - - it('TEST: verify interpretResponse empty', function () { - let bids = spec.interpretResponse(false, {}); - expect(bids).to.not.equal(null); - expect(bids).to.have.lengthOf(0); - bids = spec.interpretResponse([], {}); - expect(bids).to.not.equal(null); - expect(bids).to.have.lengthOf(0); - bids = spec.interpretResponse({}, {}); - expect(bids).to.not.equal(null); - expect(bids).to.have.lengthOf(0); - bids = spec.interpretResponse(null, {}); - expect(bids).to.not.equal(null); - expect(bids).to.have.lengthOf(0); - }); - - it('TEST: verify interpretResponse ad_type url', function () { - const serverResponse = { - body: [ - { - bidId: '789s6354sfg856', - cpm: '2.15', - width: '728', - height: '90', - ad: 'http://adn.polluxnetwork.com/zone/276?_plx_prebid=1&_plx_campaign=1125', - ad_type: 'url', - creativeId: '1125', - referrer: 'http://www.example.com' - } - ] - }; - const bids = spec.interpretResponse(serverResponse, {}); - expect(bids).to.have.lengthOf(1); - expect(bids[0].requestId).to.equal('789s6354sfg856'); - expect(bids[0].cpm).to.equal(2.15); - expect(bids[0].width).to.equal(728); - expect(bids[0].height).to.equal(90); - expect(bids[0].ttl).to.equal(3600); - expect(bids[0].creativeId).to.equal('1125'); - expect(bids[0].netRevenue).to.equal(true); - expect(bids[0].currency).to.equal('EUR'); - expect(bids[0].referrer).to.equal('http://www.example.com'); - expect(bids[0].adUrl).to.equal('http://adn.polluxnetwork.com/zone/276?_plx_prebid=1&_plx_campaign=1125'); - expect(bids[0]).to.not.have.property('ad'); - }); - - it('TEST: verify interpretResponse ad_type html', function () { - const serverResponse = { - body: [ - { - bidId: '789s6354sfg856', - cpm: '2.15', - width: '728', - height: '90', - ad: '

I am an ad

', - ad_type: 'html', - creativeId: '1125' - } - ] - }; - const bids = spec.interpretResponse(serverResponse, {}); - expect(bids).to.have.lengthOf(1); - expect(bids[0].requestId).to.equal('789s6354sfg856'); - expect(bids[0].cpm).to.equal(2.15); - expect(bids[0].width).to.equal(728); - expect(bids[0].height).to.equal(90); - expect(bids[0].ttl).to.equal(3600); - expect(bids[0].creativeId).to.equal('1125'); - expect(bids[0].netRevenue).to.equal(true); - expect(bids[0].currency).to.equal('EUR'); - expect(bids[0]).to.not.have.property('referrer'); - expect(bids[0]).to.not.have.property('adUrl'); - expect(bids[0].ad).to.equal('

I am an ad

'); - }); - - it('TEST: verify url and query params', function () { - const URL = require('url-parse'); - const request = spec.buildRequests(setup_single_bid); - const parsedUrl = new URL('https:' + request.url); - expect(parsedUrl.origin).to.equal('https://adn.polluxnetwork.com'); - expect(parsedUrl.pathname).to.equal('/prebid/v1'); - expect(parsedUrl).to.have.property('query'); - const parsedQuery = parseQS(parsedUrl.query); - expect(parsedQuery).to.have.property('domain').and.to.have.length.above(1); - }); - - it('TEST: verify isBidRequestValid', function () { - expect(spec.isBidRequestValid({})).to.equal(false); - expect(spec.isBidRequestValid({params: {}})).to.equal(false); - expect(spec.isBidRequestValid(setup_single_bid[0])).to.equal(true); - expect(spec.isBidRequestValid(setup_multi_bid[0])).to.equal(true); - expect(spec.isBidRequestValid(setup_multi_bid[1])).to.equal(true); - }); - - it('TEST: verify bidder code', function () { - expect(spec.code).to.equal('pollux'); - }); - - it('TEST: verify bidder aliases', function () { - expect(spec.aliases).to.have.lengthOf(1); - expect(spec.aliases[0]).to.equal('plx'); - }); -}); diff --git a/test/spec/modules/polymorphBidAdapter_spec.js b/test/spec/modules/polymorphBidAdapter_spec.js deleted file mode 100644 index 6fd4bd902882..000000000000 --- a/test/spec/modules/polymorphBidAdapter_spec.js +++ /dev/null @@ -1,219 +0,0 @@ -import { expect } from 'chai'; -import { polymorphAdapterSpec } from 'modules/polymorphBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; - -const BIDDER_CODE = 'polymorph'; -const ENDPOINT_URL = '//api.adsnative.com/v1/ad-template.json'; -const PLACEMENT_ID = 'ping'; -const NETWORK_KEY = 'abcd1234'; -const WIDGET_ID = 'xyz'; -const CATEGORIES = 'IAB1,IAB2'; - -const spec = newBidder(polymorphAdapterSpec).getSpec(); - -const bidRequests = [{ - 'bidder': BIDDER_CODE, - 'params': { - 'placementId': PLACEMENT_ID - }, - 'adUnitCode': 'adunit-code', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', -}, -{ - 'bidder': BIDDER_CODE, - 'params': { - 'placementId': PLACEMENT_ID, - 'defaultWidth': 300, - 'defaultHeight': 600, - }, - 'adUnitCode': 'adunit-code', - 'sizes': [[700, 250], [300, 600]], - 'bidId': '30b31c1838de1d', - 'bidderRequestId': '22edbae2733bf7', - 'auctionId': '1d1a030790a476', -}, -{ - 'bidder': BIDDER_CODE, - 'params': { - 'network_key': NETWORK_KEY, - 'widget_id': WIDGET_ID, - 'cat': CATEGORIES - }, - 'adUnitCode': 'adunit-code', - 'sizes': [[700, 250], [300, 600]], - 'bidId': '30b31c1838de1f', - 'bidderRequestId': '22edbae2733bf7', - 'auctionId': '1d1a030790a476', -}]; - -describe('Polymorph adapter test', function () { - describe('.code', function () { - it('should return a bidder code of polymorph', function () { - expect(spec.code).to.eql(BIDDER_CODE); - }); - }); - - describe('isBidRequestValid', function () { - it('should return true when required params found', function () { - expect(spec.isBidRequestValid(bidRequests[0])).to.equal(true); - }); - - it('should return true when required params found', function () { - expect(spec.isBidRequestValid(bidRequests[2])).to.equal(true); - }); - - it('should return false if req has no placementId', function () { - const invalidBidRequest = { - bidder: BIDDER_CODE, - params: { - someKey: 'abc123' - } - }; - expect(spec.isBidRequestValid(invalidBidRequest)).to.eql(false); - }); - - it('should return false if req has wrong bidder code', function () { - const invalidBidRequest = { - bidder: 'something', - params: { - someKey: 'abc123' - } - }; - expect(spec.isBidRequestValid(invalidBidRequest)).to.eql(false); - }); - }); - - describe('buildRequests', function () { - it('payload test', function () { - const requests = spec.buildRequests(bidRequests); - var payload1 = {}; - requests[0].data.replace(/([^=&]+)=([^&]*)/g, function(m, key, value) { - payload1[decodeURIComponent(key)] = decodeURIComponent(value); - }); - expect(payload1.ref).to.not.be.undefined; - expect(payload1.url).to.not.be.undefined; - expect(payload1.hb).to.equal('1'); - expect(payload1.hb_source).to.equal('prebid'); - expect(payload1.zid).to.equal(PLACEMENT_ID); - expect(payload1.sizes).to.equal('300,250,300,600'); - expect(payload1.bid_id).to.equal('30b31c1838de1e'); - - var payload2 = {}; - requests[1].data.replace(/([^=&]+)=([^&]*)/g, function(m, key, value) { - payload2[decodeURIComponent(key)] = decodeURIComponent(value); - }); - expect(payload2.ref).to.not.be.undefined; - expect(payload2.url).to.not.be.undefined; - expect(payload2.hb).to.equal('1'); - expect(payload2.hb_source).to.equal('prebid'); - expect(payload2.zid).to.equal(PLACEMENT_ID); - expect(payload2.sizes).to.equal('700,250,300,600'); - expect(payload2.bid_id).to.equal('30b31c1838de1d'); - - var payload3 = {}; - requests[2].data.replace(/([^=&]+)=([^&]*)/g, function(m, key, value) { - payload3[decodeURIComponent(key)] = decodeURIComponent(value); - }); - expect(payload3.ref).to.not.be.undefined; - expect(payload3.url).to.not.be.undefined; - expect(payload3.hb).to.equal('1'); - expect(payload3.hb_source).to.equal('prebid'); - expect(payload3.network_key).to.equal(NETWORK_KEY); - expect(payload3.widget_id).to.equal(WIDGET_ID); - expect(payload3.cat).to.equal(CATEGORIES); - expect(payload3.sizes).to.equal('700,250,300,600'); - expect(payload3.bid_id).to.equal('30b31c1838de1f'); - }); - - it('sends bid request to ENDPOINT via GET', function () { - const requests = spec.buildRequests(bidRequests); - expect(requests[0].url).to.equal(ENDPOINT_URL); - expect(requests[0].method).to.equal('GET'); - }); - }); - - describe('interpretResponse', function () { - const response = { - body: { - 'status': 'OK', - 'crid': '5ISP4995', - 'ecpm': 10, - 'ad': { - 'html': '
', - 'height': 250, - 'width': 300 - } - } - }; - - const response2 = { - body: { - 'status': 'OK', - 'ecpm': 10, - 'html': '', - 'ads': [{ - 'crid': '5ISP4995', - 'ad': { - 'html': '
' - } - }, - { - 'crid': '5ISP4996', - 'ad': { - 'html': '
' - } - }] - } - }; - - it('should get correct bid response', function () { - const body = response.body; - const expectedResponse = [{ - requestId: bidRequests[0].bidId, - cpm: body.ecpm, - width: body.ad.width, - height: body.ad.height, - ad: body.ad.html, - ttl: 3600, - creativeId: body.crid, - netRevenue: false, - currency: 'USD', - mediaType: 'banner' - }]; - - let result = spec.interpretResponse(response, { 'bidderRequest': bidRequests[0] }); - expect(result).to.deep.equal(expectedResponse); - }); - - it('widget use case', function () { - const body = response2.body; - const expectedResponse = [ - { - requestId: bidRequests[1].bidId, - cpm: body.ecpm, - width: 300, - height: 600, - ad: body.html, - ttl: 3600, - creativeId: body.ads[0].crid, - netRevenue: false, - currency: 'USD', - mediaType: 'banner' - } - ]; - - let result = spec.interpretResponse(response2, { 'bidderRequest': bidRequests[1] }); - expect(result).to.deep.equal(expectedResponse); - }); - - it('handles nobid responses', function () { - let response = []; - - let result = spec.interpretResponse(response, { 'bidderRequest': bidRequests[0] }); - expect(result.length).to.equal(0); - }); - }); -}); diff --git a/test/spec/modules/prebidServerBidAdapter_spec.js b/test/spec/modules/prebidServerBidAdapter_spec.js index c198502d4b3c..f685103b5cb1 100644 --- a/test/spec/modules/prebidServerBidAdapter_spec.js +++ b/test/spec/modules/prebidServerBidAdapter_spec.js @@ -13,7 +13,7 @@ let CONFIG = { bidders: ['appnexus'], timeout: 1000, cacheMarkup: 2, - endpoint: 'https://prebid.adnxs.com/pbs/v1/auction' + endpoint: 'https://prebid.adnxs.com/pbs/v1/openrtb2/auction' }; const REQUEST = { @@ -165,67 +165,6 @@ const OUTSTREAM_VIDEO_REQUEST = { let BID_REQUESTS; -const RESPONSE = { - 'tid': '437fbbf5-33f5-487a-8e16-a7112903cfe5', - 'status': 'OK', - 'bidder_status': [ - { - 'bidder': 'appnexus', - 'response_time_ms': 52, - 'num_bids': 1 - } - ], - 'bids': [ - { - 'bid_id': '123', - 'code': 'div-gpt-ad-1460505748561-0', - 'creative_id': '29681110', - 'bidder': 'appnexus', - 'price': 0.5, - 'adm': '', - 'width': 300, - 'height': 250, - 'deal_id': 'test-dealid', - 'ad_server_targeting': { - 'foo': 'bar' - }, - 'cache_id': '7654321', - 'cache_url': 'http://www.test.com/cache?uuid=7654321', - } - ] -}; - -const VIDEO_RESPONSE = { - 'tid': '437fbbf5-33f5-487a-8e16-a7112903cfe5', - 'status': 'OK', - 'bidder_status': [ - { - 'bidder': 'appnexus', - 'response_time_ms': 52, - 'num_bids': 1 - } - ], - 'bids': [ - { - 'bid_id': '123', - 'code': 'div-gpt-ad-1460505748561-0', - 'creative_id': '29681110', - 'bidder': 'appnexus', - 'price': 0.5, - 'adm': '', - 'width': 300, - 'height': 250, - 'deal_id': 'test-dealid', - 'ad_server_targeting': { - 'foo': 'bar' - }, - 'media_type': 'video', - 'cache_id': 'video_cache_id', - 'cache_url': 'video_cache_url', - } - ] -}; - const RESPONSE_NO_BID_NO_UNIT = { 'tid': '437fbbf5-33f5-487a-8e16-a7112903cfe5', 'status': 'OK', @@ -301,26 +240,6 @@ const RESPONSE_NO_PBS_COOKIE = { }] }; -const RESPONSE_NO_PBS_COOKIE_ERROR = { - 'tid': '882fe33e-2981-4257-bd44-bd3b0394545f', - 'status': 'no_cookie', - 'bidder_status': [{ - 'bidder': 'rubicon', - 'no_cookie': true, - 'usersync': { - 'url': 'https://pixel.rubiconproject.com/exchange/sync.php?p=prebid', - 'type': 'jsonp' - } - }, { - 'bidder': 'pubmatic', - 'no_cookie': true, - 'usersync': { - 'url': '', - 'type': 'iframe' - } - }] -}; - const RESPONSE_OPENRTB = { 'id': 'c7dcf14f', 'seatbid': [ @@ -336,6 +255,7 @@ const RESPONSE_OPENRTB = { 'iurl': 'http://lax1-ib.adnxs.com/cr?id=2968111', 'cid': '958', 'crid': '2968111', + 'dealid': 'test-dealid', 'w': 300, 'h': 250, 'ext': { @@ -375,6 +295,7 @@ const RESPONSE_OPENRTB_VIDEO = { iurl: 'http://lax1-ib.adnxs.com/cr?id=81877115', cid: '3535', crid: '81877115', + dealid: 'test-dealid', w: 1, h: 1, ext: { @@ -502,15 +423,6 @@ const RESPONSE_OPENRTB_NATIVE = { ] }; -const RESPONSE_UNSUPPORTED_BIDDER = { - 'tid': '437fbbf5-33f5-487a-8e16-a7112903cfe5', - 'status': 'OK', - 'bidder_status': [{ - 'bidder': '33Across', - 'error': 'Unsupported bidder' - }] -}; - describe('S2S Adapter', function () { let adapter, addBidResponse = sinon.spy(), @@ -552,7 +464,10 @@ describe('S2S Adapter', function () { 'auctionStart': 1510852447530, 'timeout': 5000, 'src': 's2s', - 'doneCbCallCount': 0 + 'doneCbCallCount': 0, + 'refererInfo': { + 'referer': 'http://mytestpage.com' + } } ]; }); @@ -594,15 +509,6 @@ describe('S2S Adapter', function () { expect(adapter.callBids).to.exist.and.to.be.a('function'); }); - it('exists converts types', function () { - config.setConfig({ s2sConfig: CONFIG }); - adapter.callBids(REQUEST, BID_REQUESTS, addBidResponse, done, ajax); - const requestBid = JSON.parse(requests[0].requestBody); - expect(requestBid).to.have.property('cache_markup', 2); - expect(requestBid.ad_units[0].bids[0].params.placementId).to.exist.and.to.be.a('number'); - expect(requestBid.ad_units[0].bids[0].params.member).to.exist.and.to.be.a('string'); - }); - describe('gdpr tests', function () { afterEach(function () { config.resetConfig(); @@ -805,16 +711,6 @@ describe('S2S Adapter', function () { }); }); - it('sets invalid cacheMarkup value to 0', function () { - const s2sConfig = Object.assign({}, CONFIG, { - cacheMarkup: 999 - }); - config.setConfig({ s2sConfig: s2sConfig }); - adapter.callBids(REQUEST, BID_REQUESTS, addBidResponse, done, ajax); - const requestBid = JSON.parse(requests[0].requestBody); - expect(requestBid).to.have.property('cache_markup', 0); - }); - it('adds digitrust id is present and user is not optout', function () { let ortb2Config = utils.deepClone(CONFIG); ortb2Config.endpoint = 'https://prebid.adnxs.com/pbs/v1/openrtb2/auction'; @@ -1086,27 +982,6 @@ describe('S2S Adapter', function () { key: 'fizz', value: ['buzz'] }]); - - config.resetConfig(); - const oldS2sConfig = Object.assign({}, CONFIG); - config.setConfig({ s2sConfig: oldS2sConfig }); - - const myRequest2 = utils.deepClone(REQUEST); - myRequest2.ad_units[0].bids[0].params.keywords = { - foo: ['bar', 'baz'], - fizz: ['buzz'] - }; - - adapter.callBids(myRequest2, BID_REQUESTS, addBidResponse, done, ajax); - const requestBid2 = JSON.parse(requests[1].requestBody); - - expect(requestBid2.ad_units[0].bids[0].params.keywords).to.exist.and.to.deep.equal([{ - key: 'foo', - value: ['bar', 'baz'] - }, { - key: 'fizz', - value: ['buzz'] - }]); }); it('adds limit to the cookie_sync request if userSyncLimit is greater than 0', function () { @@ -1442,47 +1317,6 @@ describe('S2S Adapter', function () { }); // TODO: test dependent on pbjs_api_spec. Needs to be isolated - it('registers bids and calls BIDDER_DONE', function () { - server.respondWith(JSON.stringify(RESPONSE)); - - config.setConfig({ s2sConfig: CONFIG }); - adapter.callBids(REQUEST, BID_REQUESTS, addBidResponse, done, ajax); - server.respond(); - sinon.assert.calledOnce(addBidResponse); - - sinon.assert.calledOnce(events.emit); - const event = events.emit.firstCall.args; - expect(event[0]).to.equal(CONSTANTS.EVENTS.BIDDER_DONE); - expect(event[1].bids[0]).to.have.property('serverResponseTimeMs', 52); - - const response = addBidResponse.firstCall.args[1]; - expect(response).to.have.property('statusMessage', 'Bid available'); - expect(response).to.have.property('cpm', 0.5); - expect(response).to.have.property('requestId', '123'); - expect(response).to.not.have.property('videoCacheKey'); - expect(response).to.have.property('cache_id', '7654321'); - expect(response).to.have.property('cache_url', 'http://www.test.com/cache?uuid=7654321'); - expect(response).to.not.have.property('vastUrl'); - }); - - it('registers video bids', function () { - server.respondWith(JSON.stringify(VIDEO_RESPONSE)); - - config.setConfig({ s2sConfig: CONFIG }); - adapter.callBids(VIDEO_REQUEST, BID_REQUESTS, addBidResponse, done, ajax); - server.respond(); - sinon.assert.calledOnce(addBidResponse); - - const response = addBidResponse.firstCall.args[1]; - expect(response).to.have.property('statusMessage', 'Bid available'); - expect(response).to.have.property('cpm', 0.5); - expect(response).to.have.property('requestId', '123'); - expect(response).to.have.property('videoCacheKey', 'video_cache_id'); - expect(response).to.have.property('cache_id', 'video_cache_id'); - expect(response).to.have.property('cache_url', 'video_cache_url'); - expect(response).to.have.property('vastUrl', 'video_cache_url'); - }); - it('does not call addBidResponse and calls done when ad unit not set', function () { server.respondWith(JSON.stringify(RESPONSE_NO_BID_NO_UNIT)); @@ -1517,7 +1351,7 @@ describe('S2S Adapter', function () { }); it('registers successful bids and calls done when there are less bids than requests', function () { - server.respondWith(JSON.stringify(RESPONSE)); + server.respondWith(JSON.stringify(RESPONSE_OPENRTB)); config.setConfig({ s2sConfig: CONFIG }); adapter.callBids(REQUEST, BID_REQUESTS, addBidResponse, done, ajax); @@ -1535,7 +1369,7 @@ describe('S2S Adapter', function () { }); it('should have dealId in bidObject', function () { - server.respondWith(JSON.stringify(RESPONSE)); + server.respondWith(JSON.stringify(RESPONSE_OPENRTB)); config.setConfig({ s2sConfig: CONFIG }); adapter.callBids(REQUEST, BID_REQUESTS, addBidResponse, done, ajax); @@ -1544,12 +1378,47 @@ describe('S2S Adapter', function () { expect(response).to.have.property('dealId', 'test-dealid'); }); - it('should pass through default adserverTargeting if present in bidObject', function () { - server.respondWith(JSON.stringify(RESPONSE)); + it('should pass through default adserverTargeting if present in bidObject for video request', function () { + config.setConfig({s2sConfig: CONFIG}); + const cacheResponse = utils.deepClone(RESPONSE_OPENRTB); + const targetingTestData = { + hb_cache_path: '/cache', + hb_cache_host: 'prebid-cache.testurl.com' + }; + + cacheResponse.seatbid.forEach(item => { + item.bid[0].ext.prebid.targeting = targetingTestData + }); + server.respondWith(JSON.stringify(cacheResponse)); + adapter.callBids(VIDEO_REQUEST, BID_REQUESTS, addBidResponse, done, ajax); + server.respond(); + + sinon.assert.calledOnce(addBidResponse); + const response = addBidResponse.firstCall.args[1]; + expect(response).to.have.property('adserverTargeting'); + expect(response.adserverTargeting).to.deep.equal({ + 'hb_cache_path': '/cache', + 'hb_cache_host': 'prebid-cache.testurl.com' + }); + }); + + it('should pass through default adserverTargeting if present in bidObject for banner request', function () { + const cacheResponse = utils.deepClone(RESPONSE_OPENRTB); + + const targetingTestData = { + 'foo': 'bar' + }; + + cacheResponse.seatbid.forEach(item => { + item.bid[0].ext.prebid.targeting = targetingTestData + }); + + server.respondWith(JSON.stringify(cacheResponse)); config.setConfig({ s2sConfig: CONFIG }); adapter.callBids(REQUEST, BID_REQUESTS, addBidResponse, done, ajax); server.respond(); + sinon.assert.calledOnce(addBidResponse); const response = addBidResponse.firstCall.args[1]; expect(response).to.have.property('adserverTargeting').that.deep.equals({ 'foo': 'bar' }); }); @@ -1591,25 +1460,6 @@ describe('S2S Adapter', function () { adapterManager.getBidAdapter.restore(); }); - it('registers bid responses when server requests cookie sync', function () { - server.respondWith(JSON.stringify(RESPONSE_NO_PBS_COOKIE)); - - config.setConfig({ s2sConfig: CONFIG }); - adapter.callBids(REQUEST, BID_REQUESTS, addBidResponse, done, ajax); - server.respond(); - sinon.assert.calledOnce(addBidResponse); - - const ad_unit_code = addBidResponse.firstCall.args[0]; - expect(ad_unit_code).to.equal('div-gpt-ad-1460505748561-0'); - - const response = addBidResponse.firstCall.args[1]; - expect(response).to.have.property('statusMessage', 'Bid available'); - expect(response).to.have.property('source', 's2s'); - - const bid_request_passed = addBidResponse.firstCall.args[1]; - expect(bid_request_passed).to.have.property('requestId', '123'); - }); - it('handles OpenRTB responses and call BIDDER_DONE', function () { const s2sConfig = Object.assign({}, CONFIG, { endpoint: 'https://prebid.adnxs.com/pbs/v1/openrtb2/auction' @@ -1631,6 +1481,8 @@ describe('S2S Adapter', function () { expect(response).to.have.property('bidderCode', 'appnexus'); expect(response).to.have.property('requestId', '123'); expect(response).to.have.property('cpm', 0.5); + expect(response).to.not.have.property('vastUrl'); + expect(response).to.not.have.property('videoCacheKey'); }); it('handles OpenRTB video responses', function () { @@ -1758,25 +1610,6 @@ describe('S2S Adapter', function () { utils.getBidRequest.restore(); }); - - it('should log warning for unsupported bidder', function () { - server.respondWith(JSON.stringify(RESPONSE_UNSUPPORTED_BIDDER)); - - const s2sConfig = Object.assign({}, CONFIG, { - bidders: ['33Across'] - }); - - const _config = { - s2sConfig: s2sConfig, - }; - - config.setConfig(_config); - config.setConfig({ s2sConfig: CONFIG }); - adapter.callBids(REQUEST, BID_REQUESTS, addBidResponse, done, ajax); - server.respond(); - - sinon.assert.calledOnce(logWarnSpy); - }); }); describe('s2sConfig', function () { @@ -1803,7 +1636,7 @@ describe('S2S Adapter', function () { bidders: ['appnexus'], timeout: 1000, adapter: 'prebidServer', - endpoint: 'https://prebid.adnxs.com/pbs/v1/auction' + endpoint: 'https://prebid.adnxs.com/pbs/v1/openrtb2/auction' }; config.setConfig({ s2sConfig: options }); @@ -1816,7 +1649,7 @@ describe('S2S Adapter', function () { enabled: true, timeout: 1000, adapter: 's2s', - endpoint: 'https://prebid.adnxs.com/pbs/v1/auction' + endpoint: 'https://prebid.adnxs.com/pbs/v1/openrtb2/auction' }; config.setConfig({ s2sConfig: options }); @@ -1919,7 +1752,7 @@ describe('S2S Adapter', function () { bidders: ['rubicon'], defaultVendor: 'rubicon', endpoint: '//prebid-server.rubiconproject.com/openrtb2/auction', - syncEndpoint: '//prebid-server.rubiconproject.com/cookie_sync' + syncEndpoint: '//prebid-server.rubiconproject.com/cookie_sync', }) }); diff --git a/test/spec/modules/projectLimeLightBidAdapter_spec.js b/test/spec/modules/projectLimeLightBidAdapter_spec.js index 434b3fbccb52..f51e1188b730 100644 --- a/test/spec/modules/projectLimeLightBidAdapter_spec.js +++ b/test/spec/modules/projectLimeLightBidAdapter_spec.js @@ -28,7 +28,7 @@ describe('ProjectLimeLightAdapter', function () { expect(serverRequest.method).to.equal('POST'); }); it('Returns valid URL', function () { - expect(serverRequest.url).to.equal('//ads.project-limelight.com/hb'); + expect(serverRequest.url).to.equal('https://ads.project-limelight.com/hb'); }); it('Returns valid data if array of bids is valid', function () { let data = serverRequest.data; diff --git a/test/spec/modules/pubnxBidAdapter_spec.js b/test/spec/modules/pubnxBidAdapter_spec.js deleted file mode 100644 index 002922fa066c..000000000000 --- a/test/spec/modules/pubnxBidAdapter_spec.js +++ /dev/null @@ -1,112 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/pubnxBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; - -const BASE_URI = '//hb.pubnxserv.com/vzhbidder/bid?'; - -describe('PubNXAdapter', function () { - const adapter = newBidder(spec); - - describe('inherited functions', function () { - it('exists and is a function', function () { - expect(adapter.callBids).to.exist.and.to.be.a('function'); - }); - }); - - describe('isBidRequestValid', function () { - let bid = { - 'bidder': 'pubnx', - 'params': { - 'placementId': 'PNX-HB-G396432V4809F3' - }, - 'adUnitCode': 'adunit-code', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - }; - - it('should return true when required params found', function () { - expect(spec.isBidRequestValid(bid)).to.equal(true); - }); - - it('should return false when required params are not passed', function () { - let bid = Object.assign({}, bid); - delete bid.params; - bid.params = { - 'placementId': 0 - }; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - }); - - describe('buildRequests', function () { - let bidRequests = [ - { - 'bidder': 'pubnx', - 'params': { - 'placementId': '10433394' - }, - 'adUnitCode': 'adunit-code', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - } - ]; - - it('sends bid request to ENDPOINT via POST', function () { - const request = spec.buildRequests(bidRequests)[0]; - expect(request.url).to.equal(BASE_URI); - expect(request.method).to.equal('POST'); - }); - }); - - describe('interpretResponse', function () { - let response = { - 'vzhPlacementId': 'PNX-HB-G396432V4809F3', - 'bid': '76021e56-adaf-4114-b68d-ccacd1b3e551_1', - 'adWidth': '300', - 'adHeight': '250', - 'cpm': '0.16312590000000002', - 'ad': '', - 'slotBidId': '44b3fcfd24aa93', - 'nurl': '', - 'statusText': 'Success' - }; - - it('should get correct bid response', function () { - let expectedResponse = [ - { - 'requestId': '44b3fcfd24aa93', - 'cpm': 0.16312590000000002, - 'width': 300, - 'height': 250, - 'netRevenue': true, - 'mediaType': 'banner', - 'currency': 'USD', - 'dealId': null, - 'creativeId': null, - 'ttl': 300, - 'ad': '' - } - ]; - let bidderRequest; - let result = spec.interpretResponse({body: response}); - expect(Object.keys(result[0])).to.have.members(Object.keys(expectedResponse[0])); - expect(result[0].cpm).to.not.equal(null); - }); - - it('handles nobid responses', function () { - let response = { - 'vzhPlacementId': 'PNX-HB-G396432V4809F3', - 'slotBidId': 'f00412ac86b79', - 'statusText': 'NO_BIDS' - }; - let bidderRequest; - - let result = spec.interpretResponse({body: response}); - expect(result.length).to.equal(0); - }); - }); -}); diff --git a/test/spec/modules/pulsepointBidAdapter_spec.js b/test/spec/modules/pulsepointBidAdapter_spec.js index 6ab05a0a0010..80cf00d2ff83 100644 --- a/test/spec/modules/pulsepointBidAdapter_spec.js +++ b/test/spec/modules/pulsepointBidAdapter_spec.js @@ -42,7 +42,7 @@ describe('PulsePoint Adapter Tests', function () { ct: 't10000', app: { bundle: 'com.pulsepoint.apps', - storeUrl: 'http://pulsepoint.com/apps', + storeUrl: 'https://pulsepoint.com/apps', domain: 'pulsepoint.com', } } @@ -318,10 +318,10 @@ describe('PulsePoint Adapter Tests', function () { assets: [ { title: { text: 'Ad Title' } }, { data: { type: 1, value: 'Sponsored By: Brand' } }, - { img: { type: 3, url: 'http://images.cdn.brand.com/123' } } + { img: { type: 3, url: 'https://images.cdn.brand.com/123' } } ], - link: { url: 'http://brand.clickme.com/' }, - imptrackers: ['http://imp1.trackme.com/', 'http://imp1.contextweb.com/'] + link: { url: 'https://brand.clickme.com/' }, + imptrackers: ['https://imp1.trackme.com/', 'https://imp1.contextweb.com/'] } }; const ortbResponse = { @@ -344,11 +344,11 @@ describe('PulsePoint Adapter Tests', function () { expect(nativeBid).to.not.equal(null); expect(nativeBid.title).to.equal('Ad Title'); expect(nativeBid.sponsoredBy).to.equal('Sponsored By: Brand'); - expect(nativeBid.image).to.equal('http://images.cdn.brand.com/123'); - expect(nativeBid.clickUrl).to.equal(encodeURIComponent('http://brand.clickme.com/')); + expect(nativeBid.image).to.equal('https://images.cdn.brand.com/123'); + expect(nativeBid.clickUrl).to.equal(encodeURIComponent('https://brand.clickme.com/')); expect(nativeBid.impressionTrackers).to.have.lengthOf(2); - expect(nativeBid.impressionTrackers[0]).to.equal('http://imp1.trackme.com/'); - expect(nativeBid.impressionTrackers[1]).to.equal('http://imp1.contextweb.com/'); + expect(nativeBid.impressionTrackers[0]).to.equal('https://imp1.trackme.com/'); + expect(nativeBid.impressionTrackers[1]).to.equal('https://imp1.contextweb.com/'); }); it('Verifies bidder code', function () { @@ -406,7 +406,7 @@ describe('PulsePoint Adapter Tests', function () { expect(ortbRequest.app.publisher).to.not.equal(null); expect(ortbRequest.app.publisher.id).to.equal('p10000'); expect(ortbRequest.app.bundle).to.equal('com.pulsepoint.apps'); - expect(ortbRequest.app.storeurl).to.equal('http://pulsepoint.com/apps'); + expect(ortbRequest.app.storeurl).to.equal('https://pulsepoint.com/apps'); expect(ortbRequest.app.domain).to.equal('pulsepoint.com'); }); @@ -475,7 +475,7 @@ describe('PulsePoint Adapter Tests', function () { bid: [{ impid: ortbRequest.imp[0].id, price: 1.25, - adm: 'http://pulsepoint.video.mp4' + adm: 'https//pulsepoint.video.mp4' }] }] }; @@ -559,7 +559,7 @@ describe('PulsePoint Adapter Tests', function () { bid: [{ impid: ortbRequest.imp[0].id, price: 1.25, - adm: 'http://pulsepoint.video.mp4', + adm: 'https//pulsepoint.video.mp4', ext: { outstream: { type: 'Inline', @@ -567,7 +567,7 @@ describe('PulsePoint Adapter Tests', function () { text: 'ADVERTISEMENT', skipaftersec: 5 }, - rendererUrl: 'http://tag.contextweb.com/hb-outstr-renderer.js' + rendererUrl: 'https://tag.contextweb.com/hb-outstr-renderer.js' } } }] @@ -577,7 +577,7 @@ describe('PulsePoint Adapter Tests', function () { const bid = bids[0]; expect(bid.cpm).to.equal(1.25); expect(bid.renderer).to.not.be.null; - expect(bid.renderer.url).to.equal('http://tag.contextweb.com/hb-outstr-renderer.js'); + expect(bid.renderer.url).to.equal('https://tag.contextweb.com/hb-outstr-renderer.js'); expect(bid.renderer.getConfig()).to.not.be.null; expect(bid.renderer.getConfig().defaultOptions).to.eql(ortbResponse.seatbid[0].bid[0].ext.outstream.config); expect(bid.renderer.getConfig().rendererOptions).to.eql(outstreamSlotConfig[0].renderer.options); diff --git a/test/spec/modules/quantumBidAdapter_spec.js b/test/spec/modules/quantumBidAdapter_spec.js index d14d24ebfe10..ba020fbc5360 100644 --- a/test/spec/modules/quantumBidAdapter_spec.js +++ b/test/spec/modules/quantumBidAdapter_spec.js @@ -2,7 +2,7 @@ import { expect } from 'chai' import { spec } from 'modules/quantumBidAdapter' import { newBidder } from 'src/adapters/bidderFactory' -const ENDPOINT = '//s.sspqns.com/hb' +const ENDPOINT = 'https://s.sspqns.com/hb' const REQUEST = { 'bidder': 'quantum', 'sizes': [[300, 250]], @@ -27,10 +27,10 @@ const serverResponse = { '' ], 'is_fallback': false, - 'nurl': 'http://s.sspqns.com/imp/KpQ1WNMHV-9a3HqWL_0JnujJFGo1Hnx9RS3FT_Yy8jW-Z6t_PJYmP2otidJsxE3qcY2EozzcBjRzGM7HEQcxVnjOzq0Th1cxb6A5bSp5BizTwY5SRaxx_0PgF6--8LqaF4LMUgMmhfF5k3gOOzzK6gKdavia4_w3LJ1CRWkMEwABr8bPzeovy1y4MOZsOXv7vXjPGMKJSTgphuZR57fL4u4ZFF4XY70K_TaH5bfXHMRAzE0Q38tfpTvbdFV_u2g-FoF0gjzKjiS88VnetT-Jo3qtrMphWzr52jsg5tH3L7hbymUOm1YkuJP9xrXLoZNVgC5sTMYolKLMSu6dqhS2FXcdfaGAcHweaaAAwJq-pB7DuiVcdnZQphUymhIia_KG2AYweWp6TYEpJbJjf2BcLpm_-KGw4gLh6L3DtEvUZwXZe-JpUJ4/', + 'nurl': 'https://s.sspqns.com/imp/KpQ1WNMHV-9a3HqWL_0JnujJFGo1Hnx9RS3FT_Yy8jW-Z6t_PJYmP2otidJsxE3qcY2EozzcBjRzGM7HEQcxVnjOzq0Th1cxb6A5bSp5BizTwY5SRaxx_0PgF6--8LqaF4LMUgMmhfF5k3gOOzzK6gKdavia4_w3LJ1CRWkMEwABr8bPzeovy1y4MOZsOXv7vXjPGMKJSTgphuZR57fL4u4ZFF4XY70K_TaH5bfXHMRAzE0Q38tfpTvbdFV_u2g-FoF0gjzKjiS88VnetT-Jo3qtrMphWzr52jsg5tH3L7hbymUOm1YkuJP9xrXLoZNVgC5sTMYolKLMSu6dqhS2FXcdfaGAcHweaaAAwJq-pB7DuiVcdnZQphUymhIia_KG2AYweWp6TYEpJbJjf2BcLpm_-KGw4gLh6L3DtEvUZwXZe-JpUJ4/', 'native': { 'link': { - 'url': 'http://s.sspqns.com/click/KpQ1WNMHV-9a3HqWL_0JnujJFGo1Hnx9RS3FT_Yy8jW-Z6t_PJYmP2otidJsxE3qcY2EozzcBjRzGM7HEQcxVnjOzq0Th1cxb6A5bSp5BizTwY5SRaxx_0PgF6--8LqaF4LMUgMmhfF5k3gOOzzK6gKdavia4_w3LJ1CRWkMEwABr8bPzeovy1y4MOZsOXv7vXjPGMKJSTgphuZR57fL4u4ZFF4XY70K_TaH5bfXHMRAzE0Q38tfpTvbdFV_u2g-FoF0gjzKjiS88VnetT-Jo3qtrMphWzr52jsg5tH3L7hbymUOm1YkuJP9xrXLoZNVgC5sTMYolKLMSu6dqhS2FXcdfaGAcHweaaAAwJq-pB7DuiVcdnZQphUymhIia_KG2AYweWp6TYEpJbJjf2BcLpm_-KGw4gLh6L3DtEvUZwXZe-JpUJ4///', + 'url': 'https://s.sspqns.com/click/KpQ1WNMHV-9a3HqWL_0JnujJFGo1Hnx9RS3FT_Yy8jW-Z6t_PJYmP2otidJsxE3qcY2EozzcBjRzGM7HEQcxVnjOzq0Th1cxb6A5bSp5BizTwY5SRaxx_0PgF6--8LqaF4LMUgMmhfF5k3gOOzzK6gKdavia4_w3LJ1CRWkMEwABr8bPzeovy1y4MOZsOXv7vXjPGMKJSTgphuZR57fL4u4ZFF4XY70K_TaH5bfXHMRAzE0Q38tfpTvbdFV_u2g-FoF0gjzKjiS88VnetT-Jo3qtrMphWzr52jsg5tH3L7hbymUOm1YkuJP9xrXLoZNVgC5sTMYolKLMSu6dqhS2FXcdfaGAcHweaaAAwJq-pB7DuiVcdnZQphUymhIia_KG2AYweWp6TYEpJbJjf2BcLpm_-KGw4gLh6L3DtEvUZwXZe-JpUJ4///', 'clicktrackers': ['https://elasticad.net'] }, 'assets': [ @@ -46,7 +46,7 @@ const serverResponse = { 'img': { 'w': 15, 'h': 15, - 'url': 'http://files.ssp.theadtech.com.s3.amazonaws.com/media/image/sxjermpz/scalecrop-15x15' + 'url': 'https://files.ssp.theadtech.com.s3.amazonaws.com/media/image/sxjermpz/scalecrop-15x15' } }, { @@ -61,19 +61,19 @@ const serverResponse = { 'img': { 'w': 500, 'h': 500, - 'url': 'http://files.ssp.theadtech.com.s3.amazonaws.com/media/image/sxjermpz/scalecrop-500x500' + 'url': 'https://files.ssp.theadtech.com.s3.amazonaws.com/media/image/sxjermpz/scalecrop-500x500' } }, { 'id': 6, 'video': { - 'vasttag': 'http://elasticad.net/vast.xml' + 'vasttag': 'https://elasticad.net/vast.xml' } }, { 'id': 2001, 'data': { - 'value': 'http://elasticad.net' + 'value': 'https://elasticad.net' } }, { @@ -97,7 +97,7 @@ const serverResponse = { { 'id': 2003, 'data': { - 'value': 'http://elasticad.net' + 'value': 'https://elasticad.net' } }, { @@ -115,7 +115,7 @@ const serverResponse = { { 'id': 2006, 'data': { - 'value': 'http://elasticad.net/vast.xml' + 'value': 'https://elasticad.net/vast.xml' } }, { @@ -129,7 +129,7 @@ const serverResponse = { 'ver': '1.1' }, 'sync': [ - 'http://match.adsrvr.org/track/cmb/generic?ttd_pid=s6e8ued&ttd_tpi=1' + 'https://match.adsrvr.org/track/cmb/generic?ttd_pid=s6e8ued&ttd_tpi=1' ] } @@ -139,10 +139,10 @@ const nativeServerResponse = { '' ], 'is_fallback': false, - 'nurl': 'http://s.sspqns.com/imp/KpQ1WNMHV-9a3HqWL_0JnujJFGo1Hnx9RS3FT_Yy8jW-Z6t_PJYmP2otidJsxE3qcY2EozzcBjRzGM7HEQcxVnjOzq0Th1cxb6A5bSp5BizTwY5SRaxx_0PgF6--8LqaF4LMUgMmhfF5k3gOOzzK6gKdavia4_w3LJ1CRWkMEwABr8bPzeovy1y4MOZsOXv7vXjPGMKJSTgphuZR57fL4u4ZFF4XY70K_TaH5bfXHMRAzE0Q38tfpTvbdFV_u2g-FoF0gjzKjiS88VnetT-Jo3qtrMphWzr52jsg5tH3L7hbymUOm1YkuJP9xrXLoZNVgC5sTMYolKLMSu6dqhS2FXcdfaGAcHweaaAAwJq-pB7DuiVcdnZQphUymhIia_KG2AYweWp6TYEpJbJjf2BcLpm_-KGw4gLh6L3DtEvUZwXZe-JpUJ4/', + 'nurl': 'https://s.sspqns.com/imp/KpQ1WNMHV-9a3HqWL_0JnujJFGo1Hnx9RS3FT_Yy8jW-Z6t_PJYmP2otidJsxE3qcY2EozzcBjRzGM7HEQcxVnjOzq0Th1cxb6A5bSp5BizTwY5SRaxx_0PgF6--8LqaF4LMUgMmhfF5k3gOOzzK6gKdavia4_w3LJ1CRWkMEwABr8bPzeovy1y4MOZsOXv7vXjPGMKJSTgphuZR57fL4u4ZFF4XY70K_TaH5bfXHMRAzE0Q38tfpTvbdFV_u2g-FoF0gjzKjiS88VnetT-Jo3qtrMphWzr52jsg5tH3L7hbymUOm1YkuJP9xrXLoZNVgC5sTMYolKLMSu6dqhS2FXcdfaGAcHweaaAAwJq-pB7DuiVcdnZQphUymhIia_KG2AYweWp6TYEpJbJjf2BcLpm_-KGw4gLh6L3DtEvUZwXZe-JpUJ4/', 'native': { 'link': { - 'url': 'http://s.sspqns.com/click/KpQ1WNMHV-9a3HqWL_0JnujJFGo1Hnx9RS3FT_Yy8jW-Z6t_PJYmP2otidJsxE3qcY2EozzcBjRzGM7HEQcxVnjOzq0Th1cxb6A5bSp5BizTwY5SRaxx_0PgF6--8LqaF4LMUgMmhfF5k3gOOzzK6gKdavia4_w3LJ1CRWkMEwABr8bPzeovy1y4MOZsOXv7vXjPGMKJSTgphuZR57fL4u4ZFF4XY70K_TaH5bfXHMRAzE0Q38tfpTvbdFV_u2g-FoF0gjzKjiS88VnetT-Jo3qtrMphWzr52jsg5tH3L7hbymUOm1YkuJP9xrXLoZNVgC5sTMYolKLMSu6dqhS2FXcdfaGAcHweaaAAwJq-pB7DuiVcdnZQphUymhIia_KG2AYweWp6TYEpJbJjf2BcLpm_-KGw4gLh6L3DtEvUZwXZe-JpUJ4///' + 'url': 'https://s.sspqns.com/click/KpQ1WNMHV-9a3HqWL_0JnujJFGo1Hnx9RS3FT_Yy8jW-Z6t_PJYmP2otidJsxE3qcY2EozzcBjRzGM7HEQcxVnjOzq0Th1cxb6A5bSp5BizTwY5SRaxx_0PgF6--8LqaF4LMUgMmhfF5k3gOOzzK6gKdavia4_w3LJ1CRWkMEwABr8bPzeovy1y4MOZsOXv7vXjPGMKJSTgphuZR57fL4u4ZFF4XY70K_TaH5bfXHMRAzE0Q38tfpTvbdFV_u2g-FoF0gjzKjiS88VnetT-Jo3qtrMphWzr52jsg5tH3L7hbymUOm1YkuJP9xrXLoZNVgC5sTMYolKLMSu6dqhS2FXcdfaGAcHweaaAAwJq-pB7DuiVcdnZQphUymhIia_KG2AYweWp6TYEpJbJjf2BcLpm_-KGw4gLh6L3DtEvUZwXZe-JpUJ4///' }, 'assets': [ { @@ -157,7 +157,7 @@ const nativeServerResponse = { 'img': { 'w': 15, 'h': 15, - 'url': 'http://files.ssp.theadtech.com.s3.amazonaws.com/media/image/sxjermpz/scalecrop-15x15' + 'url': 'https://files.ssp.theadtech.com.s3.amazonaws.com/media/image/sxjermpz/scalecrop-15x15' } }, { @@ -172,7 +172,7 @@ const nativeServerResponse = { 'img': { 'w': 500, 'h': 500, - 'url': 'http://files.ssp.theadtech.com.s3.amazonaws.com/media/image/sxjermpz/scalecrop-500x500' + 'url': 'https://files.ssp.theadtech.com.s3.amazonaws.com/media/image/sxjermpz/scalecrop-500x500' } }, { @@ -191,7 +191,7 @@ const nativeServerResponse = { { 'id': 2003, 'data': { - 'value': 'http://elasticad.net' + 'value': 'https://elasticad.net' } } ], @@ -199,7 +199,7 @@ const nativeServerResponse = { 'ver': '1.1' }, 'sync': [ - 'http://match.adsrvr.org/track/cmb/generic?ttd_pid=s6e8ued&ttd_tpi=1' + 'https://match.adsrvr.org/track/cmb/generic?ttd_pid=s6e8ued&ttd_tpi=1' ] } diff --git a/test/spec/modules/rdnBidAdapter_spec.js b/test/spec/modules/rdnBidAdapter_spec.js deleted file mode 100644 index 8f53502bc449..000000000000 --- a/test/spec/modules/rdnBidAdapter_spec.js +++ /dev/null @@ -1,156 +0,0 @@ -import { expect } from 'chai' -import * as utils from 'src/utils' -import { spec } from 'modules/rdnBidAdapter' -import { newBidder } from 'src/adapters/bidderFactory' -import {config} from '../../../src/config'; - -describe('rdnBidAdapter', function() { - const adapter = newBidder(spec); - const ENDPOINT = 'https://s-bid.rmp.rakuten.co.jp/h'; - let sandbox; - - beforeEach(function() { - config.resetConfig(); - }); - - afterEach(function () { - config.resetConfig(); - }); - - describe('inherited functions', () => { - it('exists and is a function', () => { - expect(adapter.callBids).to.exist.and.to.be.a('function') - }) - }); - - describe('isBidRequestValid', () => { - let bid = { - bidder: 'rdn', - params: { - adSpotId: '56789' - } - }; - - it('should return true when required params found', () => { - expect(spec.isBidRequestValid(bid)).to.equal(true) - }); - - it('should return false when required params are not passed', () => { - bid.params.adSpotId = ''; - expect(spec.isBidRequestValid(bid)).to.equal(false) - }); - - it('should return false when required params are not passed', () => { - let bid = Object.assign({}, bid); - delete bid.params; - bid.params = {}; - expect(spec.isBidRequestValid(bid)).to.equal(false) - }) - }); - - describe('buildRequests', () => { - const bidRequests = [ - { - // banner - params: { - adSpotId: '58278' - } - } - ]; - - it('sends bid request to ENDPOINT via GET', () => { - const request = spec.buildRequests(bidRequests)[0]; - expect(request.url).to.equal(ENDPOINT); - expect(request.method).to.equal('GET') - }) - - it('allows url override', () => { - config.setConfig({ - rdn: { - endpoint: '//test.rakuten.com' - } - }); - const request = spec.buildRequests(bidRequests)[0]; - expect(request.url).to.equal('//test.rakuten.com'); - }) - }); - - describe('interpretResponse', () => { - const bidRequests = { - banner: { - method: 'GET', - url: '', - data: { - t: '56789', - s: 'https', - ua: - 'Mozilla/5.0 (Linux; Android 5.0; SM-G900P Build/LRX21T) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Mobile Safari/537.36', - l: 'ja', - d: 'examples.com', - tp: 'https://examples.com/foo/fuga', - pp: 'https://examples.com/hoge/muga' - } - } - }; - - const serverResponse = { - noAd: [], - noAd2: { - requestId: 'biequa9oaph4we' - }, - banner: { - requestId: 'biequa9oaph4we', - cpm: 37.66, - width: 300, - height: 250, - creativeId: 140281, - dealId: 'phoh3pad-ai4ah-xoh7x-ahk7cheasae3oh', - currency: 'JPY', - netRevenue: 300, - ttl: 3000, - referrer: utils.getTopWindowUrl(), - ad: '' - } - }; - - it('handles nobid responses', () => { - const result = spec.interpretResponse( - { body: serverResponse.noAd }, - bidRequests.banner - ); - expect(result.length).to.equal(0); - - const result2 = spec.interpretResponse( - { body: serverResponse.noAd2 }, - bidRequests.banner - ); - expect(result2.length).to.equal(0); - }) - }); - describe('spec.getUserSyncs', function () { - const syncResponse = [{ - body: { - request_id: 'biequa9oaph4we', - sync_urls: ['https://rdn1.test/sync?uid=9876543210', 'https://rdn2.test/sync?uid=9876543210'] - } - }]; - const nosyncResponse = [{ - body: { - request_id: 'biequa9oaph4we', - sync_urls: [] - } - }]; - let syncOptions - beforeEach(function () { - syncOptions = { - pixelEnabled: true - } - }); - it('sucess usersync url', function () { - const result = []; - result.push({type: 'image', url: 'https://rdn1.test/sync?uid=9876543210'}); - result.push({type: 'image', url: 'https://rdn2.test/sync?uid=9876543210'}); - expect(spec.getUserSyncs(syncOptions, syncResponse)).to.deep.equal(result); - }); - }); -}); diff --git a/test/spec/modules/readpeakBidAdapter_spec.js b/test/spec/modules/readpeakBidAdapter_spec.js deleted file mode 100644 index 5fcdf9b5836c..000000000000 --- a/test/spec/modules/readpeakBidAdapter_spec.js +++ /dev/null @@ -1,207 +0,0 @@ -import { expect } from 'chai'; -import { spec, ENDPOINT } from 'modules/readpeakBidAdapter'; -import * as utils from 'src/utils'; -import {config} from 'src/config'; - -describe('ReadPeakAdapter', function () { - let bidRequest - let serverResponse - let serverRequest - - beforeEach(function () { - bidRequest = { - bidder: 'readpeak', - nativeParams: { - title: { required: true, len: 200 }, - image: { wmin: 100 }, - sponsoredBy: { }, - body: {required: false}, - cta: {required: false}, - }, - params: { - bidfloor: 5.00, - publisherId: '11bc5dd5-7421-4dd8-c926-40fa653bec76', - siteId: '11bc5dd5-7421-4dd8-c926-40fa653bec77' - }, - bidId: '2ffb201a808da7', - bidderRequestId: '178e34bad3658f', - auctionId: 'c45dd708-a418-42ec-b8a7-b70a6c6fab0a', - transactionId: 'd45dd707-a418-42ec-b8a7-b70a6c6fab0b' - } - serverResponse = { - id: bidRequest.bidderRequestId, - cur: 'USD', - seatbid: [{ - bid: [{ - id: 'bidRequest.bidId', - impid: bidRequest.bidId, - price: 0.12, - cid: '12', - crid: '123', - adomain: ['readpeak.com'], - adm: { - assets: [{ - id: 1, - title: { - text: 'Title', - } - }, - { - id: 3, - data: { - type: 1, - value: 'Brand Name', - }, - }, - { - id: 4, - data: { - type: 2, - value: 'Description', - }, - }, - { - id: 2, - img: { - type: 3, - url: 'http://url.to/image', - w: 750, - h: 500, - }, - }], - link: { - url: 'http://url.to/target' - }, - imptrackers: [ - 'http://url.to/pixeltracker' - ], - } - }], - }], - } - serverRequest = { - method: 'POST', - url: 'http://localhost:60080/header/prebid', - data: JSON.stringify({ - 'id': '178e34bad3658f', - 'imp': [ - { - 'id': '2ffb201a808da7', - 'native': { - 'request': '{"assets":[{"id":1,"required":1,"title":{"len":200}},{"id":2,"required":0,"data":{"type":1,"len":50}},{"id":3,"required":0,"img":{"type":3,"wmin":100,"hmin":150}}]}', - 'ver': '1.1' - }, - 'bidfloor': 5, - 'bidfloorcur': 'USD' - } - ], - 'site': { - 'publisher': { - 'id': '11bc5dd5-7421-4dd8-c926-40fa653bec76' - }, - 'id': '11bc5dd5-7421-4dd8-c926-40fa653bec77', - 'ref': '', - 'page': 'http://localhost', - 'domain': 'localhost' - }, - 'app': null, - 'device': { - 'ua': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/61.0.3163.100 Safari/537.36', - 'language': 'en-US' - }, - 'isPrebid': true - }) - } - }); - - describe('spec.isBidRequestValid', function () { - it('should return true when the required params are passed', function () { - expect(spec.isBidRequestValid(bidRequest)).to.equal(true); - }); - - it('should return false when the native params are missing', function () { - bidRequest.nativeParams = undefined; - expect(spec.isBidRequestValid(bidRequest)).to.equal(false); - }); - - it('should return false when the "publisherId" param is missing', function () { - bidRequest.params = { - bidfloor: 5.00 - }; - expect(spec.isBidRequestValid(bidRequest)).to.equal(false); - }); - - it('should return false when no bid params are passed', function () { - bidRequest.params = {}; - expect(spec.isBidRequestValid(bidRequest)).to.equal(false); - }); - - it('should return false when a bid request is not passed', function () { - expect(spec.isBidRequestValid()).to.equal(false); - expect(spec.isBidRequestValid({})).to.equal(false); - }); - }); - - describe('spec.buildRequests', function () { - it('should create a POST request for every bid', function () { - const request = spec.buildRequests([ bidRequest ]); - expect(request.method).to.equal('POST'); - expect(request.url).to.equal(ENDPOINT); - }); - - it('should attach request data', function () { - config.setConfig({ - currency: { - adServerCurrency: 'EUR' - } - }); - - const request = spec.buildRequests([ bidRequest ]); - - const data = JSON.parse(request.data); - - expect(data.source.ext.prebid).to.equal('$prebid.version$'); - expect(data.id).to.equal(bidRequest.bidderRequestId) - expect(data.imp[0].bidfloor).to.equal(bidRequest.params.bidfloor); - expect(data.imp[0].bidfloorcur).to.equal('USD'); - expect(data.site).to.deep.equal({ - publisher: { - id: bidRequest.params.publisherId, - domain: 'http://localhost:9876', - }, - id: bidRequest.params.siteId, - ref: window.top.document.referrer, - page: utils.getTopWindowLocation().href, - domain: utils.getTopWindowLocation().hostname, - }); - expect(data.device).to.deep.contain({ ua: navigator.userAgent, language: navigator.language }); - expect(data.cur).to.deep.equal(['EUR']); - }); - }); - - describe('spec.interpretResponse', function () { - it('should return no bids if the response is not valid', function () { - const bidResponse = spec.interpretResponse({ body: null }, serverRequest); - expect(bidResponse.length).to.equal(0); - }); - - it('should return a valid bid response', function () { - const bidResponse = spec.interpretResponse({ body: serverResponse }, serverRequest)[0]; - expect(bidResponse).to.contain({ - requestId: bidRequest.bidId, - cpm: serverResponse.seatbid[0].bid[0].price, - creativeId: serverResponse.seatbid[0].bid[0].crid, - ttl: 300, - netRevenue: true, - mediaType: 'native', - currency: serverResponse.cur - }); - - expect(bidResponse.native.title).to.equal('Title') - expect(bidResponse.native.body).to.equal('Description') - expect(bidResponse.native.image).to.deep.equal({url: 'http://url.to/image', width: 750, height: 500}) - expect(bidResponse.native.clickUrl).to.equal('http%3A%2F%2Furl.to%2Ftarget') - expect(bidResponse.native.impressionTrackers).to.contain('http://url.to/pixeltracker') - }); - }); -}); diff --git a/test/spec/modules/reklamstoreBidAdapter_spec.js b/test/spec/modules/reklamstoreBidAdapter_spec.js index 3ac40e20eafc..92f309fd54f5 100644 --- a/test/spec/modules/reklamstoreBidAdapter_spec.js +++ b/test/spec/modules/reklamstoreBidAdapter_spec.js @@ -29,7 +29,7 @@ describe('reklamstoreBidAdapterTests', function() { it('validate_generated_params', function() { let bidderRequest = { refererInfo: { - referer: 'http://reklamstore.com' + referer: 'https://reklamstore.com' } }; request = spec.buildRequests(bidRequestData.bids, bidderRequest); @@ -47,11 +47,11 @@ describe('reklamstoreBidAdapterTests', function() { h: 250, syncs: [{ type: 'image', - url: 'http://link1' + url: 'https://link1' }, { type: 'iframe', - url: 'http://link2' + url: 'https://link2' } ] } @@ -77,8 +77,8 @@ describe('reklamstoreBidAdapterTests', function() { it('should return user syncs', function () { const syncs = spec.getUserSyncs({pixelEnabled: true, iframeEnabled: true}, [serverResponse]); const expected = [ - { type: 'image', url: 'http://link1' }, - { type: 'iframe', url: 'http://link2' }, + { type: 'image', url: 'https://link1' }, + { type: 'iframe', url: 'https://link2' }, ]; expect(syncs).to.deep.equal(expected); }); diff --git a/test/spec/modules/rexrtbBidAdapter_spec.js b/test/spec/modules/rexrtbBidAdapter_spec.js deleted file mode 100644 index b35e05bbf46d..000000000000 --- a/test/spec/modules/rexrtbBidAdapter_spec.js +++ /dev/null @@ -1,107 +0,0 @@ -import {expect} from 'chai'; -import {spec} from 'modules/rexrtbBidAdapter'; - -describe('rexrtb adapater', function () { - describe('Test validate req', function () { - it('should accept minimum valid bid', function () { - let bid = { - bidder: 'rexrtb', - params: { - id: 89, - token: '658f11a5efbbce2f9be3f1f146fcbc22', - source: 'prebidtest' - } - }; - const isValid = spec.isBidRequestValid(bid); - - expect(isValid).to.equal(true); - }); - - it('should reject missing id', function () { - let bid = { - bidder: 'rexrtb', - params: { - token: '658f11a5efbbce2f9be3f1f146fcbc22', - source: 'prebidtest' - } - }; - const isValid = spec.isBidRequestValid(bid); - - expect(isValid).to.equal(false); - }); - - it('should reject id not Integer', function () { - let bid = { - bidder: 'rexrtb', - params: { - id: '123', - token: '658f11a5efbbce2f9be3f1f146fcbc22', - source: 'prebidtest' - } - }; - const isValid = spec.isBidRequestValid(bid); - - expect(isValid).to.equal(false); - }); - }); - - describe('Test build request', function () { - it('minimum request', function () { - let bid = { - bidder: 'rexrtb', - sizes: [[728, 90]], - bidId: '4d0a6829338a07', - adUnitCode: 'div-gpt-ad-1460505748561-0', - auctionId: '20882439e3238c', - params: { - id: 89, - token: '658f11a5efbbce2f9be3f1f146fcbc22', - source: 'prebidtest' - }, - }; - const req = JSON.parse(spec.buildRequests([bid])[0].data); - - expect(req).to.have.property('id'); - expect(req).to.have.property('imp'); - expect(req).to.have.property('device'); - expect(req).to.have.property('site'); - expect(req).to.have.property('hb'); - expect(req.imp[0]).to.have.property('id'); - expect(req.imp[0]).to.have.property('banner'); - expect(req.device).to.have.property('ip'); - expect(req.device).to.have.property('ua'); - expect(req.site).to.have.property('id'); - expect(req.site).to.have.property('domain'); - }); - }); - - describe('Test interpret response', function () { - it('General banner response', function () { - let resp = spec.interpretResponse({ - body: { - id: 'abcd', - seatbid: [{ - bid: [{ - id: 'abcd', - impid: 'banner-bid', - price: 0.3, - w: 728, - h: 98, - adm: 'hello', - crid: 'efgh', - exp: 5 - }] - }] - } - }, null)[0]; - - expect(resp).to.have.property('requestId', 'banner-bid'); - expect(resp).to.have.property('cpm', 0.3); - expect(resp).to.have.property('width', 728); - expect(resp).to.have.property('height', 98); - expect(resp).to.have.property('creativeId', 'efgh'); - expect(resp).to.have.property('ttl', 5); - expect(resp).to.have.property('ad', 'hello'); - }); - }); -}); diff --git a/test/spec/modules/rhythmoneBidAdapter_spec.js b/test/spec/modules/rhythmoneBidAdapter_spec.js index 29c8de43c169..80cbdb4a0afb 100644 --- a/test/spec/modules/rhythmoneBidAdapter_spec.js +++ b/test/spec/modules/rhythmoneBidAdapter_spec.js @@ -40,7 +40,7 @@ describe('rhythmone adapter tests', function () { var bidRequest = r1adapter.buildRequests(bidRequestList, this.defaultBidderRequest); - expect(bidRequest.url).to.have.string('//tag.1rx.io/rmp/myplacement/0/mypath?z=myzone&hbv='); + expect(bidRequest.url).to.have.string('https://tag.1rx.io/rmp/myplacement/0/mypath?z=myzone&hbv='); expect(bidRequest.method).to.equal('POST'); const openrtbRequest = JSON.parse(bidRequest.data); expect(openrtbRequest.site).to.not.equal(null); @@ -113,7 +113,7 @@ describe('rhythmone adapter tests', function () { var bidRequest = r1adapter.buildRequests(bidRequestList, this.defaultBidderRequest); - expect(bidRequest.url).to.have.string('//tag.1rx.io/rmp/myplacement/0/mypath?z=myzone&hbv='); + expect(bidRequest.url).to.have.string('https://tag.1rx.io/rmp/myplacement/0/mypath?z=myzone&hbv='); expect(bidRequest.method).to.equal('POST'); const openrtbRequest = JSON.parse(bidRequest.data); expect(openrtbRequest.site).to.not.equal(null); @@ -138,7 +138,7 @@ describe('rhythmone adapter tests', function () { { 'impid': 'div-gpt-ad-1438287399331-1', 'price': 1, - 'nurl': 'http://testdomain/rmp/placementid/0/path?reqId=1636037', + 'nurl': 'https://testdomain/rmp/placementid/0/path?reqId=1636037', 'adomain': [ 'test.com' ], @@ -156,7 +156,7 @@ describe('rhythmone adapter tests', function () { const bid = videoBids[0]; expect(bid.width).to.equal(800); expect(bid.height).to.equal(600); - expect(bid.vastUrl).to.equal('http://testdomain/rmp/placementid/0/path?reqId=1636037'); + expect(bid.vastUrl).to.equal('https://testdomain/rmp/placementid/0/path?reqId=1636037'); expect(bid.mediaType).to.equal('video'); expect(bid.creativeId).to.equal('cr-vid'); expect(bid.currency).to.equal('USD'); @@ -234,7 +234,7 @@ describe('rhythmone adapter tests', function () { { 'impid': 'div-gpt-ad-1438287399331-5', 'price': 1, - 'nurl': 'http://testdomain/rmp/placementid/0/path?reqId=1636037', + 'nurl': 'https://testdomain/rmp/placementid/0/path?reqId=1636037', 'adomain': [ 'test.com' ], @@ -255,7 +255,7 @@ describe('rhythmone adapter tests', function () { const bid = forRMPMultiFormatResponse[0]; expect(bid.width).to.equal(800); expect(bid.height).to.equal(600); - expect(bid.vastUrl).to.equal('http://testdomain/rmp/placementid/0/path?reqId=1636037'); + expect(bid.vastUrl).to.equal('https://testdomain/rmp/placementid/0/path?reqId=1636037'); expect(bid.mediaType).to.equal('video'); expect(bid.creativeId).to.equal('cr-vid'); expect(bid.currency).to.equal('USD'); diff --git a/test/spec/modules/richaudienceBidAdapter_spec.js b/test/spec/modules/richaudienceBidAdapter_spec.js index 6c7030676c7e..cd6690e3276a 100644 --- a/test/spec/modules/richaudienceBidAdapter_spec.js +++ b/test/spec/modules/richaudienceBidAdapter_spec.js @@ -181,7 +181,7 @@ describe('Richaudience adapter tests', function () { gdprApplies: true }, refererInfo: { - referer: 'http://domain.com', + referer: 'https://domain.com', numIframes: 0 } }); @@ -197,7 +197,8 @@ describe('Richaudience adapter tests', function () { expect(requestContent).to.have.property('bidder').and.to.equal('richaudience'); expect(requestContent).to.have.property('bidderRequestId').and.to.equal('1858b7382993ca'); expect(requestContent).to.have.property('tagId').and.to.equal('test-div'); - expect(requestContent).to.have.property('referer').and.to.equal('http%3A%2F%2Fdomain.com'); + expect(requestContent).to.have.property('referer').and.to.equal('https%3A%2F%2Fdomain.com'); + expect(requestContent).to.have.property('sizes'); expect(requestContent.sizes[0]).to.have.property('w').and.to.equal(300); expect(requestContent.sizes[0]).to.have.property('h').and.to.equal(250); expect(requestContent.sizes[1]).to.have.property('w').and.to.equal(300); @@ -224,15 +225,31 @@ describe('Richaudience adapter tests', function () { } }); - const request = spec.buildRequests(DEFAULT_PARAMS_WO_OPTIONAL, DEFAULT_PARAMS_GDPR); + const request = spec.buildRequests(DEFAULT_PARAMS_WO_OPTIONAL, { + gdprConsent: { + consentString: 'BOZcQl_ObPFjWAeABAESCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NohBgA', + gdprApplies: true + }, + refererInfo: { + referer: 'https://domain.com', + numIframes: 0 + } + }); const requestContent = JSON.parse(request[0].data); expect(requestContent).to.have.property('gdpr_consent').and.to.equal('BOZcQl_ObPFjWAeABAESCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NohBgA'); }); it('Verify adding ifa when supplyType equal to app', function () { - const request = spec.buildRequests(DEFAULT_PARAMS_APP, DEFAULT_PARAMS_GDPR); - const requestContent = JSON.parse(request[0].data); - expect(requestContent).to.have.property('gdpr_consent').and.to.equal('BOZcQl_ObPFjWAeABAESCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NohBgA'); + const request = spec.buildRequests(DEFAULT_PARAMS_APP, { + gdprConsent: { + consentString: 'BOZcQl_ObPFjWAeABAESCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NohBgA', + gdprApplies: true + }, + refererInfo: { + referer: 'https://domain.com', + numIframes: 0 + } + }); }); it('Verify build request with GDPR without gdprApplies', function () { @@ -252,7 +269,7 @@ describe('Richaudience adapter tests', function () { consentString: 'BOZcQl_ObPFjWAeABAESCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NohBgA' }, refererInfo: { - referer: 'http://domain.com', + referer: 'https://domain.com', numIframes: 0 } }); @@ -486,7 +503,7 @@ describe('Richaudience adapter tests', function () { gdprApplies: true }, refererInfo: { - referer: 'http://domain.com', + referer: 'https://domain.com', numIframes: 0 } }); @@ -513,7 +530,7 @@ describe('Richaudience adapter tests', function () { gdprApplies: true }, refererInfo: { - referer: 'http://domain.com', + referer: 'https://domain.com', numIframes: 0 } }); diff --git a/test/spec/modules/rockyouBidAdapter_spec.js b/test/spec/modules/rockyouBidAdapter_spec.js deleted file mode 100644 index 65d87566c268..000000000000 --- a/test/spec/modules/rockyouBidAdapter_spec.js +++ /dev/null @@ -1,494 +0,0 @@ -import { expect } from 'chai'; -import { spec, internals } from 'modules/rockyouBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; - -describe('RockYouAdapter', function () { - const adapter = newBidder(spec); - - describe('bid validator', function () { - it('rejects a bid that is missing the placementId', function () { - let testBid = {}; - expect(spec.isBidRequestValid(testBid)).to.be.false; - }); - - it('accepts a bid with all the expected parameters', function () { - let testBid = { - params: { - placementId: 'f39ba81609' - } - }; - - expect(spec.isBidRequestValid(testBid)).to.be.true; - }); - }); - - describe('request builder', function () { - // Taken from the docs, so used as much as is valid - const sampleBidRequest = { - 'bidder': 'tests', - 'bidId': '51ef8751f9aead', - 'params': { - 'cId': '59ac1da80784890004047d89', - 'placementId': 'ZZZPLACEMENTZZZ' - }, - 'adUnitCode': 'div-gpt-ad-1460505748561-0', - 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', - 'sizes': [[999, 888]], - 'bidderRequestId': '418b37f85e772c', - 'auctionId': '18fd8b8b0bd757', - 'mediaTypes': { - banner: { - 'sizes': [[320, 50], [300, 250], [300, 600]] - } - } - }; - - it('successfully generates a URL', function () { - const placementId = 'ZZZPLACEMENTZZZ'; - - let bidRequests = [ - { - 'params': { - 'placementId': placementId - } - } - ]; - - let results = spec.buildRequests(bidRequests, { - bidderRequestId: 'sample' - }); - let result = results.pop(); - - expect(result.url).to.not.be.undefined; - expect(result.url).to.not.be.null; - - expect(result.url).to.include('/servlet/rotator/' + placementId + '/0/vo?z=') - }); - - it('uses the bidId id as the openRtb request ID', function () { - const bidId = '51ef8751f9aead'; - - let bidRequests = [ - sampleBidRequest - ]; - - let results = spec.buildRequests(bidRequests, { - bidderRequestId: 'sample' - }); - let result = results.pop(); - - // Double encoded JSON - let payload = JSON.parse(result.data); - - expect(payload).to.not.be.null; - expect(payload.id).to.equal(bidId); - }); - - it('generates the device payload as expected', function () { - let bidRequests = [ - sampleBidRequest - ]; - - let results = spec.buildRequests(bidRequests, { - bidderRequestId: 'sample' - }); - let result = results.pop(); - - // Double encoded JSON - let payload = JSON.parse(result.data); - - expect(payload).to.not.be.null; - let userData = payload.user; - - expect(userData).to.not.be.null; - }); - - it('generates multiple requests with single imp bodies', function () { - const SECOND_PLACEMENT_ID = 'YYYPLACEMENTIDYYY'; - let firstBidRequest = JSON.parse(JSON.stringify(sampleBidRequest)); - let secondBidRequest = JSON.parse(JSON.stringify(sampleBidRequest)); - secondBidRequest.params.placementId = SECOND_PLACEMENT_ID; - - let bidRequests = [ - firstBidRequest, - secondBidRequest - ]; - - let results = spec.buildRequests(bidRequests, { - bidderRequestId: 'sample' - }); - - expect(results instanceof Array).to.be.true; - expect(results.length).to.equal(2); - - let firstRequest = results[0]; - - // Double encoded JSON - let firstPayload = JSON.parse(firstRequest.data); - - expect(firstPayload).to.not.be.null; - expect(firstPayload.imp).to.not.be.null; - expect(firstPayload.imp.length).to.equal(1); - - expect(firstRequest.url).to.not.be.null; - expect(firstRequest.url.indexOf('ZZZPLACEMENTZZZ')).to.be.gt(0); - - let secondRequest = results[1]; - - // Double encoded JSON - let secondPayload = JSON.parse(secondRequest.data); - - expect(secondPayload).to.not.be.null; - expect(secondPayload.imp).to.not.be.null; - expect(secondPayload.imp.length).to.equal(1); - - expect(secondRequest.url).to.not.be.null; - expect(secondRequest.url.indexOf(SECOND_PLACEMENT_ID)).to.be.gt(0); - }); - - it('generates a banner request as expected', function () { - // clone the sample for stability - let localBidRequest = JSON.parse(JSON.stringify(sampleBidRequest)); - - let results = spec.buildRequests([localBidRequest], { - bidderRequestId: 'sample' - }); - let result = results.pop(); - - // Double encoded JSON - let payload = JSON.parse(result.data); - - expect(payload).to.not.be.null; - - let imps = payload.imp; - - let firstImp = imps[0]; - - expect(firstImp.banner).to.not.be.null; - - let bannerData = firstImp.banner; - - expect(bannerData.w).to.equal(320); - expect(bannerData.h).to.equal(50); - }); - - it('generates a banner request using a singular adSize instead of an array', function () { - // clone the sample for stability - let localBidRequest = JSON.parse(JSON.stringify(sampleBidRequest)); - localBidRequest.sizes = [320, 50]; - localBidRequest.mediaTypes = { banner: {} }; - - let results = spec.buildRequests([localBidRequest], { - bidderRequestId: 'sample' - }); - let result = results.pop(); - - // Double encoded JSON - let payload = JSON.parse(result.data); - - expect(payload).to.not.be.null; - - let imps = payload.imp; - - let firstImp = imps[0]; - - expect(firstImp.banner).to.not.be.null; - - let bannerData = firstImp.banner; - - expect(bannerData.w).to.equal(320); - expect(bannerData.h).to.equal(50); - }); - - it('fails gracefully on an invalid size', function () { - // clone the sample for stability - let localBidRequest = JSON.parse(JSON.stringify(sampleBidRequest)); - localBidRequest.sizes = ['x', 'w']; - - localBidRequest.mediaTypes = { banner: { sizes: ['y', 'z'] } }; - - let results = spec.buildRequests([localBidRequest], { - bidderRequestId: 'sample' - }); - let result = results.pop(); - - // Double encoded JSON - let payload = JSON.parse(result.data); - - expect(payload).to.not.be.null; - - let imps = payload.imp; - - let firstImp = imps[0]; - - expect(firstImp.banner).to.not.be.null; - - let bannerData = firstImp.banner; - - expect(bannerData.w).to.equal(null); - expect(bannerData.h).to.equal(null); - }); - - it('generates a video request as expected', function () { - // clone the sample for stability - let localBidRequest = JSON.parse(JSON.stringify(sampleBidRequest)); - - localBidRequest.mediaTypes = { video: { - playerSize: [326, 56] - } }; - - let results = spec.buildRequests([localBidRequest], { - bidderRequestId: 'sample' - }); - let result = results.pop(); - - // Double encoded JSON - let payload = JSON.parse(result.data); - - expect(payload).to.not.be.null; - - let imps = payload.imp; - - let firstImp = imps[0]; - - expect(firstImp.video).to.not.be.null; - - let videoData = firstImp.video; - - expect(videoData.w).to.equal(326); - expect(videoData.h).to.equal(56); - }); - - it('propagates the mediaTypes object in the built request', function () { - let localBidRequest = JSON.parse(JSON.stringify(sampleBidRequest)); - - localBidRequest.mediaTypes = { video: {} }; - - let results = spec.buildRequests([localBidRequest], { - bidderRequestId: 'sample' - }); - let result = results.pop(); - - let mediaTypes = result.mediaTypes; - - expect(mediaTypes).to.not.be.null; - expect(mediaTypes).to.not.be.undefined; - expect(mediaTypes.video).to.not.be.null; - expect(mediaTypes.video).to.not.be.undefined; - }); - }); - - describe('response interpreter', function () { - it('returns an empty array when no bids present', function () { - // an empty JSON body indicates no ad was found - - let result = spec.interpretResponse({ body: '' }, {}) - - expect(result).to.eql([]); - }); - - it('gracefully fails when a non-JSON body is present', function () { - let result = spec.interpretResponse({ body: 'THIS IS NOT ' }, {}) - - expect(result).to.eql([]); - }); - - it('returns a valid bid response on sucessful banner request', function () { - let incomingRequestId = 'XXtestingXX'; - let responsePrice = 3.14 - - let responseCreative = '\n\n
\n
'; - - let responseCreativeId = '274'; - let responseCurrency = 'USD'; - - let responseWidth = 300; - let responseHeight = 250; - let responseTtl = 213; - - let sampleResponse = { - id: '66043f5ca44ecd8f8769093b1615b2d9', - seatbid: [ - { - bid: [ - { - id: 'c21bab0e-7668-4d8f-908a-63e094c09197', - impid: '1', - price: responsePrice, - adid: responseCreativeId, - adm: responseCreative, - adomain: [ - 'www.rockyouteststudios.com' - ], - cid: '274', - attr: [], - w: responseWidth, - h: responseHeight, - ext: { - ttl: responseTtl - } - } - ], - seat: '201', - group: 0 - } - ], - bidid: 'c21bab0e-7668-4d8f-908a-63e094c09197', - cur: responseCurrency - }; - - let sampleRequest = { - bidId: incomingRequestId, - mediaTypes: { banner: {} }, - requestId: incomingRequestId - }; - - let result = spec.interpretResponse( - { - body: sampleResponse - }, - sampleRequest - ); - - expect(result.length).to.equal(1); - - let processedBid = result[0]; - - // expect(processedBid.requestId).to.equal(incomingRequestId); - expect(processedBid.cpm).to.equal(responsePrice); - expect(processedBid.width).to.equal(responseWidth); - expect(processedBid.height).to.equal(responseHeight); - expect(processedBid.ad).to.equal(responseCreative); - expect(processedBid.ttl).to.equal(responseTtl); - expect(processedBid.creativeId).to.equal(responseCreativeId); - expect(processedBid.netRevenue).to.equal(true); - expect(processedBid.currency).to.equal(responseCurrency); - }); - - it('returns an valid bid response on sucessful video request', function () { - let incomingRequestId = 'XXtesting-275XX'; - let responsePrice = 6 - - let responseCreative = '\n\n \n \n Mediatastic\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n'; - - let responseCreativeId = '1556'; - let responseCurrency = 'USD'; - - let responseWidth = 284; - let responseHeight = 285; - let responseTtl = 286; - - let sampleResponse = { - id: '1234567890', - seatbid: [ - { - bid: [ - { - id: 'a8ae0b48-a8db-4220-ba0c-7458f452b1f5', - impid: '1', - price: responsePrice, - adid: responseCreativeId, - adm: responseCreative, - cid: '270', - attr: [], - w: responseWidth, - h: responseHeight, - ext: { - ttl: responseTtl - } - } - ], - seat: '201', - group: 0 - } - ], - bidid: 'a8ae0b48-a8db-4220-ba0c-7458f452b1f5', - cur: 'USD' - }; - - let sampleRequest = { - bidId: incomingRequestId, - mediaTypes: { - video: { - } - }, - requestId: incomingRequestId - }; - - let result = spec.interpretResponse( - { - body: sampleResponse - }, - sampleRequest - ); - - expect(result.length).to.equal(1); - - let processedBid = result[0]; - - // expect(processedBid.requestId).to.equal(incomingRequestId); - expect(processedBid.cpm).to.equal(responsePrice); - expect(processedBid.width).to.equal(responseWidth); - expect(processedBid.height).to.equal(responseHeight); - expect(processedBid.ad).to.equal(null); - expect(processedBid.ttl).to.equal(responseTtl); - expect(processedBid.creativeId).to.equal(responseCreativeId); - expect(processedBid.netRevenue).to.equal(true); - expect(processedBid.currency).to.equal(responseCurrency); - expect(processedBid.vastXml).to.equal(responseCreative); - }); - - it('generates event callbacks as expected', function () { - let tally = {}; - let renderer = { - handleVideoEvent: (eventObject) => { - let eventName = eventObject.eventName; - if (tally[eventName]) { - tally[eventName] = tally[eventName] + 1; - } else { - tally[eventName] = 1; - } - } - }; - - let callbacks = internals.playerCallbacks(renderer); - - let validCallbacks = ['LOAD', 'IMPRESSION', 'COMPLETE', 'ERROR']; - - validCallbacks.forEach(event => { - callbacks('n/a', event); - }); - - let callbackKeys = Object.keys(tally); - expect(callbackKeys.length).to.equal(3); - expect(tally['loaded']).to.equal(1); - expect(tally['impression']).to.equal(1); - expect(tally['ended']).to.equal(2); - }); - - it('generates a renderer that will hide on complete', function () { - let elementName = 'test_element_id'; - let selector = `#${elementName}`; - - let mockElement = { - style: { - display: 'some' - } - }; - - document.querySelector = (name) => { - if (name === selector) { - return mockElement; - } else { - return null; - } - }; - - let renderer = internals.generateRenderer({}, elementName); - - renderer.handlers['ended'](); - - expect(mockElement.style.display).to.equal('none'); - }) - }); -}); diff --git a/test/spec/modules/roxotAnalyticsAdapter_spec.js b/test/spec/modules/roxotAnalyticsAdapter_spec.js index cd48cb7f37de..d40ceb61cd5a 100644 --- a/test/spec/modules/roxotAnalyticsAdapter_spec.js +++ b/test/spec/modules/roxotAnalyticsAdapter_spec.js @@ -189,7 +189,7 @@ describe('Roxot Prebid Analytic', function () { }); expect(requests.length).to.equal(1); - expect(requests[0].url).to.equal('//' + roxotConfigServerUrl + '/c?publisherId=' + publisherId + '&host=localhost'); + expect(requests[0].url).to.equal('https://' + roxotConfigServerUrl + '/c?publisherId=' + publisherId + '&host=localhost'); requests[0].respond(200, {'Content-Type': 'application/json'}, '{"a": 1, "i": 1, "bat": 1}'); events.emit(constants.EVENTS.AUCTION_INIT, auctionInit); @@ -207,9 +207,9 @@ describe('Roxot Prebid Analytic', function () { expect(requests.length).to.equal(4); - expect(requests[1].url).to.equal('//' + roxotEventServerUrl + '/a?publisherId=' + publisherId + '&host=localhost'); - expect(requests[2].url).to.equal('//' + roxotEventServerUrl + '/bat?publisherId=' + publisherId + '&host=localhost'); - expect(requests[3].url).to.equal('//' + roxotEventServerUrl + '/i?publisherId=' + publisherId + '&host=localhost'); + expect(requests[1].url).to.equal('https://' + roxotEventServerUrl + '/a?publisherId=' + publisherId + '&host=localhost'); + expect(requests[2].url).to.equal('https://' + roxotEventServerUrl + '/bat?publisherId=' + publisherId + '&host=localhost'); + expect(requests[3].url).to.equal('https://' + roxotEventServerUrl + '/i?publisherId=' + publisherId + '&host=localhost'); let auction = JSON.parse(requests[1].requestBody); expect(auction).to.include.all.keys('event', 'eventName', 'options', 'data'); @@ -269,7 +269,7 @@ describe('Roxot Prebid Analytic', function () { }); expect(requests.length).to.equal(1); - expect(requests[0].url).to.equal('//' + roxotConfigServerUrl + '/c?publisherId=' + publisherId + '&host=localhost'); + expect(requests[0].url).to.equal('https://' + roxotConfigServerUrl + '/c?publisherId=' + publisherId + '&host=localhost'); requests[0].respond(200, {'Content-Type': 'application/json'}, '{"a": 1, "i": 1, "bat": 1}'); events.emit(constants.EVENTS.AUCTION_INIT, auctionInit); @@ -287,8 +287,8 @@ describe('Roxot Prebid Analytic', function () { expect(requests.length).to.equal(3); - expect(requests[1].url).to.equal('//' + roxotEventServerUrl + '/a?publisherId=' + publisherId + '&host=localhost'); - expect(requests[2].url).to.equal('//' + roxotEventServerUrl + '/bat?publisherId=' + publisherId + '&host=localhost'); + expect(requests[1].url).to.equal('https://' + roxotEventServerUrl + '/a?publisherId=' + publisherId + '&host=localhost'); + expect(requests[2].url).to.equal('https://' + roxotEventServerUrl + '/bat?publisherId=' + publisherId + '&host=localhost'); let auction = JSON.parse(requests[1].requestBody); expect(auction.data.adUnits).to.include.all.keys(noBidAdUnit, bidAfterTimeoutAdUnit); diff --git a/test/spec/modules/rtbdemandBidAdapter_spec.js b/test/spec/modules/rtbdemandBidAdapter_spec.js index 25178c21d88b..6b5ef2151629 100644 --- a/test/spec/modules/rtbdemandBidAdapter_spec.js +++ b/test/spec/modules/rtbdemandBidAdapter_spec.js @@ -108,7 +108,7 @@ describe('rtbdemandAdapter', function () { it('sends bid request to ENDPOINT via GET', function () { const [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); - expect(request.url).to.equal('//bidding.rtbdemand.com/hb'); + expect(request.url).to.equal('https://bidding.rtbdemand.com/hb'); expect(request.method).to.equal('GET'); }); }) @@ -159,7 +159,7 @@ describe('rtbdemandAdapter', function () { }); describe('user sync', function () { - const syncUrl = '//bidding.rtbdemand.com/delivery/matches.php?type=iframe'; + const syncUrl = 'https://bidding.rtbdemand.com/delivery/matches.php?type=iframe'; it('should register the sync iframe', function () { expect(spec.getUserSyncs({})).to.be.undefined; diff --git a/test/spec/modules/rtbdemandadkBidAdapter_spec.js b/test/spec/modules/rtbdemandadkBidAdapter_spec.js deleted file mode 100644 index c1fbd35d6c9b..000000000000 --- a/test/spec/modules/rtbdemandadkBidAdapter_spec.js +++ /dev/null @@ -1,268 +0,0 @@ -import {expect} from 'chai'; -import {spec} from 'modules/rtbdemandadkBidAdapter'; -import * as utils from 'src/utils'; - -describe('rtbdemandadk adapter', function () { - const bid1_zone1 = { - bidder: 'rtbdemandadk', - bidId: 'Bid_01', - params: {zoneId: 1, host: 'rtb.rtbdemand.com'}, - placementCode: 'ad-unit-1', - sizes: [[300, 250], [300, 200]] - }, bid2_zone2 = { - bidder: 'rtbdemandadk', - bidId: 'Bid_02', - params: {zoneId: 2, host: 'rtb.rtbdemand.com'}, - placementCode: 'ad-unit-2', - sizes: [[728, 90]] - }, bid3_host2 = { - bidder: 'rtbdemandadk', - bidId: 'Bid_02', - params: {zoneId: 1, host: 'rtb-private.rtbdemand.com'}, - placementCode: 'ad-unit-2', - sizes: [[728, 90]] - }, bid_without_zone = { - bidder: 'rtbdemandadk', - bidId: 'Bid_W', - params: {host: 'rtb-private.rtbdemand.com'}, - placementCode: 'ad-unit-1', - sizes: [[728, 90]] - }, bid_without_host = { - bidder: 'rtbdemandadk', - bidId: 'Bid_W', - params: {zoneId: 1}, - placementCode: 'ad-unit-1', - sizes: [[728, 90]] - }, bid_with_wrong_zoneId = { - bidder: 'rtbdemandadk', - bidId: 'Bid_02', - params: {zoneId: 'wrong id', host: 'rtb.rtbdemand.com'}, - placementCode: 'ad-unit-2', - sizes: [[728, 90]] - }, bid_video = { - bidder: 'rtbdemandadk', - bidId: 'Bid_Video', - sizes: [640, 480], - mediaType: 'video', - params: { - zoneId: 1, - host: 'rtb.rtbdemand.com', - video: { - mimes: ['video/mp4', 'video/webm', 'video/x-flv'] - } - }, - placementCode: 'ad-unit-1' - }; - - const bidResponse1 = { - id: 'bid1', - seatbid: [{ - bid: [{ - id: '1', - impid: 'Bid_01', - crid: '100_001', - price: 3.01, - nurl: 'https://rtb.com/win?i=ZjKoPYSFI3Y_0', - adm: '', - w: 300, - h: 250 - }] - }], - cur: 'USD', - ext: { - adk_usersync: ['http://adk.sync.com/sync'] - } - }, bidResponse2 = { - id: 'bid2', - seatbid: [{ - bid: [{ - id: '2', - impid: 'Bid_02', - crid: '100_002', - price: 1.31, - adm: '', - w: 300, - h: 250 - }] - }], - cur: 'USD' - }, videoBidResponse = { - id: '47ce4badcf7482', - seatbid: [{ - bid: [{ - id: 'sZSYq5zYMxo_0', - impid: 'Bid_Video', - crid: '100_003', - price: 0.00145, - adid: '158801', - nurl: 'https://rtb.com/win?i=sZSYq5zYMxo_0&f=nurl', - cid: '16855' - }] - }], - cur: 'USD' - }, usersyncOnlyResponse = { - id: 'nobid1', - ext: { - adk_usersync: ['http://adk.sync.com/sync'] - } - }; - - describe('input parameters validation', function () { - it('empty request shouldn\'t generate exception', function () { - expect(spec.isBidRequestValid({ - bidderCode: 'rtbdemandadk' - })).to.be.equal(false); - }); - - it('request without zone shouldn\'t issue a request', function () { - expect(spec.isBidRequestValid(bid_without_zone)).to.be.equal(false); - }); - - it('request without host shouldn\'t issue a request', function () { - expect(spec.isBidRequestValid(bid_without_host)).to.be.equal(false); - }); - - it('empty request shouldn\'t generate exception', function () { - expect(spec.isBidRequestValid(bid_with_wrong_zoneId)).to.be.equal(false); - }); - }); - - describe('banner request building', function () { - let bidRequest; - before(function () { - let wmock = sinon.stub(utils, 'getTopWindowLocation').callsFake(() => ({ - protocol: 'https:', - hostname: 'example.com', - host: 'example.com', - pathname: '/index.html', - href: 'https://example.com/index.html' - })); - let dntmock = sinon.stub(utils, 'getDNT').callsFake(() => true); - let request = spec.buildRequests([bid1_zone1])[0]; - bidRequest = JSON.parse(request.data.r); - wmock.restore(); - dntmock.restore(); - }); - - it('should be a first-price auction', function () { - expect(bidRequest).to.have.property('at', 1); - }); - - it('should have banner object', function () { - expect(bidRequest.imp[0]).to.have.property('banner'); - }); - - it('should have w/h', function () { - expect(bidRequest.imp[0].banner).to.have.property('format'); - expect(bidRequest.imp[0].banner.format).to.be.eql([{w: 300, h: 250}, {w: 300, h: 200}]); - }); - - it('should respect secure connection', function () { - expect(bidRequest.imp[0]).to.have.property('secure', 1); - }); - - it('should have tagid', function () { - expect(bidRequest.imp[0]).to.have.property('tagid', 'ad-unit-1'); - }); - - it('should create proper site block', function () { - expect(bidRequest.site).to.have.property('domain', 'example.com'); - expect(bidRequest.site).to.have.property('page', 'https://example.com/index.html'); - }); - - it('should fill device with caller macro', function () { - expect(bidRequest).to.have.property('device'); - expect(bidRequest.device).to.have.property('ip', 'caller'); - expect(bidRequest.device).to.have.property('ua', 'caller'); - expect(bidRequest.device).to.have.property('dnt', 1); - }); - }); - - describe('video request building', function () { - let bidRequest; - - before(function () { - let request = spec.buildRequests([bid_video])[0]; - bidRequest = JSON.parse(request.data.r); - }); - - it('should have video object', function () { - expect(bidRequest.imp[0]).to.have.property('video'); - }); - - it('should have h/w', function () { - expect(bidRequest.imp[0].video).to.have.property('w', 640); - expect(bidRequest.imp[0].video).to.have.property('h', 480); - }); - - it('should have tagid', function () { - expect(bidRequest.imp[0]).to.have.property('tagid', 'ad-unit-1'); - }); - }); - - describe('requests routing', function () { - it('should issue a request for each host', function () { - let pbRequests = spec.buildRequests([bid1_zone1, bid3_host2]); - expect(pbRequests).to.have.length(2); - expect(pbRequests[0].url).to.have.string(`//${bid1_zone1.params.host}/`); - expect(pbRequests[1].url).to.have.string(`//${bid3_host2.params.host}/`); - }); - - it('should issue a request for each zone', function () { - let pbRequests = spec.buildRequests([bid1_zone1, bid2_zone2]); - expect(pbRequests).to.have.length(2); - expect(pbRequests[0].data.zone).to.be.equal(bid1_zone1.params.zoneId); - expect(pbRequests[1].data.zone).to.be.equal(bid2_zone2.params.zoneId); - }); - }); - - describe('responses processing', function () { - it('should return fully-initialized banner bid-response', function () { - let request = spec.buildRequests([bid1_zone1])[0]; - let resp = spec.interpretResponse({body: bidResponse1}, request)[0]; - expect(resp).to.have.property('requestId', 'Bid_01'); - expect(resp).to.have.property('cpm', 3.01); - expect(resp).to.have.property('width', 300); - expect(resp).to.have.property('height', 250); - expect(resp).to.have.property('creativeId', '100_001'); - expect(resp).to.have.property('currency'); - expect(resp).to.have.property('ttl'); - expect(resp).to.have.property('mediaType', 'banner'); - expect(resp).to.have.property('ad'); - expect(resp.ad).to.have.string(''); - }); - - it('should return fully-initialized video bid-response', function () { - let request = spec.buildRequests([bid_video])[0]; - let resp = spec.interpretResponse({body: videoBidResponse}, request)[0]; - expect(resp).to.have.property('requestId', 'Bid_Video'); - expect(resp.mediaType).to.equal('video'); - expect(resp.cpm).to.equal(0.00145); - expect(resp.vastUrl).to.equal('https://rtb.com/win?i=sZSYq5zYMxo_0&f=nurl'); - expect(resp.width).to.equal(640); - expect(resp.height).to.equal(480); - }); - - it('should add nurl as pixel for banner response', function () { - let request = spec.buildRequests([bid1_zone1])[0]; - let resp = spec.interpretResponse({body: bidResponse1}, request)[0]; - let expectedNurl = bidResponse1.seatbid[0].bid[0].nurl + '&px=1'; - expect(resp.ad).to.have.string(expectedNurl); - }); - - it('should handle bidresponse with user-sync only', function () { - let request = spec.buildRequests([bid1_zone1])[0]; - let resp = spec.interpretResponse({body: usersyncOnlyResponse}, request); - expect(resp).to.have.length(0); - }); - - it('should perform usersync', function () { - let syncs = spec.getUserSyncs({iframeEnabled: false}, [{body: bidResponse1}]); - expect(syncs).to.have.length(0); - syncs = spec.getUserSyncs({iframeEnabled: true}, [{body: bidResponse1}]); - expect(syncs).to.have.length(1); - expect(syncs[0]).to.have.property('type', 'iframe'); - expect(syncs[0]).to.have.property('url', 'http://adk.sync.com/sync'); - }); - }); -}); diff --git a/test/spec/modules/rtbhouseBidAdapter_spec.js b/test/spec/modules/rtbhouseBidAdapter_spec.js index 67845fa1983a..6c6faf4e4d01 100644 --- a/test/spec/modules/rtbhouseBidAdapter_spec.js +++ b/test/spec/modules/rtbhouseBidAdapter_spec.js @@ -75,8 +75,8 @@ describe('RTBHouseAdapter', () => { 'refererInfo': { 'numIframes': 0, 'reachedTop': true, - 'referer': 'http://example.com', - 'stack': ['http://example.com'] + 'referer': 'https://example.com', + 'stack': ['https://example.com'] } }; @@ -402,10 +402,10 @@ describe('RTBHouseAdapter', () => { native: { ver: 1.1, link: { - url: 'http://example.com' + url: 'https://example.com' }, imptrackers: [ - 'http://example.com/imptracker' + 'https://example.com/imptracker' ], assets: [{ id: OPENRTB.NATIVE.ASSET_ID.TITLE, @@ -417,7 +417,7 @@ describe('RTBHouseAdapter', () => { id: OPENRTB.NATIVE.ASSET_ID.IMAGE, required: 1, img: { - url: 'http://example.com/image.jpg', + url: 'https://example.com/image.jpg', w: 150, h: 50 } @@ -446,10 +446,10 @@ describe('RTBHouseAdapter', () => { const bids = spec.interpretResponse({body: response}, {}); expect(bids[0].native).to.deep.equal({ title: 'Title text', - clickUrl: encodeURIComponent('http://example.com'), - impressionTrackers: ['http://example.com/imptracker'], + clickUrl: encodeURIComponent('https://example.com'), + impressionTrackers: ['https://example.com/imptracker'], image: { - url: encodeURIComponent('http://example.com/image.jpg'), + url: encodeURIComponent('https://example.com/image.jpg'), width: 150, height: 50 }, diff --git a/test/spec/modules/rubiconAnalyticsAdapter_spec.js b/test/spec/modules/rubiconAnalyticsAdapter_spec.js deleted file mode 100644 index dd34245bd8ef..000000000000 --- a/test/spec/modules/rubiconAnalyticsAdapter_spec.js +++ /dev/null @@ -1,814 +0,0 @@ -import rubiconAnalyticsAdapter, { SEND_TIMEOUT, parseBidResponse } from 'modules/rubiconAnalyticsAdapter'; -import CONSTANTS from 'src/constants.json'; -import { config } from 'src/config'; - -import { - setConfig, - addBidResponseHook, -} from 'modules/currency'; - -let Ajv = require('ajv'); -let schema = require('./rubiconAnalyticsSchema.json'); -let ajv = new Ajv({ - allErrors: true -}); - -let validator = ajv.compile(schema); - -function validate(message) { - validator(message); - expect(validator.errors).to.deep.equal(null); -} - -// using es6 "import * as events from 'src/events'" causes the events.getEvents stub not to work... -let events = require('src/events'); -let ajax = require('src/ajax'); -let utils = require('src/utils'); - -const { - EVENTS: { - AUCTION_INIT, - AUCTION_END, - BID_REQUESTED, - BID_RESPONSE, - BIDDER_DONE, - BID_WON, - BID_TIMEOUT, - SET_TARGETING - } -} = CONSTANTS; - -const BID = { - 'bidder': 'rubicon', - 'width': 640, - 'height': 480, - 'mediaType': 'video', - 'statusMessage': 'Bid available', - 'bidId': '2ecff0db240757', - 'adId': 'fake_ad_id', - 'source': 'client', - 'requestId': '2ecff0db240757', - 'currency': 'USD', - 'creativeId': '3571560', - 'cpm': 1.22752, - 'ttl': 300, - 'netRevenue': false, - 'ad': '', - 'rubiconTargeting': { - 'rpfl_elemid': '/19968336/header-bid-tag-0', - 'rpfl_14062': '2_tier0100' - }, - 'auctionId': '25c6d7f5-699a-4bfc-87c9-996f915341fa', - 'responseTimestamp': 1519149629415, - 'requestTimestamp': 1519149628471, - 'adUnitCode': '/19968336/header-bid-tag-0', - 'timeToRespond': 944, - 'pbLg': '1.00', - 'pbMg': '1.20', - 'pbHg': '1.22', - 'pbAg': '1.20', - 'pbDg': '1.22', - 'pbCg': '', - 'size': '640x480', - 'adserverTargeting': { - 'hb_bidder': 'rubicon', - 'hb_adid': '2ecff0db240757', - 'hb_pb': 1.20, - 'hb_size': '640x480', - 'hb_source': 'client' - }, - getStatusCode() { - return 1; - } -}; - -const BID2 = Object.assign({}, BID, { - adUnitCode: '/19968336/header-bid-tag1', - bidId: '3bd4ebb1c900e2', - adId: 'fake_ad_id', - requestId: '3bd4ebb1c900e2', - width: 728, - height: 90, - mediaType: 'banner', - cpm: 1.52, - source: 'server', - seatBidId: 'aaaa-bbbb-cccc-dddd', - rubiconTargeting: { - 'rpfl_elemid': '/19968336/header-bid-tag1', - 'rpfl_14062': '2_tier0100' - }, - adserverTargeting: { - 'hb_bidder': 'rubicon', - 'hb_adid': '3bd4ebb1c900e2', - 'hb_pb': '1.500', - 'hb_size': '728x90', - 'hb_source': 'server' - } -}); - -const MOCK = { - SET_TARGETING: { - [BID.adUnitCode]: BID.adserverTargeting, - [BID2.adUnitCode]: BID2.adserverTargeting - }, - AUCTION_INIT: { - 'auctionId': '25c6d7f5-699a-4bfc-87c9-996f915341fa', - 'timestamp': 1519767010567, - 'auctionStatus': 'inProgress', - 'adUnits': [ { - 'code': '/19968336/header-bid-tag1', - 'sizes': [[640, 480]], - 'bids': [ { - 'bidder': 'rubicon', - 'params': { - 'accountId': 1001, 'siteId': 113932, 'zoneId': 535512 - } - } ], - 'transactionId': 'ca4af27a-6d02-4f90-949d-d5541fa12014' - } - ], - 'adUnitCodes': ['/19968336/header-bid-tag1'], - 'bidderRequests': [ { - 'bidderCode': 'rubicon', - 'auctionId': '25c6d7f5-699a-4bfc-87c9-996f915341fa', - 'bidderRequestId': '1be65d7958826a', - 'bids': [ { - 'bidder': 'rubicon', - 'params': { - 'accountId': 1001, 'siteId': 113932, 'zoneId': 535512 - }, - 'mediaTypes': { - 'banner': { - 'sizes': [[640, 480]] - } - }, - 'adUnitCode': '/19968336/header-bid-tag1', - 'transactionId': 'ca4af27a-6d02-4f90-949d-d5541fa12014', - 'sizes': [[640, 480]], - 'bidId': '2ecff0db240757', - 'bidderRequestId': '1be65d7958826a', - 'auctionId': '25c6d7f5-699a-4bfc-87c9-996f915341fa', - 'src': 'client', - 'bidRequestsCount': 1 - } - ], - 'timeout': 3000, - 'refererInfo': { - 'referer': 'http://www.test.com/page.html', 'reachedTop': true, 'numIframes': 0, 'stack': ['http://www.test.com/page.html'] - } - } - ], - 'bidsReceived': [], - 'winningBids': [], - 'timeout': 3000, - 'config': { - 'accountId': 1001, 'endpoint': '//localhost:9999/event' - } - }, - BID_REQUESTED: { - 'bidder': 'rubicon', - 'auctionId': '25c6d7f5-699a-4bfc-87c9-996f915341fa', - 'bidderRequestId': '1be65d7958826a', - 'bids': [ - { - 'bidder': 'rubicon', - 'params': { - 'accountId': '1001', - 'siteId': '70608', - 'zoneId': '335918', - 'userId': '12346', - 'keywords': ['a', 'b', 'c'], - 'inventory': 'test', - 'visitor': {'ucat': 'new', 'lastsearch': 'iphone'}, - 'position': 'btf', - 'video': { - 'language': 'en', - 'playerHeight': 480, - 'playerWidth': 640, - 'size_id': 203, - 'skip': 1, - 'skipdelay': 15, - 'aeParams': { - 'p_aso.video.ext.skip': '1', - 'p_aso.video.ext.skipdelay': '15' - } - } - }, - 'mediaType': 'video', - 'adUnitCode': '/19968336/header-bid-tag-0', - 'transactionId': 'ca4af27a-6d02-4f90-949d-d5541fa12014', - 'sizes': [[640, 480]], - 'bidId': '2ecff0db240757', - 'bidderRequestId': '1be65d7958826a', - 'auctionId': '25c6d7f5-699a-4bfc-87c9-996f915341fa' - }, - { - 'bidder': 'rubicon', - 'params': { - 'accountId': '14062', - 'siteId': '70608', - 'zoneId': '335918', - 'userId': '12346', - 'keywords': ['a', 'b', 'c'], - 'inventory': {'rating': '4-star', 'prodtype': 'tech'}, - 'visitor': {'ucat': 'new', 'lastsearch': 'iphone'}, - 'position': 'atf' - }, - 'mediaTypes': { - 'banner': { - 'sizes': [[1000, 300], [970, 250], [728, 90]] - } - }, - 'adUnitCode': '/19968336/header-bid-tag1', - 'transactionId': 'c116413c-9e3f-401a-bee1-d56aec29a1d4', - 'sizes': [[1000, 300], [970, 250], [728, 90]], - 'bidId': '3bd4ebb1c900e2', - 'seatBidId': 'aaaa-bbbb-cccc-dddd', - 'bidderRequestId': '1be65d7958826a', - 'auctionId': '25c6d7f5-699a-4bfc-87c9-996f915341fa' - } - ], - 'auctionStart': 1519149536560, - 'timeout': 5000, - 'start': 1519149562216 - }, - BID_RESPONSE: [ - BID, - BID2 - ], - AUCTION_END: { - 'auctionId': '25c6d7f5-699a-4bfc-87c9-996f915341fa' - }, - BID_WON: [ - Object.assign({}, BID, { - 'status': 'rendered' - }), - Object.assign({}, BID2, { - 'status': 'rendered' - }) - ], - BIDDER_DONE: { - 'bidderCode': 'rubicon', - 'bids': [ - BID, - Object.assign({}, BID2, { - 'serverResponseTimeMs': 42, - }) - ] - }, - BID_TIMEOUT: [ - { - 'bidId': '2ecff0db240757', - 'bidder': 'rubicon', - 'adUnitCode': '/19968336/header-bid-tag-0', - 'auctionId': '25c6d7f5-699a-4bfc-87c9-996f915341fa' - } - ] -}; - -const ANALYTICS_MESSAGE = { - 'eventTimeMillis': 1519767013781, - 'integration': 'pbjs', - 'version': '$prebid.version$', - 'referrerUri': 'http://www.test.com/page.html', - 'auctions': [ - { - 'clientTimeoutMillis': 3000, - 'serverTimeoutMillis': 1000, - 'accountId': 1001, - 'samplingFactor': 1, - 'adUnits': [ - { - 'adUnitCode': '/19968336/header-bid-tag-0', - 'transactionId': 'ca4af27a-6d02-4f90-949d-d5541fa12014', - 'videoAdFormat': 'outstream', - 'mediaTypes': [ - 'video' - ], - 'dimensions': [ - { - 'width': 640, - 'height': 480 - } - ], - 'status': 'success', - 'accountId': 1001, - 'siteId': 70608, - 'zoneId': 335918, - 'adserverTargeting': { - 'hb_bidder': 'rubicon', - 'hb_adid': '2ecff0db240757', - 'hb_pb': '1.200', - 'hb_size': '640x480', - 'hb_source': 'client' - }, - 'bids': [ - { - 'bidder': 'rubicon', - 'bidId': '2ecff0db240757', - 'status': 'success', - 'source': 'client', - 'clientLatencyMillis': 3214, - 'params': { - 'accountId': '1001', - 'siteId': '70608', - 'zoneId': '335918' - }, - 'bidResponse': { - 'bidPriceUSD': 1.22752, - 'dimensions': { - 'width': 640, - 'height': 480 - }, - 'mediaType': 'video' - } - } - ] - }, - { - 'adUnitCode': '/19968336/header-bid-tag1', - 'transactionId': 'c116413c-9e3f-401a-bee1-d56aec29a1d4', - 'mediaTypes': [ - 'banner' - ], - 'dimensions': [ - { - 'width': 1000, - 'height': 300 - }, - { - 'width': 970, - 'height': 250 - }, - { - 'width': 728, - 'height': 90 - } - ], - 'status': 'success', - 'adserverTargeting': { - 'hb_bidder': 'rubicon', - 'hb_adid': '3bd4ebb1c900e2', - 'hb_pb': '1.500', - 'hb_size': '728x90', - 'hb_source': 'server' - }, - 'bids': [ - { - 'bidder': 'rubicon', - 'bidId': 'aaaa-bbbb-cccc-dddd', - 'status': 'success', - 'source': 'server', - 'clientLatencyMillis': 3214, - 'serverLatencyMillis': 42, - 'params': { - 'accountId': '14062', - 'siteId': '70608', - 'zoneId': '335918' - }, - 'bidResponse': { - 'bidPriceUSD': 1.52, - 'dimensions': { - 'width': 728, - 'height': 90 - }, - 'mediaType': 'banner' - } - } - ] - } - ] - } - ], - 'bidsWon': [ - { - 'bidder': 'rubicon', - 'transactionId': 'ca4af27a-6d02-4f90-949d-d5541fa12014', - 'adUnitCode': '/19968336/header-bid-tag-0', - 'bidId': '2ecff0db240757', - 'status': 'success', - 'source': 'client', - 'clientLatencyMillis': 3214, - 'samplingFactor': 1, - 'accountId': 1001, - 'siteId': 70608, - 'zoneId': 335918, - 'params': { - 'accountId': '1001', - 'siteId': '70608', - 'zoneId': '335918' - }, - 'videoAdFormat': 'outstream', - 'mediaTypes': [ - 'video' - ], - 'adserverTargeting': { - 'hb_bidder': 'rubicon', - 'hb_adid': '2ecff0db240757', - 'hb_pb': '1.200', - 'hb_size': '640x480', - 'hb_source': 'client' - }, - 'bidResponse': { - 'bidPriceUSD': 1.22752, - 'dimensions': { - 'width': 640, - 'height': 480 - }, - 'mediaType': 'video' - }, - 'bidwonStatus': 'success' - }, - { - 'bidder': 'rubicon', - 'transactionId': 'c116413c-9e3f-401a-bee1-d56aec29a1d4', - 'adUnitCode': '/19968336/header-bid-tag1', - 'bidId': 'aaaa-bbbb-cccc-dddd', - 'status': 'success', - 'source': 'server', - 'clientLatencyMillis': 3214, - 'serverLatencyMillis': 42, - 'samplingFactor': 1, - 'accountId': 1001, - 'params': { - 'accountId': '14062', - 'siteId': '70608', - 'zoneId': '335918' - }, - 'mediaTypes': [ - 'banner' - ], - 'adserverTargeting': { - 'hb_bidder': 'rubicon', - 'hb_adid': '3bd4ebb1c900e2', - 'hb_pb': '1.500', - 'hb_size': '728x90', - 'hb_source': 'server' - }, - 'bidResponse': { - 'bidPriceUSD': 1.52, - 'dimensions': { - 'width': 728, - 'height': 90 - }, - 'mediaType': 'banner' - }, - 'bidwonStatus': 'success' - } - ], - 'wrapperName': '10000_fakewrapper_test' -}; - -function performStandardAuction() { - events.emit(AUCTION_INIT, MOCK.AUCTION_INIT); - events.emit(BID_REQUESTED, MOCK.BID_REQUESTED); - events.emit(BID_RESPONSE, MOCK.BID_RESPONSE[0]); - events.emit(BID_RESPONSE, MOCK.BID_RESPONSE[1]); - events.emit(BIDDER_DONE, MOCK.BIDDER_DONE); - events.emit(AUCTION_END, MOCK.AUCTION_END); - events.emit(SET_TARGETING, MOCK.SET_TARGETING); - events.emit(BID_WON, MOCK.BID_WON[0]); - events.emit(BID_WON, MOCK.BID_WON[1]); -} - -describe('rubicon analytics adapter', function () { - let sandbox; - let xhr; - let requests; - let oldScreen; - let clock; - - beforeEach(function () { - sandbox = sinon.sandbox.create(); - - xhr = sandbox.useFakeXMLHttpRequest(); - requests = []; - xhr.onCreate = request => requests.push(request); - - sandbox.stub(events, 'getEvents').returns([]); - - sandbox.stub(utils, 'getTopWindowUrl').returns('http://www.test.com/page.html'); - - clock = sandbox.useFakeTimers(1519767013781); - - config.setConfig({ - s2sConfig: { - timeout: 1000, - accountId: 10000, - }, - rubicon: { - wrapperName: '10000_fakewrapper_test' - } - }) - }); - - afterEach(function () { - sandbox.restore(); - config.resetConfig(); - }); - - it('should require accountId', function () { - sandbox.stub(utils, 'logError'); - - rubiconAnalyticsAdapter.enableAnalytics({ - options: { - endpoint: '//localhost:9999/event' - } - }); - - expect(utils.logError.called).to.equal(true); - }); - - it('should require endpoint', function () { - sandbox.stub(utils, 'logError'); - - rubiconAnalyticsAdapter.enableAnalytics({ - options: { - accountId: 1001 - } - }); - - expect(utils.logError.called).to.equal(true); - }); - - describe('sampling', function () { - beforeEach(function () { - sandbox.stub(Math, 'random').returns(0.08); - sandbox.stub(utils, 'logError'); - }); - - afterEach(function () { - rubiconAnalyticsAdapter.disableAnalytics(); - }); - - describe('with options.samplingFactor', function () { - it('should sample', function () { - rubiconAnalyticsAdapter.enableAnalytics({ - options: { - endpoint: '//localhost:9999/event', - accountId: 1001, - samplingFactor: 10 - } - }); - - performStandardAuction(); - - expect(requests.length).to.equal(1); - }); - - it('should unsample', function () { - rubiconAnalyticsAdapter.enableAnalytics({ - options: { - endpoint: '//localhost:9999/event', - accountId: 1001, - samplingFactor: 20 - } - }); - - performStandardAuction(); - - expect(requests.length).to.equal(0); - }); - - it('should throw errors for invalid samplingFactor', function () { - rubiconAnalyticsAdapter.enableAnalytics({ - options: { - endpoint: '//localhost:9999/event', - accountId: 1001, - samplingFactor: 30 - } - }); - - performStandardAuction(); - - expect(requests.length).to.equal(0); - expect(utils.logError.called).to.equal(true); - }); - }); - describe('with options.sampling', function () { - it('should sample', function () { - rubiconAnalyticsAdapter.enableAnalytics({ - options: { - endpoint: '//localhost:9999/event', - accountId: 1001, - sampling: 0.1 - } - }); - - performStandardAuction(); - - expect(requests.length).to.equal(1); - }); - - it('should unsample', function () { - rubiconAnalyticsAdapter.enableAnalytics({ - options: { - endpoint: '//localhost:9999/event', - accountId: 1001, - sampling: 0.05 - } - }); - - performStandardAuction(); - - expect(requests.length).to.equal(0); - }); - - it('should throw errors for invalid samplingFactor', function () { - rubiconAnalyticsAdapter.enableAnalytics({ - options: { - endpoint: '//localhost:9999/event', - accountId: 1001, - sampling: 1 / 30 - } - }); - - performStandardAuction(); - - expect(requests.length).to.equal(0); - expect(utils.logError.called).to.equal(true); - }); - }); - }); - - describe('when handling events', function () { - beforeEach(function () { - rubiconAnalyticsAdapter.enableAnalytics({ - options: { - endpoint: '//localhost:9999/event', - accountId: 1001 - } - }); - }); - - afterEach(function () { - rubiconAnalyticsAdapter.disableAnalytics(); - }); - - it('should build a batched message from prebid events', function () { - performStandardAuction(); - - expect(requests.length).to.equal(1); - let request = requests[0]; - - expect(request.url).to.equal('//localhost:9999/event'); - - let message = JSON.parse(request.requestBody); - validate(message); - - expect(message).to.deep.equal(ANALYTICS_MESSAGE); - }); - - it('should pick the highest cpm bid if more than one bid per bidRequestId', function () { - // Only want one bid request in our mock auction - let bidRequested = utils.deepClone(MOCK.BID_REQUESTED); - bidRequested.bids.shift(); - let auctionInit = utils.deepClone(MOCK.AUCTION_INIT); - auctionInit.adUnits.shift(); - - // clone the mock bidResponse and duplicate - let duplicateResponse1 = utils.deepClone(BID2); - duplicateResponse1.cpm = 1.0; - duplicateResponse1.adserverTargeting.hb_pb = '1.0'; - duplicateResponse1.adserverTargeting.hb_adid = '1111'; - let duplicateResponse2 = utils.deepClone(BID2); - duplicateResponse2.cpm = 5.5; - duplicateResponse2.adserverTargeting.hb_pb = '5.5'; - duplicateResponse2.adserverTargeting.hb_adid = '5555'; - let duplicateResponse3 = utils.deepClone(BID2); - duplicateResponse3.cpm = 0.1; - duplicateResponse3.adserverTargeting.hb_pb = '0.1'; - duplicateResponse3.adserverTargeting.hb_adid = '3333'; - - const setTargeting = { - [duplicateResponse2.adUnitCode]: duplicateResponse2.adserverTargeting - }; - - const bidWon = Object.assign({}, duplicateResponse2, { - 'status': 'rendered' - }); - - // spoof the auction with just our duplicates - events.emit(AUCTION_INIT, auctionInit); - events.emit(BID_REQUESTED, bidRequested); - events.emit(BID_RESPONSE, duplicateResponse1); - events.emit(BID_RESPONSE, duplicateResponse2); - events.emit(BID_RESPONSE, duplicateResponse3); - events.emit(AUCTION_END, MOCK.AUCTION_END); - events.emit(SET_TARGETING, setTargeting); - events.emit(BID_WON, bidWon); - - let message = JSON.parse(requests[0].requestBody); - validate(message); - expect(message.auctions[0].adUnits[0].bids[0].bidResponse.bidPriceUSD).to.equal(5.5); - expect(message.auctions[0].adUnits[0].adserverTargeting.hb_pb).to.equal('5.5'); - expect(message.auctions[0].adUnits[0].adserverTargeting.hb_adid).to.equal('5555'); - expect(message.bidsWon.length).to.equal(1); - expect(message.bidsWon[0].bidResponse.bidPriceUSD).to.equal(5.5); - expect(message.bidsWon[0].adserverTargeting.hb_pb).to.equal('5.5'); - expect(message.bidsWon[0].adserverTargeting.hb_adid).to.equal('5555'); - }); - - it('should send batched message without BID_WON if necessary and further BID_WON events individually', function () { - events.emit(AUCTION_INIT, MOCK.AUCTION_INIT); - events.emit(BID_REQUESTED, MOCK.BID_REQUESTED); - events.emit(BID_RESPONSE, MOCK.BID_RESPONSE[0]); - events.emit(BID_RESPONSE, MOCK.BID_RESPONSE[1]); - events.emit(BIDDER_DONE, MOCK.BIDDER_DONE); - events.emit(AUCTION_END, MOCK.AUCTION_END); - events.emit(SET_TARGETING, MOCK.SET_TARGETING); - events.emit(BID_WON, MOCK.BID_WON[0]); - - clock.tick(SEND_TIMEOUT + 1000); - - events.emit(BID_WON, MOCK.BID_WON[1]); - - expect(requests.length).to.equal(2); - - let message = JSON.parse(requests[0].requestBody); - validate(message); - expect(message.bidsWon.length).to.equal(1); - expect(message.auctions).to.deep.equal(ANALYTICS_MESSAGE.auctions); - expect(message.bidsWon[0]).to.deep.equal(ANALYTICS_MESSAGE.bidsWon[0]); - - message = JSON.parse(requests[1].requestBody); - validate(message); - expect(message.bidsWon.length).to.equal(1); - expect(message).to.not.have.property('auctions'); - expect(message.bidsWon[0]).to.deep.equal(ANALYTICS_MESSAGE.bidsWon[1]); - }); - - it('should properly mark bids as timed out', function () { - events.emit(AUCTION_INIT, MOCK.AUCTION_INIT); - events.emit(BID_REQUESTED, MOCK.BID_REQUESTED); - events.emit(BID_TIMEOUT, MOCK.BID_TIMEOUT); - events.emit(AUCTION_END, MOCK.AUCTION_END); - - clock.tick(SEND_TIMEOUT + 1000); - - expect(requests.length).to.equal(1); - - let message = JSON.parse(requests[0].requestBody); - validate(message); - let timedOutBid = message.auctions[0].adUnits[0].bids[0]; - expect(timedOutBid.status).to.equal('error'); - expect(timedOutBid.error.code).to.equal('timeout-error'); - expect(timedOutBid).to.not.have.property('bidResponse'); - }); - - it('should successfully convert bid price to USD in parseBidResponse', function () { - // Set the rates - setConfig({ - adServerCurrency: 'JPY', - rates: { - USD: { - JPY: 100 - } - } - }); - - // set our bid response to JPY - const bidCopy = utils.deepClone(BID2); - bidCopy.currency = 'JPY'; - bidCopy.cpm = 100; - - // Now add the bidResponse hook which hooks on the currenct conversion function onto the bid response - let innerBid; - addBidResponseHook(function(adCodeId, bid) { - innerBid = bid; - }, 'elementId', bidCopy); - - // Use the rubi analytics parseBidResponse Function to get the resulting cpm from the bid response! - const bidResponseObj = parseBidResponse(innerBid); - expect(bidResponseObj).to.have.property('bidPriceUSD'); - expect(bidResponseObj.bidPriceUSD).to.equal(1.0); - }); - }); - - describe('config with integration type', () => { - it('should use the integration type provided in the config instead of the default', () => { - sandbox.stub(config, 'getConfig').callsFake(function (key) { - const config = { - 'rubicon.int_type': 'testType' - }; - return config[key]; - }); - - rubiconAnalyticsAdapter.enableAnalytics({ - options: { - endpoint: '//localhost:9999/event', - accountId: 1001 - } - }); - - performStandardAuction(); - - expect(requests.length).to.equal(1); - const request = requests[0]; - const message = JSON.parse(request.requestBody); - expect(message.integration).to.equal('testType'); - - rubiconAnalyticsAdapter.disableAnalytics(); - }); - }); -}); diff --git a/test/spec/modules/rubiconBidAdapter_spec.js b/test/spec/modules/rubiconBidAdapter_spec.js index c69415846520..d0c0773ff452 100644 --- a/test/spec/modules/rubiconBidAdapter_spec.js +++ b/test/spec/modules/rubiconBidAdapter_spec.js @@ -550,12 +550,12 @@ describe('the rubicon adapter', function () { it('should add referer info to request data', function () { let refererInfo = { - referer: 'http://www.prebid.org', + referer: 'https://www.prebid.org', reachedTop: true, numIframes: 1, stack: [ - 'http://www.prebid.org/page.html', - 'http://www.prebid.org/iframe1.html', + 'https://www.prebid.org/page.html', + 'https://www.prebid.org/iframe1.html', ] }; @@ -564,7 +564,7 @@ describe('the rubicon adapter', function () { let [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); expect(parseQuery(request.data).rf).to.exist; - expect(parseQuery(request.data).rf).to.equal('http://www.prebid.org'); + expect(parseQuery(request.data).rf).to.equal('https://www.prebid.org'); }); it('page_url should use params.referrer, config.getConfig("pageUrl"), bidderRequest.refererInfo in that order', function () { @@ -572,20 +572,20 @@ describe('the rubicon adapter', function () { expect(parseQuery(request.data).rf).to.equal('localhost'); delete bidderRequest.bids[0].params.referrer; - let refererInfo = { referer: 'http://www.prebid.org' }; + let refererInfo = { referer: 'https://www.prebid.org' }; bidderRequest = Object.assign({refererInfo}, bidderRequest); [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); - expect(parseQuery(request.data).rf).to.equal('http://www.prebid.org'); + expect(parseQuery(request.data).rf).to.equal('https://www.prebid.org'); let origGetConfig = config.getConfig; sandbox.stub(config, 'getConfig').callsFake(function (key) { if (key === 'pageUrl') { - return 'http://www.rubiconproject.com'; + return 'https://www.rubiconproject.com'; } return origGetConfig.apply(config, arguments); }); [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); - expect(parseQuery(request.data).rf).to.equal('http://www.rubiconproject.com'); + expect(parseQuery(request.data).rf).to.equal('https://www.rubiconproject.com'); bidderRequest.bids[0].params.secure = true; [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); @@ -2455,7 +2455,7 @@ describe('the rubicon adapter', function () { describe('get price granularity', function() { it('should return correct buckets for all price granularity values', function() { - const CUSTOM_PRICE_BUCKET_ITEM = {min: 0, max: 5, increment: 0.5}; + const CUSTOM_PRICE_BUCKET_ITEM = {max: 5, increment: 0.5}; const mockConfig = { priceGranularity: undefined, diff --git a/test/spec/modules/saraBidAdapter_spec.js b/test/spec/modules/saraBidAdapter_spec.js deleted file mode 100644 index 6614ec652657..000000000000 --- a/test/spec/modules/saraBidAdapter_spec.js +++ /dev/null @@ -1,293 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/saraBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; - -describe('Sara Adapter', function () { - const adapter = newBidder(spec); - - describe('inherited functions', function () { - it('exists and is a function', function () { - expect(adapter.callBids).to.exist.and.to.be.a('function'); - }); - }); - - describe('isBidRequestValid', function () { - let bid = { - 'bidder': 'sara', - 'params': { - 'uid': '4' - }, - 'adUnitCode': 'adunit-code', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - }; - - it('should return true when required params found', function () { - expect(spec.isBidRequestValid(bid)).to.equal(true); - }); - - it('should return false when required params are not passed', function () { - let bid = Object.assign({}, bid); - delete bid.params; - bid.params = { - 'uid': 0 - }; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - }); - - describe('buildRequests', function () { - function parseRequest(url) { - const res = {}; - url.split('&').forEach((it) => { - const couple = it.split('='); - res[couple[0]] = decodeURIComponent(couple[1]); - }); - return res; - } - let bidRequests = [ - { - 'bidder': 'sara', - 'params': { - 'uid': '5' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - }, - { - 'bidder': 'sara', - 'params': { - 'uid': '5' - }, - 'adUnitCode': 'adunit-code-2', - 'sizes': [[728, 90]], - 'bidId': '3150ccb55da321', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - }, - { - 'bidder': 'sara', - 'params': { - 'uid': '6' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '42dbe3a7168a6a', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - } - ]; - - it('should attach valid params to the tag', function () { - const request = spec.buildRequests([bidRequests[0]]); - expect(request.data).to.be.an('string'); - const payload = parseRequest(request.data); - expect(payload).to.have.property('u').that.is.a('string'); - expect(payload).to.have.property('pt', 'net'); - expect(payload).to.have.property('auids', '5'); - }); - - it('auids must not be duplicated', function () { - const request = spec.buildRequests(bidRequests); - expect(request.data).to.be.an('string'); - const payload = parseRequest(request.data); - expect(payload).to.have.property('u').that.is.a('string'); - expect(payload).to.have.property('pt', 'net'); - expect(payload).to.have.property('auids', '5,6'); - }); - - it('pt parameter must be "gross" if params.priceType === "gross"', function () { - bidRequests[1].params.priceType = 'gross'; - const request = spec.buildRequests(bidRequests); - expect(request.data).to.be.an('string'); - const payload = parseRequest(request.data); - expect(payload).to.have.property('u').that.is.a('string'); - expect(payload).to.have.property('pt', 'gross'); - expect(payload).to.have.property('auids', '5,6'); - delete bidRequests[1].params.priceType; - }); - - it('pt parameter must be "net" or "gross"', function () { - bidRequests[1].params.priceType = 'some'; - const request = spec.buildRequests(bidRequests); - expect(request.data).to.be.an('string'); - const payload = parseRequest(request.data); - expect(payload).to.have.property('u').that.is.a('string'); - expect(payload).to.have.property('pt', 'net'); - expect(payload).to.have.property('auids', '5,6'); - delete bidRequests[1].params.priceType; - }); - }); - - describe('interpretResponse', function () { - const responses = [ - {'bid': [{'price': 1.15, 'adm': '
test content 1
', 'auid': 4, 'h': 250, 'w': 300}], 'seat': '1'}, - {'bid': [{'price': 0.5, 'adm': '
test content 2
', 'auid': 5, 'h': 90, 'w': 728}], 'seat': '1'}, - {'bid': [{'price': 0, 'auid': 6, 'h': 250, 'w': 300}], 'seat': '1'}, - {'bid': [{'price': 0, 'adm': '
test content 4
', 'h': 250, 'w': 300}], 'seat': '1'}, - undefined, - {'bid': [], 'seat': '1'}, - {'seat': '1'}, - ]; - - it('should get correct bid response', function () { - const bidRequests = [ - { - 'bidder': 'sara', - 'params': { - 'uid': '4' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '659423fff799cb', - 'bidderRequestId': '5f2009617a7c0a', - 'auctionId': '1cbd2feafe5e8b', - } - ]; - const request = spec.buildRequests(bidRequests); - const expectedResponse = [ - { - 'requestId': '659423fff799cb', - 'cpm': 1.15, - 'creativeId': 4, - 'dealId': undefined, - 'width': 300, - 'height': 250, - 'ad': '
test content 1
', - 'currency': 'USD', - 'netRevenue': true, - 'ttl': 360, - } - ]; - - const result = spec.interpretResponse({'body': {'seatbid': [responses[0]]}}, request); - expect(result).to.deep.equal(expectedResponse); - }); - - it('should get correct multi bid response', function () { - const bidRequests = [ - { - 'bidder': 'sara', - 'params': { - 'uid': '4' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '300bfeb0d71a5b', - 'bidderRequestId': '2c2bb1972df9a', - 'auctionId': '1fa09aee5c8c99', - }, - { - 'bidder': 'sara', - 'params': { - 'uid': '5' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '4dff80cc4ee346', - 'bidderRequestId': '2c2bb1972df9a', - 'auctionId': '1fa09aee5c8c99', - }, - { - 'bidder': 'sara', - 'params': { - 'uid': '4' - }, - 'adUnitCode': 'adunit-code-2', - 'sizes': [[728, 90]], - 'bidId': '5703af74d0472a', - 'bidderRequestId': '2c2bb1972df9a', - 'auctionId': '1fa09aee5c8c99', - } - ]; - const request = spec.buildRequests(bidRequests); - const expectedResponse = [ - { - 'requestId': '300bfeb0d71a5b', - 'cpm': 1.15, - 'creativeId': 4, - 'dealId': undefined, - 'width': 300, - 'height': 250, - 'ad': '
test content 1
', - 'currency': 'USD', - 'netRevenue': true, - 'ttl': 360, - }, - { - 'requestId': '5703af74d0472a', - 'cpm': 1.15, - 'creativeId': 4, - 'dealId': undefined, - 'width': 300, - 'height': 250, - 'ad': '
test content 1
', - 'currency': 'USD', - 'netRevenue': true, - 'ttl': 360, - }, - { - 'requestId': '4dff80cc4ee346', - 'cpm': 0.5, - 'creativeId': 5, - 'dealId': undefined, - 'width': 728, - 'height': 90, - 'ad': '
test content 2
', - 'currency': 'USD', - 'netRevenue': true, - 'ttl': 360, - } - ]; - - const result = spec.interpretResponse({'body': {'seatbid': [responses[0], responses[1]]}}, request); - expect(result).to.deep.equal(expectedResponse); - }); - - it('handles wrong and nobid responses', function () { - const bidRequests = [ - { - 'bidder': 'sara', - 'params': { - 'uid': '6' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '300bfeb0d7190gf', - 'bidderRequestId': '2c2bb1972d23af', - 'auctionId': '1fa09aee5c84d34', - }, - { - 'bidder': 'sara', - 'params': { - 'uid': '7' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '300bfeb0d71321', - 'bidderRequestId': '2c2bb1972d23af', - 'auctionId': '1fa09aee5c84d34', - }, - { - 'bidder': 'sara', - 'params': { - 'uid': '8' - }, - 'adUnitCode': 'adunit-code-2', - 'sizes': [[728, 90]], - 'bidId': '300bfeb0d7183bb', - 'bidderRequestId': '2c2bb1972d23af', - 'auctionId': '1fa09aee5c84d34', - } - ]; - const request = spec.buildRequests(bidRequests); - const result = spec.interpretResponse({'body': {'seatbid': responses.slice(2)}}, request); - expect(result.length).to.equal(0); - }); - }); -}); diff --git a/test/spec/modules/sekindoUMBidAdapter_spec.js b/test/spec/modules/sekindoUMBidAdapter_spec.js index b699015bb3e0..2718d26b2b4a 100644 --- a/test/spec/modules/sekindoUMBidAdapter_spec.js +++ b/test/spec/modules/sekindoUMBidAdapter_spec.js @@ -143,7 +143,7 @@ describe('sekindoUMAdapter', function () { 'headers': function(header) { return 'dummy header'; }, - 'body': {'id': '30b31c1838de1e', 'bidderCode': 'sekindoUM', 'cpm': 2.1951, 'width': 300, 'height': 250, 'vastUrl': '//vastUrl', 'ttl': 36000, 'creativeId': '323774', 'netRevenue': true, 'currency': 'USD'} + 'body': {'id': '30b31c1838de1e', 'bidderCode': 'sekindoUM', 'cpm': 2.1951, 'width': 300, 'height': 250, 'vastUrl': 'https://vastUrl', 'ttl': 36000, 'creativeId': '323774', 'netRevenue': true, 'currency': 'USD'} }; bidRequests.mediaType = 'video'; bidRequests.params = videoParams; @@ -158,7 +158,7 @@ describe('sekindoUMAdapter', function () { 'currency': 'USD', 'netRevenue': true, 'ttl': 36000, - 'vastUrl': '//vastUrl' + 'vastUrl': 'https://vastUrl' } ]; let result = spec.interpretResponse(response, bidRequests); diff --git a/test/spec/modules/serverbidBidAdapter_spec.js b/test/spec/modules/serverbidBidAdapter_spec.js deleted file mode 100644 index 8949463e151b..000000000000 --- a/test/spec/modules/serverbidBidAdapter_spec.js +++ /dev/null @@ -1,253 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/serverbidBidAdapter'; -import { createBid } from 'src/bidfactory'; - -const ENDPOINT = 'https://e.serverbid.com/api/v2'; -const SMARTSYNC_CALLBACK = 'serverbidCallBids'; - -const REQUEST = { - 'bidderCode': 'serverbid', - 'auctionId': 'a4713c32-3762-4798-b342-4ab810ca770d', - 'bidderRequestId': '109f2a181342a9', - 'bidRequest': [{ - 'bidder': 'serverbid', - 'params': { - 'networkId': 9969, - 'siteId': 730181 - }, - 'placementCode': 'div-gpt-ad-1487778092495-0', - 'sizes': [ - [728, 90], - [970, 90] - ], - 'bidId': '2b0f82502298c9', - 'bidderRequestId': '109f2a181342a9', - 'auctionId': 'a4713c32-3762-4798-b342-4ab810ca770d' - }, - { - 'bidder': 'serverbid', - 'params': { - 'networkId': 9969, - 'siteId': 730181 - }, - 'placementCode': 'div-gpt-ad-1487778092495-0', - 'sizes': [ - [728, 90], - [970, 90] - ], - 'bidId': '123', - 'bidderRequestId': '109f2a181342a9', - 'auctionId': 'a4713c32-3762-4798-b342-4ab810ca770d' - }], - 'start': 1487883186070, - 'auctionStart': 1487883186069, - 'timeout': 3000 -}; - -const RESPONSE = { - 'headers': null, - 'body': { - 'user': { 'key': 'ue1-2d33e91b71e74929b4aeecc23f4376f1' }, - 'decisions': { - '2b0f82502298c9': { - 'adId': 2364764, - 'creativeId': 1950991, - 'flightId': 2788300, - 'campaignId': 542982, - 'clickUrl': 'https://e.serverbid.com/r', - 'impressionUrl': 'https://e.serverbid.com/i.gif', - 'contents': [{ - 'type': 'html', - 'body': '', - 'data': { - 'height': 90, - 'width': 728, - 'imageUrl': 'https://static.adzerk.net/Advertisers/b0ab77db8a7848c8b78931aed022a5ef.gif', - 'fileName': 'b0ab77db8a7848c8b78931aed022a5ef.gif' - }, - 'template': 'image' - }], - 'height': 90, - 'width': 728, - 'events': [], - 'pricing': {'price': 0.5, 'clearPrice': 0.5, 'revenue': 0.0005, 'rateType': 2, 'eCPM': 0.5} - }, - '123': { - 'adId': 2364764, - 'creativeId': 1950991, - 'flightId': 2788300, - 'campaignId': 542982, - 'clickUrl': 'https://e.serverbid.com/r', - 'impressionUrl': 'https://e.serverbid.com/i.gif', - 'contents': [{ - 'type': 'html', - 'body': '', - 'data': { - 'height': 90, - 'width': 728, - 'imageUrl': 'https://static.adzerk.net/Advertisers/b0ab77db8a7848c8b78931aed022a5ef.gif', - 'fileName': 'b0ab77db8a7848c8b78931aed022a5ef.gif' - }, - 'template': 'image' - }], - 'height': 90, - 'width': 728, - 'events': [], - 'pricing': {'price': 0.5, 'clearPrice': 0.5, 'revenue': 0.0005, 'rateType': 2, 'eCPM': 0.5} - } - } - } -}; - -describe('Serverbid BidAdapter', function () { - let bidRequests; - let adapter = spec; - - beforeEach(function () { - bidRequests = [ - { - bidder: 'serverbid', - params: { - networkId: '9969', - siteId: '730181' - }, - placementCode: 'header-bid-tag-1', - sizes: [[300, 250], [300, 600]], - bidId: '23acc48ad47af5', - auctionId: '0fb4905b-9456-4152-86be-c6f6d259ba99', - bidderRequestId: '1c56ad30b9b8ca8', - transactionId: '92489f71-1bf2-49a0-adf9-000cea934729' - } - ]; - }); - - describe('bid request validation', function () { - it('should accept valid bid requests', function () { - let bid = { - bidder: 'serverbid', - params: { - networkId: '9969', - siteId: '123' - } - }; - expect(spec.isBidRequestValid(bid)).to.equal(true); - }); - - it('should accept valid bid requests with extra fields', function () { - let bid = { - bidder: 'serverbid', - params: { - networkId: '9969', - siteId: '123', - zoneId: '123' - } - }; - expect(spec.isBidRequestValid(bid)).to.equal(true); - }); - - it('should reject bid requests without siteId', function () { - let bid = { - bidder: 'serverbid', - params: { - networkId: '9969' - } - }; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - - it('should reject bid requests without networkId', function () { - let bid = { - bidder: 'serverbid', - params: { - siteId: '9969' - } - }; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - }); - - describe('buildRequests validation', function () { - it('creates request data', function () { - let request = spec.buildRequests(bidRequests); - - expect(request).to.exist.and.to.be.a('object'); - }); - - it('request to serverbid should contain a url', function () { - let request = spec.buildRequests(bidRequests); - - expect(request.url).to.have.string('serverbid.com'); - }); - - it('requires valid bids to make request', function () { - let request = spec.buildRequests([]); - expect(request.bidRequest).to.be.empty; - }); - - it('sends bid request to ENDPOINT via POST', function () { - let request = spec.buildRequests(bidRequests); - - expect(request.method).to.have.string('POST'); - }); - }); - describe('interpretResponse validation', function () { - it('response should have valid bidderCode', function () { - let bidRequest = spec.buildRequests(REQUEST.bidRequest); - let bid = createBid(1, bidRequest.bidRequest[0]); - - expect(bid.bidderCode).to.equal('serverbid'); - }); - - it('response should include objects for all bids', function () { - let bids = spec.interpretResponse(RESPONSE, REQUEST); - - expect(bids.length).to.equal(2); - }); - - it('registers bids', function () { - let bids = spec.interpretResponse(RESPONSE, REQUEST); - bids.forEach(b => { - expect(b).to.have.property('cpm'); - expect(b.cpm).to.be.above(0); - expect(b).to.have.property('requestId'); - expect(b).to.have.property('cpm'); - expect(b).to.have.property('width'); - expect(b).to.have.property('height'); - expect(b).to.have.property('ad'); - expect(b).to.have.property('currency', 'USD'); - expect(b).to.have.property('creativeId'); - expect(b).to.have.property('ttl', 360); - expect(b).to.have.property('netRevenue', true); - expect(b).to.have.property('referrer'); - }); - }); - - it('handles nobid responses', function () { - let EMPTY_RESP = Object.assign({}, RESPONSE, {'body': {'decisions': null}}) - let bids = spec.interpretResponse(EMPTY_RESP, REQUEST); - - expect(bids).to.be.empty; - }); - - it('handles no server response', function () { - let bids = spec.interpretResponse(null, REQUEST); - - expect(bids).to.be.empty; - }); - }); - describe('getUserSyncs', function () { - let syncOptions = {'iframeEnabled': true}; - - it('handles empty sync options', function () { - let opts = spec.getUserSyncs({}); - - expect(opts).to.be.undefined; - }); - - it('should return a sync url if iframe syncs are enabled', function () { - let opts = spec.getUserSyncs(syncOptions); - - expect(opts.length).to.equal(1); - }); - }); -}); diff --git a/test/spec/modules/serverbidServerBidAdapter_spec.js b/test/spec/modules/serverbidServerBidAdapter_spec.js deleted file mode 100644 index 1190648bb84b..000000000000 --- a/test/spec/modules/serverbidServerBidAdapter_spec.js +++ /dev/null @@ -1,303 +0,0 @@ -import { expect } from 'chai'; -import Adapter from 'modules/serverbidServerBidAdapter'; -import * as utils from 'src/utils'; -import { config } from 'src/config'; -import { ajax } from 'src/ajax'; - -const ENDPOINT = 'https://e.serverbid.com/api/v2'; - -let CONFIG = { - enabled: true, - bidders: ['appnexus'], - timeout: 1000, - adapter: 'serverbidServer', - networkId: 9969, - siteId: 730181, - endpoint: ENDPOINT -}; - -let CONFIG_ARG = { - s2sConfig: CONFIG -} - -const REQUEST = { - 'account_id': '1', - 'tid': '437fbbf5-33f5-487a-8e16-a7112903cfe5', - 'max_bids': 1, - 'timeout_millis': 1000, - 'url': '', - 'prebid_version': '0.21.0-pre', - 'ad_units': [ - { - 'code': 'div-gpt-ad-1460505748561-0', - 'sizes': [ - { - 'w': 300, - 'h': 250 - }, - { - 'w': 300, - 'h': 600 - } - ], - 'transactionId': '4ef956ad-fd83-406d-bd35-e4bb786ab86c', - 'bids': [ - { - 'bid_id': '123', - 'bidder': 'appnexus', - 'params': { - 'placementId': '10433394', - 'member': 123 - } - } - ] - } - ] -}; - -const BID_REQUESTS = [ - { - 'bidderCode': 'appnexus', - 'auctionId': '173afb6d132ba3', - 'bidderRequestId': '3d1063078dfcc8', - 'tid': '437fbbf5-33f5-487a-8e16-a7112903cfe5', - 'bids': [ - { - 'bidder': 'appnexus', - 'params': { - 'placementId': '10433394', - 'member': 123 - }, - 'bid_id': '123', - 'adUnitCode': 'div-gpt-ad-1460505748561-0', - 'transactionId': '4ef956ad-fd83-406d-bd35-e4bb786ab86c', - 'sizes': [ - { - 'w': 300, - 'h': 250 - } - ], - 'bidId': '259fb43aaa06c1', - 'bidderRequestId': '3d1063078dfcc8', - 'auctionId': '173afb6d132ba3' - } - ], - 'auctionStart': 1510852447530, - 'timeout': 5000, - 'src': 's2s', - 'doneCbCallCount': 0 - } -]; - -const RESPONSE = { - 'user': { 'key': 'ue1-2d33e91b71e74929b4aeecc23f4376f1' }, - 'decisions': { - '123': [{ - 'adId': 2364764, - 'creativeId': 1950991, - 'flightId': 2788300, - 'campaignId': 542982, - 'clickUrl': 'https://e.serverbid.com/r', - 'impressionUrl': 'https://e.serverbid.com/i.gif', - 'contents': [{ - 'type': 'html', - 'body': '', - 'data': { - 'height': 300, - 'width': 250, - 'imageUrl': 'https://static.adzerk.net/Advertisers/b0ab77db8a7848c8b78931aed022a5ef.gif', - 'fileName': 'b0ab77db8a7848c8b78931aed022a5ef.gif' - }, - 'template': 'image' - }], - 'height': 250, - 'width': 300, - 'events': [], - 'pricing': {'price': 0.5, 'clearPrice': 0.5, 'revenue': 0.0005, 'rateType': 2, 'eCPM': 0.5} - }], - } -}; - -const RESPONSE_NO_BID_NO_UNIT = { - 'user': { 'key': 'ue1-2d33e91b71e74929b4aeecc23f4376f1' }, - 'decisions': { - '123': [] - } -}; - -const REQUEST_TWO_UNITS = { - 'account_id': '1', - 'tid': '437fbbf5-33f5-487a-8e16-a7112903cfe5', - 'max_bids': 1, - 'timeout_millis': 1000, - 'url': '', - 'prebid_version': '0.21.0-pre', - 'ad_units': [ - { - 'code': 'div-gpt-ad-1460505748561-0', - 'sizes': [ - { - 'w': 300, - 'h': 250 - }, - { - 'w': 300, - 'h': 600 - } - ], - 'transactionId': '4ef956ad-fd83-406d-bd35-e4bb786ab86c', - 'bids': [ - { - 'bid_id': '123', - 'bidder': 'appnexus', - 'params': { - 'placementId': '10433394', - 'member': 123 - } - } - ] - }, - { - 'code': 'div-gpt-ad-1460505748561-1', - 'sizes': [ - { - 'w': 300, - 'h': 250 - }, - { - 'w': 300, - 'h': 600 - } - ], - 'transactionId': '4ef956ad-fd83-406d-bd35-e4bb786bb86d', - 'bids': [ - { - 'bid_id': '101111', - 'bidder': 'appnexus', - 'params': { - 'placementId': '10433394', - 'member': 123 - } - } - ] - } - ] -}; - -describe('ServerBid S2S Adapter', function () { - let adapter, - addBidResponse = sinon.spy(), - done = sinon.spy(); - - beforeEach(function () { - adapter = new Adapter() - }); - - afterEach(function () { - addBidResponse.resetHistory(); - done.resetHistory(); - }); - - describe('request function', function () { - let xhr; - let requests; - - beforeEach(function () { - xhr = sinon.useFakeXMLHttpRequest(); - requests = []; - xhr.onCreate = request => requests.push(request); - }); - - afterEach(function () { - xhr.restore(); - }); - - it('exists and is a function', function () { - expect(adapter.callBids).to.exist.and.to.be.a('function'); - }); - }); - - describe('response handler', function () { - let server; - - beforeEach(function () { - server = sinon.fakeServer.create(); - sinon.stub(utils, 'getBidRequest').returns({ - bidId: '123' - }); - }); - - afterEach(function () { - server.restore(); - utils.getBidRequest.restore(); - }); - - it('registers bids', function () { - server.respondWith(JSON.stringify(RESPONSE)); - - config.setConfig(CONFIG_ARG); - adapter.callBids(REQUEST, BID_REQUESTS, addBidResponse, done, ajax); - server.respond(); - sinon.assert.calledOnce(addBidResponse); - - const response = addBidResponse.firstCall.args[1]; - expect(response).to.have.property('statusMessage', 'Bid available'); - expect(response).to.have.property('cpm', 0.5); - expect(response).to.have.property('requestId', '123'); - }); - - it('registers no-bid response when ad unit not set', function () { - server.respondWith(JSON.stringify(RESPONSE_NO_BID_NO_UNIT)); - - config.setConfig(CONFIG_ARG); - adapter.callBids(REQUEST, BID_REQUESTS, addBidResponse, done, ajax); - server.respond(); - sinon.assert.calledOnce(addBidResponse); - - const ad_unit_code = addBidResponse.firstCall.args[0]; - expect(ad_unit_code).to.equal('div-gpt-ad-1460505748561-0'); - - const response = addBidResponse.firstCall.args[1]; - expect(response).to.have.property('statusMessage', 'Bid returned empty or error response'); - - const bid_request_passed = addBidResponse.firstCall.args[1]; - expect(bid_request_passed).to.have.property('requestId', '123'); - }); - - it('registers no-bid response when ad unit is set', function () { - server.respondWith(JSON.stringify(RESPONSE_NO_BID_NO_UNIT)); - - config.setConfig(CONFIG_ARG); - adapter.callBids(REQUEST, BID_REQUESTS, addBidResponse, done, ajax); - server.respond(); - sinon.assert.calledOnce(addBidResponse); - - const ad_unit_code = addBidResponse.firstCall.args[0]; - expect(ad_unit_code).to.equal('div-gpt-ad-1460505748561-0'); - - const response = addBidResponse.firstCall.args[1]; - expect(response).to.have.property('statusMessage', 'Bid returned empty or error response'); - }); - - it('registers no-bid response when there are less bids than requests', function () { - server.respondWith(JSON.stringify(RESPONSE)); - - config.setConfig(CONFIG_ARG); - adapter.callBids(REQUEST_TWO_UNITS, BID_REQUESTS, addBidResponse, done, ajax); - server.respond(); - - sinon.assert.calledTwice(addBidResponse); - - expect(addBidResponse.firstCall.args[0]).to.equal('div-gpt-ad-1460505748561-0'); - expect(addBidResponse.secondCall.args[0]).to.equal('div-gpt-ad-1460505748561-1'); - - expect(addBidResponse.firstCall.args[1]).to.have.property('requestId', '123'); - expect(addBidResponse.secondCall.args[1]).to.have.property('requestId', '101111'); - - expect(addBidResponse.firstCall.args[1]) - .to.have.property('statusMessage', 'Bid available'); - expect(addBidResponse.secondCall.args[1]) - .to.have.property('statusMessage', 'Bid returned empty or error response'); - }); - }); -}); diff --git a/test/spec/modules/sharethroughBidAdapter_spec.js b/test/spec/modules/sharethroughBidAdapter_spec.js index 8a8ccdbbeb34..a8caefc52408 100644 --- a/test/spec/modules/sharethroughBidAdapter_spec.js +++ b/test/spec/modules/sharethroughBidAdapter_spec.js @@ -40,7 +40,7 @@ const bidRequests = [ const prebidRequests = [ { method: 'GET', - url: document.location.protocol + '//btlr.sharethrough.com' + '/WYu2BXv1/v1', + url: 'https://btlr.sharethrough.com' + '/WYu2BXv1/v1', data: { bidId: 'bidId', placement_key: 'pKey' @@ -52,7 +52,7 @@ const prebidRequests = [ }, { method: 'GET', - url: document.location.protocol + '//btlr.sharethrough.com' + '/WYu2BXv1/v1', + url: 'https://btlr.sharethrough.com' + '/WYu2BXv1/v1', data: { bidId: 'bidId', placement_key: 'pKey' @@ -64,7 +64,7 @@ const prebidRequests = [ }, { method: 'GET', - url: document.location.protocol + '//btlr.sharethrough.com' + '/WYu2BXv1/v1', + url: 'https://btlr.sharethrough.com' + '/WYu2BXv1/v1', data: { bidId: 'bidId', placement_key: 'pKey' @@ -77,7 +77,7 @@ const prebidRequests = [ }, { method: 'GET', - url: document.location.protocol + '//btlr.sharethrough.com' + '/WYu2BXv1/v1', + url: 'https://btlr.sharethrough.com' + '/WYu2BXv1/v1', data: { bidId: 'bidId', placement_key: 'pKey' @@ -89,7 +89,7 @@ const prebidRequests = [ }, { method: 'GET', - url: document.location.protocol + '//btlr.sharethrough.com' + '/WYu2BXv1/v1', + url: 'https://btlr.sharethrough.com' + '/WYu2BXv1/v1', data: { bidId: 'bidId', placement_key: 'pKey' @@ -218,9 +218,9 @@ describe('sharethrough adapter spec', function () { const builtBidRequests = spec.buildRequests(bidRequests); expect(builtBidRequests[0].url).to.eq( - 'http://btlr.sharethrough.com/WYu2BXv1/v1'); + 'https://btlr.sharethrough.com/WYu2BXv1/v1'); expect(builtBidRequests[1].url).to.eq( - 'http://btlr.sharethrough.com/WYu2BXv1/v1'); + 'https://btlr.sharethrough.com/WYu2BXv1/v1'); expect(builtBidRequests[0].method).to.eq('GET'); }); diff --git a/test/spec/modules/showheroes-bsBidAdapter_spec.js b/test/spec/modules/showheroes-bsBidAdapter_spec.js index 124f98600d54..937df5a8c83e 100644 --- a/test/spec/modules/showheroes-bsBidAdapter_spec.js +++ b/test/spec/modules/showheroes-bsBidAdapter_spec.js @@ -5,7 +5,7 @@ import {VIDEO, BANNER} from 'src/mediaTypes' const bidderRequest = { refererInfo: { - referer: 'http://example.com' + referer: 'https://example.com' } } diff --git a/test/spec/modules/slimcutBidAdapter_spec.js b/test/spec/modules/slimcutBidAdapter_spec.js index 92649bf35561..ecbb926cdd14 100644 --- a/test/spec/modules/slimcutBidAdapter_spec.js +++ b/test/spec/modules/slimcutBidAdapter_spec.js @@ -2,8 +2,8 @@ import {expect} from 'chai'; import {spec} from 'modules/slimcutBidAdapter'; import {newBidder} from 'src/adapters/bidderFactory'; -const ENDPOINT = '//sb.freeskreen.com/pbr'; -const AD_SCRIPT = '"'; +const ENDPOINT = 'https://sb.freeskreen.com/pbr'; +const AD_SCRIPT = '"'; describe('slimcutBidAdapter', function() { const adapter = newBidder(spec); @@ -116,7 +116,7 @@ describe('slimcutBidAdapter', function() { const bidRequest = Object.assign({}, bidRequests[0]) const bidderRequest = { refererInfo: { - referer: 'http://example.com/page.html', + referer: 'https://example.com/page.html', reachedTop: true, numIframes: 2 } @@ -125,7 +125,7 @@ describe('slimcutBidAdapter', function() { const payload = JSON.parse(request.data); expect(payload.referrer).to.exist; - expect(payload.referrer).to.deep.equal('http://example.com/page.html') + expect(payload.referrer).to.deep.equal('https://example.com/page.html') }); }); @@ -151,7 +151,7 @@ describe('slimcutBidAdapter', function() { it('should get the correct number of sync urls', () => { let urls = spec.getUserSyncs({iframeEnabled: true}, bids); expect(urls.length).to.equal(1); - expect(urls[0].url).to.equal('//sb.freeskreen.com/async_usersync.html'); + expect(urls[0].url).to.equal('https://sb.freeskreen.com/async_usersync.html'); }); it('should return no url if not iframe enabled', () => { diff --git a/test/spec/modules/smartadserverBidAdapter_spec.js b/test/spec/modules/smartadserverBidAdapter_spec.js deleted file mode 100644 index 30afad308c71..000000000000 --- a/test/spec/modules/smartadserverBidAdapter_spec.js +++ /dev/null @@ -1,399 +0,0 @@ -import { - expect -} from 'chai'; -import { - spec -} from 'modules/smartadserverBidAdapter'; -import { - newBidder -} from 'src/adapters/bidderFactory'; -import { - config -} from 'src/config'; -import * as utils from 'src/utils'; -import { requestBidsHook } from 'modules/consentManagement'; - -// Default params with optional ones -describe('Smart bid adapter tests', function () { - var DEFAULT_PARAMS = [{ - adUnitCode: 'sas_42', - bidId: 'abcd1234', - sizes: [ - [300, 250], - [300, 200] - ], - bidder: 'smartadserver', - params: { - domain: 'http://prg.smartadserver.com', - siteId: '1234', - pageId: '5678', - formatId: '90', - target: 'test=prebid', - bidfloor: 0.420, - buId: '7569', - appName: 'Mozilla', - ckId: 42 - }, - requestId: 'efgh5678', - transactionId: 'zsfgzzg' - }]; - - // Default params without optional ones - var DEFAULT_PARAMS_WO_OPTIONAL = [{ - adUnitCode: 'sas_42', - bidId: 'abcd1234', - sizes: [ - [300, 250], - [300, 200] - ], - bidder: 'smartadserver', - params: { - domain: 'http://prg.smartadserver.com', - siteId: '1234', - pageId: '5678', - formatId: '90' - }, - requestId: 'efgh5678' - }]; - - var BID_RESPONSE = { - body: { - cpm: 12, - width: 300, - height: 250, - creativeId: 'zioeufg', - currency: 'GBP', - isNetCpm: true, - ttl: 300, - adUrl: 'http://awesome.fake.url', - ad: '< --- awesome script --- >', - cSyncUrl: 'http://awesome.fake.csync.url' - } - }; - - it('Verify build request', function () { - config.setConfig({ - 'currency': { - 'adServerCurrency': 'EUR' - } - }); - const request = spec.buildRequests(DEFAULT_PARAMS); - expect(request[0]).to.have.property('url').and.to.equal('http://prg.smartadserver.com/prebid/v1'); - expect(request[0]).to.have.property('method').and.to.equal('POST'); - const requestContent = JSON.parse(request[0].data); - expect(requestContent).to.have.property('siteid').and.to.equal('1234'); - expect(requestContent).to.have.property('pageid').and.to.equal('5678'); - expect(requestContent).to.have.property('formatid').and.to.equal('90'); - expect(requestContent).to.have.property('currencyCode').and.to.equal('EUR'); - expect(requestContent).to.have.property('bidfloor').and.to.equal(0.42); - expect(requestContent).to.have.property('targeting').and.to.equal('test=prebid'); - expect(requestContent).to.have.property('tagId').and.to.equal('sas_42'); - expect(requestContent).to.have.property('sizes'); - expect(requestContent.sizes[0]).to.have.property('w').and.to.equal(300); - expect(requestContent.sizes[0]).to.have.property('h').and.to.equal(250); - expect(requestContent.sizes[1]).to.have.property('w').and.to.equal(300); - expect(requestContent.sizes[1]).to.have.property('h').and.to.equal(200); - expect(requestContent).to.have.property('pageDomain').and.to.equal(utils.getTopWindowUrl()); - expect(requestContent).to.have.property('transactionId').and.to.not.equal(null).and.to.not.be.undefined; - expect(requestContent).to.have.property('buid').and.to.equal('7569'); - expect(requestContent).to.have.property('appname').and.to.equal('Mozilla'); - expect(requestContent).to.have.property('ckid').and.to.equal(42); - }); - - it('Verify parse response', function () { - const request = spec.buildRequests(DEFAULT_PARAMS); - const bids = spec.interpretResponse(BID_RESPONSE, request[0]); - expect(bids).to.have.lengthOf(1); - const bid = bids[0]; - expect(bid.cpm).to.equal(12); - expect(bid.adUrl).to.equal('http://awesome.fake.url'); - expect(bid.ad).to.equal('< --- awesome script --- >'); - expect(bid.width).to.equal(300); - expect(bid.height).to.equal(250); - expect(bid.creativeId).to.equal('zioeufg'); - expect(bid.currency).to.equal('GBP'); - expect(bid.netRevenue).to.equal(true); - expect(bid.ttl).to.equal(300); - expect(bid.requestId).to.equal(DEFAULT_PARAMS[0].bidId); - expect(bid.referrer).to.equal(utils.getTopWindowUrl()); - - expect(function () { - spec.interpretResponse(BID_RESPONSE, { - data: 'invalid Json' - }) - }).to.not.throw(); - }); - - it('Verifies bidder code', function () { - expect(spec.code).to.equal('smartadserver'); - }); - - it('Verifies bidder aliases', function () { - expect(spec.aliases).to.have.lengthOf(1); - expect(spec.aliases[0]).to.equal('smart'); - }); - - it('Verifies if bid request valid', function () { - expect(spec.isBidRequestValid(DEFAULT_PARAMS[0])).to.equal(true); - expect(spec.isBidRequestValid(DEFAULT_PARAMS_WO_OPTIONAL[0])).to.equal(true); - expect(spec.isBidRequestValid({})).to.equal(false); - expect(spec.isBidRequestValid({ - params: {} - })).to.equal(false); - expect(spec.isBidRequestValid({ - params: { - pageId: 123 - } - })).to.equal(false); - expect(spec.isBidRequestValid({ - params: { - siteId: 123 - } - })).to.equal(false); - expect(spec.isBidRequestValid({ - params: { - formatId: 123, - pageId: 234 - } - })).to.equal(false); - expect(spec.isBidRequestValid({ - params: { - domain: 'www.test.com', - pageId: 234 - } - })).to.equal(false); - expect(spec.isBidRequestValid({ - params: { - domain: 'www.test.com', - formatId: 123, - siteId: 456, - pageId: 234 - } - })).to.equal(true); - expect(spec.isBidRequestValid({ - params: { - domain: 'www.test.com', - formatId: 123, - siteId: 456, - pageId: 234, - buId: 789, - appName: 'Mozilla' - } - })).to.equal(true); - expect(spec.isBidRequestValid({ - params: { - domain: 'www.test.com', - formatId: 123, - pageId: 234, - buId: 789, - appName: 'Mozilla' - } - })).to.equal(false); - }); - - it('Verifies user sync', function () { - var syncs = spec.getUserSyncs({ - iframeEnabled: true - }, [BID_RESPONSE]); - expect(syncs).to.have.lengthOf(1); - expect(syncs[0].type).to.equal('iframe'); - expect(syncs[0].url).to.equal('http://awesome.fake.csync.url'); - - syncs = spec.getUserSyncs({ - iframeEnabled: false - }, [BID_RESPONSE]); - expect(syncs).to.have.lengthOf(0); - - syncs = spec.getUserSyncs({ - iframeEnabled: true - }, []); - expect(syncs).to.have.lengthOf(0); - }); - - describe('gdpr tests', function () { - afterEach(function () { - config.resetConfig(); - $$PREBID_GLOBAL$$.requestBids.removeAll(); - }); - - it('Verify build request with GDPR', function () { - config.setConfig({ - 'currency': { - 'adServerCurrency': 'EUR' - }, - consentManagement: { - cmp: 'iab', - consentRequired: true, - timeout: 1000, - allowAuctionWithoutConsent: true - } - }); - const request = spec.buildRequests(DEFAULT_PARAMS_WO_OPTIONAL, { - gdprConsent: { - consentString: 'BOKAVy4OKAVy4ABAB8AAAAAZ+A==', - gdprApplies: true - } - }); - const requestContent = JSON.parse(request[0].data); - expect(requestContent).to.have.property('gdpr').and.to.equal(true); - expect(requestContent).to.have.property('gdpr_consent').and.to.equal('BOKAVy4OKAVy4ABAB8AAAAAZ+A=='); - }); - - it('Verify build request with GDPR without gdprApplies', function () { - config.setConfig({ - 'currency': { - 'adServerCurrency': 'EUR' - }, - consentManagement: { - cmp: 'iab', - consentRequired: true, - timeout: 1000, - allowAuctionWithoutConsent: true - } - }); - const request = spec.buildRequests(DEFAULT_PARAMS_WO_OPTIONAL, { - gdprConsent: { - consentString: 'BOKAVy4OKAVy4ABAB8AAAAAZ+A==' - } - }); - const requestContent = JSON.parse(request[0].data); - expect(requestContent).to.not.have.property('gdpr'); - expect(requestContent).to.have.property('gdpr_consent').and.to.equal('BOKAVy4OKAVy4ABAB8AAAAAZ+A=='); - }); - }); - - describe('Instream video tests', function () { - afterEach(function () { - config.resetConfig(); - $$PREBID_GLOBAL$$.requestBids.removeAll(); - }); - - const INSTREAM_DEFAULT_PARAMS = [{ - adUnitCode: 'sas_42', - bidId: 'abcd1234', - bidder: 'smartadserver', - mediaTypes: { - video: { - context: 'instream', - playerSize: [[640, 480]] // It seems prebid.js transforms the player size array into an array of array... - } - }, - params: { - siteId: '1234', - pageId: '5678', - formatId: '90', - target: 'test=prebid', - bidfloor: 0.420, - buId: '7569', - appName: 'Mozilla', - ckId: 42, - video: { - protocol: 6 - } - }, - requestId: 'efgh5678', - transactionId: 'zsfgzzg' - }]; - - var INSTREAM_BID_RESPONSE = { - body: { - cpm: 12, - width: 640, - height: 480, - creativeId: 'zioeufg', - currency: 'GBP', - isNetCpm: true, - ttl: 300, - adUrl: 'http://awesome.fake-vast.url', - ad: '', - cSyncUrl: 'http://awesome.fake.csync.url' - } - }; - - it('Verify instream video build request', function () { - config.setConfig({ - 'currency': { - 'adServerCurrency': 'EUR' - } - }); - const request = spec.buildRequests(INSTREAM_DEFAULT_PARAMS); - expect(request[0]).to.have.property('url').and.to.equal('https://prg.smartadserver.com/prebid/v1'); - expect(request[0]).to.have.property('method').and.to.equal('POST'); - const requestContent = JSON.parse(request[0].data); - expect(requestContent).to.have.property('siteid').and.to.equal('1234'); - expect(requestContent).to.have.property('pageid').and.to.equal('5678'); - expect(requestContent).to.have.property('formatid').and.to.equal('90'); - expect(requestContent).to.have.property('currencyCode').and.to.equal('EUR'); - expect(requestContent).to.have.property('bidfloor').and.to.equal(0.42); - expect(requestContent).to.have.property('targeting').and.to.equal('test=prebid'); - expect(requestContent).to.have.property('tagId').and.to.equal('sas_42'); - expect(requestContent).to.have.property('pageDomain').and.to.equal(utils.getTopWindowUrl()); - expect(requestContent).to.have.property('transactionId').and.to.not.equal(null).and.to.not.be.undefined; - expect(requestContent).to.have.property('buid').and.to.equal('7569'); - expect(requestContent).to.have.property('appname').and.to.equal('Mozilla'); - expect(requestContent).to.have.property('ckid').and.to.equal(42); - expect(requestContent).to.have.property('isVideo').and.to.equal(true); - expect(requestContent).to.have.property('videoData'); - expect(requestContent.videoData).to.have.property('videoProtocol').and.to.equal(6); - expect(requestContent.videoData).to.have.property('playerWidth').and.to.equal(640); - expect(requestContent.videoData).to.have.property('playerHeight').and.to.equal(480); - }); - - it('Verify instream parse response', function () { - const request = spec.buildRequests(INSTREAM_DEFAULT_PARAMS); - const bids = spec.interpretResponse(INSTREAM_BID_RESPONSE, request[0]); - expect(bids).to.have.lengthOf(1); - const bid = bids[0]; - expect(bid.cpm).to.equal(12); - expect(bid.mediaType).to.equal('video'); - expect(bid.vastUrl).to.equal('http://awesome.fake-vast.url'); - expect(bid.vastXml).to.equal(''); - expect(bid.width).to.equal(640); - expect(bid.height).to.equal(480); - expect(bid.creativeId).to.equal('zioeufg'); - expect(bid.currency).to.equal('GBP'); - expect(bid.netRevenue).to.equal(true); - expect(bid.ttl).to.equal(300); - expect(bid.requestId).to.equal(INSTREAM_DEFAULT_PARAMS[0].bidId); - expect(bid.referrer).to.equal(utils.getTopWindowUrl()); - - expect(function () { - spec.interpretResponse(INSTREAM_BID_RESPONSE, { - data: 'invalid Json' - }) - }).to.not.throw(); - }); - - it('Verify not handled media type return empty request', function () { - config.setConfig({ - 'currency': { - 'adServerCurrency': 'EUR' - } - }); - const request = spec.buildRequests([{ - adUnitCode: 'sas_42', - bidder: 'smartadserver', - mediaTypes: { - video: { - context: 'badcontext' - } - }, - params: { - domain: 'http://prg.smartadserver.com', - siteId: '1234', - pageId: '5678', - formatId: '90', - target: 'test=prebid', - bidfloor: 0.420, - buId: '7569', - appName: 'Mozilla', - ckId: 42 - }, - requestId: 'efgh5678', - transactionId: 'zsfgzzg' - }, INSTREAM_DEFAULT_PARAMS[0]]); - expect(request[0]).to.be.empty; - expect(request[1]).to.not.be.empty; - }); - }); -}); diff --git a/test/spec/modules/smartrtbBidAdapter_spec.js b/test/spec/modules/smartrtbBidAdapter_spec.js index 7477dbf9418b..955dd3ba471e 100644 --- a/test/spec/modules/smartrtbBidAdapter_spec.js +++ b/test/spec/modules/smartrtbBidAdapter_spec.js @@ -13,8 +13,8 @@ const br = { crid: 'crid' }], pixels: [ - { type: 'image', url: 'http://smrtb.com/image' }, - { type: 'iframe', url: 'http://smrtb.com/iframe' } + { type: 'image', url: 'https://smrtb.com/image' }, + { type: 'iframe', url: 'https://smrtb.com/iframe' } ] } } @@ -30,8 +30,8 @@ const vr = { crid: 'video_crid' }], pixels: [ - { type: 'image', url: 'http://smrtb.com/image' }, - { type: 'iframe', url: 'http://smrtb.com/iframe' } + { type: 'image', url: 'https://smrtb.com/image' }, + { type: 'iframe', url: 'https://smrtb.com/iframe' } ] } } diff --git a/test/spec/modules/smartyadsBidAdapter_spec.js b/test/spec/modules/smartyadsBidAdapter_spec.js deleted file mode 100644 index e301e9733a61..000000000000 --- a/test/spec/modules/smartyadsBidAdapter_spec.js +++ /dev/null @@ -1,230 +0,0 @@ -import {expect} from 'chai'; -import {spec} from '../../../modules/smartyadsBidAdapter'; - -describe('SmartyadsAdapter', function () { - let bid = { - bidId: '23fhj33i987f', - bidder: 'smartyads', - params: { - placementId: 0, - traffic: 'banner' - } - }; - - describe('isBidRequestValid', function () { - it('Should return true if there are bidId, params and placementId parameters present', function () { - expect(spec.isBidRequestValid(bid)).to.be.true; - }); - it('Should return false if at least one of parameters is not present', function () { - delete bid.params.placementId; - expect(spec.isBidRequestValid(bid)).to.be.false; - }); - }); - - describe('buildRequests', function () { - let serverRequest = spec.buildRequests([bid]); - it('Creates a ServerRequest object with method, URL and data', function () { - expect(serverRequest).to.exist; - expect(serverRequest.method).to.exist; - expect(serverRequest.url).to.exist; - expect(serverRequest.data).to.exist; - }); - it('Returns POST method', function () { - expect(serverRequest.method).to.equal('POST'); - }); - it('Returns valid URL', function () { - expect(serverRequest.url).to.equal('//ssp-nj.webtradehub.com/?c=o&m=multi'); - }); - it('Returns valid data if array of bids is valid', function () { - let data = serverRequest.data; - expect(data).to.be.an('object'); - expect(data).to.have.all.keys('deviceWidth', 'deviceHeight', 'language', 'secure', 'host', 'page', 'placements'); - expect(data.deviceWidth).to.be.a('number'); - expect(data.deviceHeight).to.be.a('number'); - expect(data.language).to.be.a('string'); - expect(data.secure).to.be.within(0, 1); - expect(data.host).to.be.a('string'); - expect(data.page).to.be.a('string'); - let placement = data['placements'][0]; - expect(placement).to.have.keys('placementId', 'bidId', 'traffic'); - expect(placement.placementId).to.equal(0); - expect(placement.bidId).to.equal('23fhj33i987f'); - expect(placement.traffic).to.equal('banner'); - }); - it('Returns empty data if no valid requests are passed', function () { - serverRequest = spec.buildRequests([]); - let data = serverRequest.data; - expect(data.placements).to.be.an('array').that.is.empty; - }); - }); - describe('interpretResponse', function () { - it('Should interpret banner response', function () { - const banner = { - body: [{ - mediaType: 'banner', - width: 300, - height: 250, - cpm: 0.4, - ad: 'Test', - requestId: '23fhj33i987f', - ttl: 120, - creativeId: '2', - netRevenue: true, - currency: 'USD', - dealId: '1' - }] - }; - let bannerResponses = spec.interpretResponse(banner); - expect(bannerResponses).to.be.an('array').that.is.not.empty; - let dataItem = bannerResponses[0]; - expect(dataItem).to.have.all.keys('requestId', 'cpm', 'width', 'height', 'ad', 'ttl', 'creativeId', - 'netRevenue', 'currency', 'dealId'); - expect(dataItem.requestId).to.equal('23fhj33i987f'); - expect(dataItem.cpm).to.equal(0.4); - expect(dataItem.width).to.equal(300); - expect(dataItem.height).to.equal(250); - expect(dataItem.ad).to.equal('Test'); - expect(dataItem.ttl).to.equal(120); - expect(dataItem.creativeId).to.equal('2'); - expect(dataItem.netRevenue).to.be.true; - expect(dataItem.currency).to.equal('USD'); - }); - it('Should interpret video response', function () { - const video = { - body: [{ - vastUrl: 'test.com', - mediaType: 'video', - cpm: 0.5, - requestId: '23fhj33i987f', - ttl: 120, - creativeId: '2', - netRevenue: true, - currency: 'USD', - dealId: '1' - }] - }; - let videoResponses = spec.interpretResponse(video); - expect(videoResponses).to.be.an('array').that.is.not.empty; - - let dataItem = videoResponses[0]; - expect(dataItem).to.have.all.keys('requestId', 'cpm', 'vastUrl', 'ttl', 'creativeId', - 'netRevenue', 'currency', 'dealId'); - expect(dataItem.mediaType).to.not.exist; - expect(dataItem.requestId).to.equal('23fhj33i987f'); - expect(dataItem.cpm).to.equal(0.5); - expect(dataItem.vastUrl).to.equal('test.com'); - expect(dataItem.ttl).to.equal(120); - expect(dataItem.creativeId).to.equal('2'); - expect(dataItem.netRevenue).to.be.true; - expect(dataItem.currency).to.equal('USD'); - }); - it('Should interpret native response', function () { - const native = { - body: [{ - mediaType: 'native', - clickUrl: 'test.com', - title: 'Test', - image: 'test.com', - impressionTrackers: ['test.com'], - ttl: 120, - cpm: 0.4, - requestId: '23fhj33i987f', - creativeId: '2', - netRevenue: true, - currency: 'USD', - }] - }; - let nativeResponses = spec.interpretResponse(native); - expect(nativeResponses).to.be.an('array').that.is.not.empty; - - let dataItem = nativeResponses[0]; - expect(dataItem).to.have.keys('requestId', 'cpm', 'clickUrl', 'impressionTrackers', 'title', 'image', 'ttl', 'creativeId', 'netRevenue', 'currency'); - expect(dataItem.mediaType).to.not.exist; - expect(dataItem.requestId).to.equal('23fhj33i987f'); - expect(dataItem.cpm).to.equal(0.4); - expect(dataItem.clickUrl).to.equal('test.com'); - expect(dataItem.title).to.equal('Test'); - expect(dataItem.image).to.equal('test.com'); - expect(dataItem.impressionTrackers).to.be.an('array').that.is.not.empty; - expect(dataItem.impressionTrackers[0]).to.equal('test.com'); - expect(dataItem.ttl).to.equal(120); - expect(dataItem.creativeId).to.equal('2'); - expect(dataItem.netRevenue).to.be.true; - expect(dataItem.currency).to.equal('USD'); - }); - it('Should return an empty array if invalid banner response is passed', function () { - const invBanner = { - body: [{ - width: 300, - cpm: 0.4, - ad: 'Test', - requestId: '23fhj33i987f', - ttl: 120, - creativeId: '2', - netRevenue: true, - currency: 'USD', - dealId: '1' - }] - }; - - let serverResponses = spec.interpretResponse(invBanner); - expect(serverResponses).to.be.an('array').that.is.empty; - }); - it('Should return an empty array if invalid video response is passed', function () { - const invVideo = { - body: [{ - mediaType: 'video', - cpm: 0.5, - requestId: '23fhj33i987f', - ttl: 120, - creativeId: '2', - netRevenue: true, - currency: 'USD', - dealId: '1' - }] - }; - let serverResponses = spec.interpretResponse(invVideo); - expect(serverResponses).to.be.an('array').that.is.empty; - }); - it('Should return an empty array if invalid native response is passed', function () { - const invNative = { - body: [{ - mediaType: 'native', - clickUrl: 'test.com', - title: 'Test', - impressionTrackers: ['test.com'], - ttl: 120, - requestId: '23fhj33i987f', - creativeId: '2', - netRevenue: true, - currency: 'USD', - }] - }; - let serverResponses = spec.interpretResponse(invNative); - expect(serverResponses).to.be.an('array').that.is.empty; - }); - it('Should return an empty array if invalid response is passed', function () { - const invalid = { - body: [{ - ttl: 120, - creativeId: '2', - netRevenue: true, - currency: 'USD', - dealId: '1' - }] - }; - let serverResponses = spec.interpretResponse(invalid); - expect(serverResponses).to.be.an('array').that.is.empty; - }); - }); - describe('getUserSyncs', function () { - let userSync = spec.getUserSyncs(); - it('Returns valid URL and type', function () { - expect(userSync).to.be.an('array').with.lengthOf(1); - expect(userSync[0].type).to.exist; - expect(userSync[0].url).to.exist; - expect(userSync[0].type).to.be.equal('image'); - expect(userSync[0].url).to.be.equal('//ssp-nj.webtradehub.com/?c=o&m=cookie'); - }); - }); -}); diff --git a/test/spec/modules/smilewantedBidAdapter_spec.js b/test/spec/modules/smilewantedBidAdapter_spec.js index 144c7ca60f6d..78a793137b6d 100644 --- a/test/spec/modules/smilewantedBidAdapter_spec.js +++ b/test/spec/modules/smilewantedBidAdapter_spec.js @@ -151,11 +151,11 @@ describe('smilewantedBidAdapterTests', function () { it('SmileWanted - Verify build request with referrer', function () { const request = spec.buildRequests(DISPLAY_REQUEST, { refererInfo: { - referer: 'http://localhost/Prebid.js/integrationExamples/gpt/hello_world.html' + referer: 'https://localhost/Prebid.js/integrationExamples/gpt/hello_world.html' } }); const requestContent = JSON.parse(request[0].data); - expect(requestContent).to.have.property('pageDomain').and.to.equal('http://localhost/Prebid.js/integrationExamples/gpt/hello_world.html'); + expect(requestContent).to.have.property('pageDomain').and.to.equal('https://localhost/Prebid.js/integrationExamples/gpt/hello_world.html'); }); describe('gdpr tests', function () { diff --git a/test/spec/modules/somoBidAdapter_spec.js b/test/spec/modules/somoBidAdapter_spec.js deleted file mode 100644 index 16fd43841b7d..000000000000 --- a/test/spec/modules/somoBidAdapter_spec.js +++ /dev/null @@ -1,481 +0,0 @@ -import {expect} from 'chai'; -import {spec} from 'modules/somoBidAdapter'; -import * as utils from 'src/utils'; - -describe('Somo Audience Adapter Tests', function () { - describe('isBidRequestValid', function () { - it('should return false when given an invalid bid', function () { - const bid = { - bidder: 'somo', - }; - const isValid = spec.isBidRequestValid(bid); - expect(isValid).to.equal(false); - }); - it('should return true when given a placementId bid', function () { - const bid = { - bidder: 'somo', - params: { - placementId: 'test' - } - }; - const isValid = spec.isBidRequestValid(bid); - expect(isValid).to.equal(true); - }); - }); - - describe('buildRequests', function () { - describe('buildBannerRequests', function () { - it('should properly build a banner request with type not defined and sizes not defined', function () { - const bidRequests = [{ - bidder: 'somo', - params: { - placementId: 'test' - } - }]; - const request = spec.buildRequests(bidRequests); - expect(request[0].url).to.equal('//publisher-east.mobileadtrading.com/rtb/bid?s=test'); - expect(request[0].method).to.equal('POST'); - const ortbRequest = request[0].data; - expect(ortbRequest.site).to.not.equal(null); - expect(ortbRequest.site.ref).to.equal(utils.getTopWindowReferrer()); - expect(ortbRequest.site.page).to.equal(utils.getTopWindowLocation().href); - expect(ortbRequest.site.domain).to.not.be.undefined; - expect(ortbRequest.imp).to.have.lengthOf(1); - expect(ortbRequest.device).to.not.equal(null); - expect(ortbRequest.device.ua).to.equal(navigator.userAgent); - expect(ortbRequest.imp[0].bidfloor).to.not.be.null; - expect(ortbRequest.imp[0].banner).to.not.equal(null); - }); - - it('should properly build a banner request with sizes defined in 2d array', function () { - const bidRequests = [{ - bidder: 'somo', - sizes: [[300, 250]], - params: { - placementId: 'test' - } - }]; - const request = spec.buildRequests(bidRequests); - expect(request[0].url).to.equal('//publisher-east.mobileadtrading.com/rtb/bid?s=test'); - expect(request[0].method).to.equal('POST'); - const ortbRequest = request[0].data; - expect(ortbRequest.site).to.not.equal(null); - expect(ortbRequest.site.ref).to.equal(utils.getTopWindowReferrer()); - expect(ortbRequest.site.page).to.equal(utils.getTopWindowLocation().href); - expect(ortbRequest.site.domain).to.not.be.undefined; - expect(ortbRequest.imp).to.have.lengthOf(1); - expect(ortbRequest.imp[0].bidfloor).to.not.be.null; - expect(ortbRequest.imp[0].banner).to.not.equal(null); - expect(ortbRequest.imp[0].banner.w).to.equal(300); - expect(ortbRequest.imp[0].banner.h).to.equal(250); - }); - it('should properly build a banner request with sizes defined in 1d array', function () { - const bidRequests = [{ - bidder: 'somo', - sizes: [300, 250], - params: { - placementId: 'test' - } - }]; - const request = spec.buildRequests(bidRequests); - expect(request[0].url).to.equal('//publisher-east.mobileadtrading.com/rtb/bid?s=test'); - expect(request[0].method).to.equal('POST'); - const ortbRequest = request[0].data; - expect(ortbRequest.site).to.not.equal(null); - expect(ortbRequest.site.ref).to.equal(utils.getTopWindowReferrer()); - expect(ortbRequest.site.page).to.equal(utils.getTopWindowLocation().href); - expect(ortbRequest.site.domain).to.not.be.undefined; - expect(ortbRequest.imp).to.have.lengthOf(1); - expect(ortbRequest.imp[0].bidfloor).to.not.be.null; - expect(ortbRequest.imp[0].banner).to.not.equal(null); - expect(ortbRequest.imp[0].banner.w).to.equal(300); - expect(ortbRequest.imp[0].banner.h).to.equal(250); - expect(ortbRequest.imp[0].banner.mimes).to.equal(undefined); - expect(ortbRequest.imp[0].banner.btype).to.equal(undefined); - expect(ortbRequest.imp[0].banner.pos).to.equal(undefined); - expect(ortbRequest.imp[0].banner.battr).to.equal(undefined); - }); - - it('should populate optional banner parameters', function () { - const bidRequests = [ - { - bidder: 'somo', - sizes: [[300, 200]], - mediaType: 'banner', - params: { - placementId: 'test', - banner: { - mimes: 'video/mp4', - btype: '4', - pos: '1', - battr: 'ibv', - } - } - } - ]; - const request = spec.buildRequests(bidRequests); - const ortbRequest = request[0].data; - expect(ortbRequest.imp[0].banner).to.not.equal(null); - expect(ortbRequest.imp[0].banner.w).to.equal(300); - expect(ortbRequest.imp[0].banner.h).to.equal(200); - expect(ortbRequest.imp[0].banner.mimes).to.equal('video/mp4'); - expect(ortbRequest.imp[0].banner.btype).to.equal('4'); - expect(ortbRequest.imp[0].banner.pos).to.equal('1'); - expect(ortbRequest.imp[0].banner.battr).to.equal('ibv'); - }); - }); - - describe('buildVideoRequests', function () { - it('should properly build a video request with sizes defined', function () { - const bidRequests = [{ - bidder: 'somo', - mediaTypes: { - video: {} - }, - sizes: [200, 300], - params: { - placementId: 'test' - } - }]; - const request = spec.buildRequests(bidRequests); - const ortbRequest = request[0].data; - expect(ortbRequest.site).to.not.equal(null); - expect(ortbRequest.site.ref).to.equal(utils.getTopWindowReferrer()); - expect(ortbRequest.site.page).to.equal(utils.getTopWindowLocation().href); - expect(ortbRequest.site.domain).to.not.be.undefined; - expect(ortbRequest.imp).to.have.lengthOf(1); - expect(ortbRequest.imp[0].video).to.not.equal(null); - expect(ortbRequest.imp[0].video.w).to.equal(200); - expect(ortbRequest.imp[0].video.h).to.equal(300); - }); - - it('should properly build a video request with sizes defined in 2d array', function () { - const bidRequests = [{ - bidder: 'somo', - mediaTypes: { - video: {} - }, - sizes: [[200, 300]], - params: { - placementId: 'test' - } - }]; - const request = spec.buildRequests(bidRequests); - const ortbRequest = request[0].data; - expect(ortbRequest.site).to.not.equal(null); - expect(ortbRequest.site.ref).to.equal(utils.getTopWindowReferrer()); - expect(ortbRequest.site.page).to.equal(utils.getTopWindowLocation().href); - expect(ortbRequest.site.domain).to.not.be.undefined; - expect(ortbRequest.imp).to.have.lengthOf(1); - expect(ortbRequest.imp[0].video).to.not.equal(null); - expect(ortbRequest.imp[0].video.w).to.equal(200); - expect(ortbRequest.imp[0].video.h).to.equal(300); - }); - it('should properly build a video request with sizes not defined', function () { - const bidRequests = [{ - bidder: 'somo', - mediaType: 'video', - params: { - placementId: 'test' - } - }]; - const request = spec.buildRequests(bidRequests); - const ortbRequest = request[0].data; - expect(ortbRequest.imp).to.have.lengthOf(1); - expect(ortbRequest.imp[0].video).to.not.equal(null); - expect(ortbRequest.imp[0].video.mimes).to.equal(undefined); - expect(ortbRequest.imp[0].video.minduration).to.equal(undefined); - expect(ortbRequest.imp[0].video.maxduration).to.equal(undefined); - expect(ortbRequest.imp[0].video.protocols).to.equal(undefined); - expect(ortbRequest.imp[0].video.startdelay).to.equal(undefined); - expect(ortbRequest.imp[0].video.linearity).to.equal(undefined); - expect(ortbRequest.imp[0].video.skip).to.equal(undefined); - expect(ortbRequest.imp[0].video.delivery).to.equal(undefined); - expect(ortbRequest.imp[0].video.pos).to.equal(undefined); - expect(ortbRequest.imp[0].video.api).to.equal(undefined); - expect(ortbRequest.imp[0].video.battr).to.equal(undefined); - }); - - it('should populate optional video parameters', function () { - const bidRequests = [ - { - bidder: 'somo', - sizes: [[200, 300]], - mediaType: 'video', - params: { - placementId: 'test', - video: { - mimes: 'video/mp4', - minduration: '15', - maxduration: '30', - protocols: 'mp4', - startdelay: '0', - linearity: 'linear', - skip: '1', - delivery: 'web', - pos: '1', - api: 'VPAID 1.0', - battr: 'ibv', - } - } - } - ]; - const request = spec.buildRequests(bidRequests); - const ortbRequest = request[0].data; - expect(ortbRequest.imp[0].video).to.not.equal(null); - expect(ortbRequest.imp[0].video.w).to.equal(200); - expect(ortbRequest.imp[0].video.h).to.equal(300); - expect(ortbRequest.imp[0].video.mimes).to.equal('video/mp4'); - expect(ortbRequest.imp[0].video.minduration).to.equal('15'); - expect(ortbRequest.imp[0].video.maxduration).to.equal('30'); - expect(ortbRequest.imp[0].video.protocols).to.equal('mp4'); - expect(ortbRequest.imp[0].video.startdelay).to.equal('0'); - expect(ortbRequest.imp[0].video.linearity).to.equal('linear'); - expect(ortbRequest.imp[0].video.skip).to.equal('1'); - expect(ortbRequest.imp[0].video.delivery).to.equal('web'); - expect(ortbRequest.imp[0].video.pos).to.equal('1'); - expect(ortbRequest.imp[0].video.api).to.equal('VPAID 1.0'); - expect(ortbRequest.imp[0].video.battr).to.equal('ibv'); - }); - }); - - describe('buildSiteRequests', function () { - it('should fill in basic site parameters', function () { - const bidRequests = [{ - bidder: 'somo', - params: { - placementId: 'test' - } - }]; - const request = spec.buildRequests(bidRequests); - const ortbRequest = request[0].data; - expect(ortbRequest.app).to.equal(null); - expect(ortbRequest.site).to.not.equal(null); - expect(ortbRequest.site.ref).to.equal(utils.getTopWindowReferrer()); - expect(ortbRequest.site.page).to.equal(utils.getTopWindowLocation().href); - expect(ortbRequest.site.domain).to.not.be.undefined; - }); - - it('should fill in optional site parameters', function () { - const bidRequests = [{ - bidder: 'somo', - params: { - placementId: 'test', - site: { - domain: 'somoaudience.com', - name: 'Somo Audience', - cat: 'IAB-25', - keywords: 'unit testing', - content: 'Unit Testing' - } - } - }]; - const request = spec.buildRequests(bidRequests); - const ortbRequest = request[0].data; - expect(ortbRequest.app).to.equal(null); - expect(ortbRequest.site).to.not.equal(null); - expect(ortbRequest.site.name).to.equal('Somo Audience'); - expect(ortbRequest.site.domain).to.equal('somoaudience.com'); - expect(ortbRequest.site.cat).to.equal('IAB-25'); - expect(ortbRequest.site.keywords).to.equal('unit testing'); - expect(ortbRequest.site.content).to.equal('Unit Testing'); - }) - }); - - describe('buildAppRequests', function () { - it('should fill in app parameters', function () { - const bidRequests = [{ - bidder: 'somo', - params: { - placementId: 'test', - app: { - bundle: 'com.somoaudience.apps', - storeUrl: 'http://somoaudience.com/apps', - domain: 'somoaudience.com', - name: 'Generic SomoAudience App 5', - cat: 'IAB-25', - keywords: 'unit testing', - content: 'Unit Testing', - ver: '5.423-s', - } - } - }]; - const request = spec.buildRequests(bidRequests); - const ortbRequest = request[0].data; - expect(ortbRequest.site).to.equal(null); - expect(ortbRequest.app).to.not.be.null; - expect(ortbRequest.app.bundle).to.equal('com.somoaudience.apps'); - expect(ortbRequest.app.storeUrl).to.equal('http://somoaudience.com/apps'); - expect(ortbRequest.app.domain).to.equal('somoaudience.com'); - expect(ortbRequest.app.name).to.equal('Generic SomoAudience App 5'); - expect(ortbRequest.app.ver).to.equal('5.423-s'); - expect(ortbRequest.app.cat).to.equal('IAB-25'); - expect(ortbRequest.app.keywords).to.equal('unit testing'); - expect(ortbRequest.app.content).to.equal('Unit Testing'); - }); - }); - - describe('buildGDPRRequests', function () { - const bidderRequest = { - gdprConsent: { - gdprApplies: true, - consentString: 'test' - }, - }; - - it('should properly build request with gdpr consent', function () { - const bidRequests = [{ - bidder: 'somo', - params: { - placementId: 'test' - } - }]; - const request = spec.buildRequests(bidRequests, bidderRequest); - const ortbRequest = request[0].data; - expect(ortbRequest.reqs).to.not.equal(undefined); - expect(ortbRequest.reqs.ext).to.not.equal(undefined); - expect(ortbRequest.reqs.ext.gdpr).to.equal(true); - expect(ortbRequest.user).to.not.equal(undefined); - expect(ortbRequest.user.ext).to.not.equal(undefined); - expect(ortbRequest.user.ext.consent).to.equal('test'); - }); - it('should properly build request with gdpr not applies', function () { - bidderRequest.gdprConsent.gdprApplies = false; - const bidRequests = [{ - bidder: 'somo', - params: { - placementId: 'test' - } - }]; - const request = spec.buildRequests(bidRequests, bidderRequest); - const ortbRequest = request[0].data; - expect(ortbRequest.reqs).to.not.equal(undefined); - expect(ortbRequest.reqs.ext).to.not.equal(undefined); - expect(ortbRequest.reqs.ext.gdpr).to.equal(false); - expect(ortbRequest.user).to.not.equal(undefined); - expect(ortbRequest.user.ext).to.not.equal(undefined); - expect(ortbRequest.user.ext.consent).to.equal('test'); - }); - }); - - describe('buildExtraArgsRequests', function () { - it('should populate optional parameters', function () { - const bidRequests = [ - { - bidder: 'somo', - params: { - placementId: 'test', - bcat: ['IAB-2', 'IAB-7'], - badv: ['somoaudience.com', 'mobileadtrading.com'], - bidfloor: '0.05', - }, - } - ]; - const request = spec.buildRequests(bidRequests); - const ortbRequest = request[0].data; - expect(ortbRequest.imp[0].bidfloor).to.not.be.null; - expect(ortbRequest.imp[0].bidfloor).to.be.equal('0.05'); - expect(ortbRequest.bcat).to.not.be.null; - expect(ortbRequest.bcat).to.have.lengthOf(2); - expect(ortbRequest.bcat).to.contain('IAB-2'); - expect(ortbRequest.badv).to.not.be.null; - expect(ortbRequest.badv).to.have.lengthOf(2); - expect(ortbRequest.badv).to.contain('somoaudience.com'); - }); - }); - }); - - describe('interpretResponse', function () { - it('Verify banner parse response', function () { - const bidRequests = [ - { - bidder: 'somo', - params: { - placementId: 'test', - }, - bidId: '234234234', - } - ]; - const request = spec.buildRequests(bidRequests); - const ortbRequest = request[0].data; - const ortbResponse = { - seatbid: [{ - bid: [{ - impid: ortbRequest.imp[0].id, - price: 1.25, - adm: 'Somo Test Ad' - }], - bidId: '234234234' - }] - }; - const bids = spec.interpretResponse({ body: ortbResponse }, {bidRequest: bidRequests[0]}); - const bid = bids[0]; - expect(bid.cpm).to.equal(1.25); - expect(bid.ad).to.equal('Somo Test Ad'); - }); - - it('Verify video parse response', function () { - const bidRequests = [ - { - bidder: 'somo', - mediaTypes: { - video: { - } - }, - params: { - placementId: 'test', - }, - bidId: '234234234', - } - ]; - const request = spec.buildRequests(bidRequests); - const ortbRequest = request[0].data; - const ortbResponse = { - seatbid: [{ - bid: [{ - impid: ortbRequest.imp[0].id, - price: 1.25, - adm: 'Somo Test Ad' - }], - bidId: '234234234' - }] - }; - const bids = spec.interpretResponse({ body: ortbResponse }, {bidRequest: bidRequests[0]}); - const bid = bids[0]; - expect(bid.cpm).to.equal(1.25); - expect(bid.vastXml).to.equal('Somo Test Ad'); - }); - }); - - describe('user sync', function () { - it('should register the pixel sync url', function () { - let syncs = spec.getUserSyncs({ - pixelEnabled: true - }); - expect(syncs).to.not.be.an('undefined'); - expect(syncs).to.have.lengthOf(1); - expect(syncs[0].type).to.equal('image'); - }); - - it('should pass gdpr params', function () { - let syncs = spec.getUserSyncs({ pixelEnabled: true }, {}, { - gdprApplies: false, consentString: 'test' - }); - expect(syncs).to.not.be.an('undefined'); - expect(syncs).to.have.lengthOf(1); - expect(syncs[0].type).to.equal('image'); - expect(syncs[0].url).to.contains('gdpr=0'); - }); - - it('should pass gdpr applies params', function () { - let syncs = spec.getUserSyncs({ pixelEnabled: true }, {}, { - gdprApplies: true, consentString: 'test' - }); - expect(syncs).to.not.be.an('undefined'); - expect(syncs).to.have.lengthOf(1); - expect(syncs[0].type).to.equal('image'); - expect(syncs[0].url).to.contains('gdpr=1'); - expect(syncs[0].url).to.contains('gdpr_consent=test'); - }); - }); -}); diff --git a/test/spec/modules/sonobiBidAdapter_spec.js b/test/spec/modules/sonobiBidAdapter_spec.js index a6bf88cfc74b..aac7d8396afb 100644 --- a/test/spec/modules/sonobiBidAdapter_spec.js +++ b/test/spec/modules/sonobiBidAdapter_spec.js @@ -297,8 +297,8 @@ describe('SonobiBidAdapter', function () { 'refererInfo': { 'numIframes': 0, 'reachedTop': true, - 'referer': 'http://example.com', - 'stack': ['http://example.com'] + 'referer': 'https://example.com', + 'stack': ['https://example.com'] } }; it('should include the digitrust id and keyv', () => { @@ -369,7 +369,7 @@ describe('SonobiBidAdapter', function () { it('should return a properly formatted request with referer', function () { bidRequest[0].params.referrer = '' const bidRequests = spec.buildRequests(bidRequest, bidderRequests) - expect(bidRequests.data.ref).to.equal('http://example.com') + expect(bidRequests.data.ref).to.equal('https://example.com') }) it('should return a properly formatted request with GDPR applies set to false', function () { @@ -390,8 +390,8 @@ describe('SonobiBidAdapter', function () { 'refererInfo': { 'numIframes': 0, 'reachedTop': true, - 'referer': 'http://example.com', - 'stack': ['http://example.com'] + 'referer': 'https://example.com', + 'stack': ['https://example.com'] } }; const bidRequests = spec.buildRequests(bidRequest, bidderRequests) @@ -410,8 +410,8 @@ describe('SonobiBidAdapter', function () { 'refererInfo': { 'numIframes': 0, 'reachedTop': true, - 'referer': 'http://example.com', - 'stack': ['http://example.com'] + 'referer': 'https://example.com', + 'stack': ['https://example.com'] } }; const bidRequests = spec.buildRequests(bidRequest, bidderRequests) @@ -547,7 +547,7 @@ describe('SonobiBidAdapter', function () { 'url': 'https://apex.go.sonobi.com/trinity.json', 'withCredentials': true, 'data': { - 'key_maker': '{"30b31c1838de1f":"1a2b3c4d5e6f1a2b3c4d|300x250,300x600|f=1.25","/7780971/sparks_prebid_LB|30b31c1838de1e":"300x250,300x600"}', 'ref': 'http://localhost/', 's': '2474372d-c0ff-4f46-aef4-a173058403d9', 'pv': 'c9cfc207-cd83-4a01-b591-8bb29389d4b0' + 'key_maker': '{"30b31c1838de1f":"1a2b3c4d5e6f1a2b3c4d|300x250,300x600|f=1.25","/7780971/sparks_prebid_LB|30b31c1838de1e":"300x250,300x600"}', 'ref': 'https://localhost/', 's': '2474372d-c0ff-4f46-aef4-a173058403d9', 'pv': 'c9cfc207-cd83-4a01-b591-8bb29389d4b0' }, 'bidderRequests': [ { @@ -653,7 +653,7 @@ describe('SonobiBidAdapter', function () { 'cpm': 1.07, 'width': 300, 'height': 600, - 'ad': ``, + 'ad': ``, 'ttl': 500, 'creativeId': '1234abcd', 'netRevenue': true, @@ -665,7 +665,7 @@ describe('SonobiBidAdapter', function () { 'cpm': 1.25, 'width': 300, 'height': 250, - 'vastUrl': 'https://mco-1-apex.go.sonobi.com/vast.xml?vid=30292e432662bd5f86d90774b944b038&ref=http%3A%2F%2Flocalhost%2F', + 'vastUrl': 'https://mco-1-apex.go.sonobi.com/vast.xml?vid=30292e432662bd5f86d90774b944b038&ref=https%3A%2F%2Flocalhost%2F', 'ttl': 500, 'creativeId': '30292e432662bd5f86d90774b944b038', 'netRevenue': true, @@ -679,7 +679,7 @@ describe('SonobiBidAdapter', function () { 'cpm': 1.07, 'width': 300, 'height': 600, - 'ad': ``, + 'ad': ``, 'ttl': 500, 'creativeId': '1234abcd', 'netRevenue': true, @@ -691,7 +691,7 @@ describe('SonobiBidAdapter', function () { 'cpm': 1.25, 'width': 640, 'height': 480, - 'vastUrl': 'https://mco-1-apex.go.sonobi.com/vast.xml?vid=30292e432662bd5f86d90774b944b038&ref=http%3A%2F%2Flocalhost%2F', + 'vastUrl': 'https://mco-1-apex.go.sonobi.com/vast.xml?vid=30292e432662bd5f86d90774b944b038&ref=https%3A%2F%2Flocalhost%2F', 'ttl': 500, 'creativeId': 'somecrid', 'netRevenue': true, diff --git a/test/spec/modules/sortableBidAdapter_spec.js b/test/spec/modules/sortableBidAdapter_spec.js deleted file mode 100644 index 98695f44ee09..000000000000 --- a/test/spec/modules/sortableBidAdapter_spec.js +++ /dev/null @@ -1,258 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/sortableBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; -import * as utils from 'src/utils'; - -const ENDPOINT = `//c.deployads.com/openrtb2/auction?src=$$REPO_AND_VERSION$$&host=${utils.getTopWindowLocation().host}`; - -describe('sortableBidAdapter', function() { - const adapter = newBidder(spec); - - describe('isBidRequestValid', function () { - function makeBid() { - return { - 'bidder': 'sortable', - 'params': { - 'tagId': '403370', - 'siteId': 'example.com', - 'keywords': { - 'key1': 'val1', - 'key2': 'val2' - }, - 'floorSizeMap': { - '728x90': 0.15, - '300x250': 1.20 - } - }, - 'adUnitCode': 'adunit-code', - 'sizes': [ - [300, 250] - ], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - }; - } - - it('should return true when required params found', function () { - expect(spec.isBidRequestValid(makeBid())).to.equal(true); - }); - - it('should return false when tagId not passed correctly', function () { - let bid = makeBid(); - delete bid.params.tagId; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - - it('should return false when sizes not passed correctly', function () { - let bid = makeBid(); - delete bid.sizes; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - - it('should return false when sizes are wrong length', function () { - let bid = makeBid(); - bid.sizes = [[300]]; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - - it('should return false when require params are not passed', function () { - let bid = makeBid(); - bid.params = {}; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - - it('should return false when the floorSizeMap is invalid', function () { - let bid = makeBid(); - bid.params.floorSizeMap = { - 'sixforty by foureighty': 1234 - }; - expect(spec.isBidRequestValid(bid)).to.equal(false); - bid.params.floorSizeMap = { - '728x90': 'three' - } - expect(spec.isBidRequestValid(bid)).to.equal(false); - bid.params.floorSizeMap = 'a'; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - - it('should return true when the floorSizeMap is missing or empty', function () { - let bid = makeBid(); - bid.params.floorSizeMap = {}; - expect(spec.isBidRequestValid(bid)).to.equal(true); - delete bid.params.floorSizeMap; - expect(spec.isBidRequestValid(bid)).to.equal(true); - }); - it('should return false when the keywords are invalid', function () { - let bid = makeBid(); - bid.params.keywords = { - 'badval': 1234 - }; - expect(spec.isBidRequestValid(bid)).to.equal(false); - bid.params.keywords = 'a'; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - - it('should return true when the keywords are missing or empty', function () { - let bid = makeBid(); - bid.params.keywords = {}; - expect(spec.isBidRequestValid(bid)).to.equal(true); - delete bid.params.keywords; - expect(spec.isBidRequestValid(bid)).to.equal(true); - }); - }); - - describe('buildRequests', function () { - const bidRequests = [{ - 'bidder': 'sortable', - 'params': { - 'tagId': '403370', - 'siteId': 'example.com', - 'floor': 0.21, - 'keywords': { - 'key1': 'val1', - 'key2': 'val2' - }, - 'floorSizeMap': { - '728x90': 0.15, - '300x250': 1.20 - } - }, - 'sizes': [ - [300, 250] - ], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475' - }]; - - const request = spec.buildRequests(bidRequests); - const requestBody = JSON.parse(request.data); - - it('sends bid request to our endpoint via POST', function () { - expect(request.method).to.equal('POST'); - }); - - it('attaches source and version to endpoint URL as query params', function () { - expect(request.url).to.equal(ENDPOINT); - }); - - it('sends screen dimensions', function () { - expect(requestBody.site.device.w).to.equal(screen.width); - expect(requestBody.site.device.h).to.equal(screen.height); - }); - - it('includes the ad size in the bid request', function () { - expect(requestBody.imp[0].banner.format[0].w).to.equal(300); - expect(requestBody.imp[0].banner.format[0].h).to.equal(250); - }); - - it('includes the params in the bid request', function () { - expect(requestBody.imp[0].ext.keywords).to.deep.equal( - {'key1': 'val1', - 'key2': 'val2'} - ); - expect(requestBody.site.publisher.id).to.equal('example.com'); - expect(requestBody.imp[0].tagid).to.equal('403370'); - expect(requestBody.imp[0].bidfloor).to.equal(0.21); - }); - - it('should have the floor size map set', function () { - expect(requestBody.imp[0].ext.floorSizeMap).to.deep.equal({ - '728x90': 0.15, - '300x250': 1.20 - }); - }); - }); - - describe('interpretResponse', function () { - function makeResponse() { - return { - body: { - 'id': '5e5c23a5ba71e78', - 'seatbid': [ - { - 'bid': [ - { - 'id': '6vmb3isptf', - 'crid': 'sortablescreative', - 'impid': '322add653672f68', - 'price': 1.22, - 'adm': '', - 'attr': [5], - 'h': 90, - 'nurl': 'http://nurl', - 'w': 728 - } - ], - 'seat': 'MOCK' - } - ], - 'bidid': '5e5c23a5ba71e78' - } - }; - } - - const expectedBid = { - 'requestId': '322add653672f68', - 'cpm': 1.22, - 'width': 728, - 'height': 90, - 'creativeId': 'sortablescreative', - 'dealId': null, - 'currency': 'USD', - 'netRevenue': true, - 'mediaType': 'banner', - 'ttl': 60, - 'ad': '
' - }; - - it('should get the correct bid response', function () { - let result = spec.interpretResponse(makeResponse()); - expect(result.length).to.equal(1); - expect(result[0]).to.deep.equal(expectedBid); - }); - - it('should handle a missing crid', function () { - let noCridResponse = makeResponse(); - delete noCridResponse.body.seatbid[0].bid[0].crid; - const fallbackCrid = noCridResponse.body.seatbid[0].bid[0].id; - let noCridResult = Object.assign({}, expectedBid, {'creativeId': fallbackCrid}); - let result = spec.interpretResponse(noCridResponse); - expect(result.length).to.equal(1); - expect(result[0]).to.deep.equal(noCridResult); - }); - - it('should handle a missing nurl', function () { - let noNurlResponse = makeResponse(); - delete noNurlResponse.body.seatbid[0].bid[0].nurl; - let noNurlResult = Object.assign({}, expectedBid); - noNurlResult.ad = ''; - let result = spec.interpretResponse(noNurlResponse); - expect(result.length).to.equal(1); - expect(result[0]).to.deep.equal(noNurlResult); - }); - - it('should handle a missing adm', function () { - let noAdmResponse = makeResponse(); - delete noAdmResponse.body.seatbid[0].bid[0].adm; - let noAdmResult = Object.assign({}, expectedBid); - delete noAdmResult.ad; - noAdmResult.adUrl = 'http://nurl'; - let result = spec.interpretResponse(noAdmResponse); - expect(result.length).to.equal(1); - expect(result[0]).to.deep.equal(noAdmResult); - }); - - it('handles empty bid response', function () { - let response = { - body: { - 'id': '5e5c23a5ba71e78', - 'seatbid': [] - } - }; - let result = spec.interpretResponse(response); - expect(result.length).to.equal(0); - }); - }); -}); diff --git a/test/spec/modules/sovrnAnalyticsAdapter_spec.js b/test/spec/modules/sovrnAnalyticsAdapter_spec.js deleted file mode 100644 index 299e22ca7903..000000000000 --- a/test/spec/modules/sovrnAnalyticsAdapter_spec.js +++ /dev/null @@ -1,546 +0,0 @@ -import sovrnAnalyticsAdapter from '../../../modules/sovrnAnalyticsAdapter' -import { expect } from 'chai' -import {config} from 'src/config' -import adaptermanager from 'src/adapterManager' -var assert = require('assert'); - -let events = require('src/events'); -let constants = require('src/constants.json'); - -/** - * Emit analytics events - * @param {array} eventArr - array of objects to define the events that will fire - * @param {object} eventObj - key is eventType, value is event - * @param {string} auctionId - the auction id to attached to the events - */ -function emitEvent(eventType, event, auctionId) { - event.auctionId = auctionId; - events.emit(constants.EVENTS[eventType], event); -} - -let auctionStartTimestamp = Date.now(); -let timeout = 3000; -let auctionInit = { - timestamp: auctionStartTimestamp, - timeout: timeout -}; -let bidderCode = 'sovrn'; -let bidderRequestId = '123bri'; -let adUnitCode = 'div'; -let adUnitCode2 = 'div2'; -let bidId = 'bidid'; -let bidId2 = 'bidid2'; -let tId = '7aafa3ee-a80a-46d7-a4a0-cbcba463d97a'; -let tId2 = '99dca3ee-a80a-46d7-a4a0-cbcba463d97e'; -let bidRequested = { - auctionStart: auctionStartTimestamp, - bidderCode: bidderCode, - bidderRequestId: bidderRequestId, - bids: [ - { - adUnitCode: adUnitCode, - bidId: bidId, - bidder: bidderCode, - bidderRequestId: '10340af0c7dc72', - sizes: [[300, 250]], - startTime: auctionStartTimestamp + 100, - transactionId: tId - }, - { - adUnitCode: adUnitCode2, - bidId: bidId2, - bidder: bidderCode, - bidderRequestId: '10340af0c7dc72', - sizes: [[300, 250]], - startTime: auctionStartTimestamp + 100, - transactionId: tId2 - } - ], - doneCbCallCount: 1, - start: auctionStartTimestamp, - timeout: timeout -}; -let bidResponse = { - bidderCode: bidderCode, - width: 300, - height: 250, - statusMessage: 'Bid available', - adId: '3870e27a5752fb', - mediaType: 'banner', - source: 'client', - requestId: bidId, - cpm: 0.8584999918937682, - creativeId: 'cridprebidrtb', - dealId: null, - currency: 'USD', - netRevenue: true, - ad: '
divvy mcdiv
', - ttl: 60000, - responseTimestamp: auctionStartTimestamp + 150, - requestTimestamp: auctionStartTimestamp + 100, - bidder: bidderCode, - adUnitCode: adUnitCode, - timeToRespond: 50, - pbLg: '0.50', - pbMg: '0.80', - pbHg: '0.85', - pbAg: '0.85', - pbDg: '0.85', - pbCg: '', - size: '300x250', - adserverTargeting: { - hb_bidder: bidderCode, - hb_adid: '3870e27a5752fb', - hb_pb: '0.85' - }, - status: 'rendered' -}; - -let bidResponse2 = { - bidderCode: bidderCode, - width: 300, - height: 250, - statusMessage: 'Bid available', - adId: '9999e27a5752fb', - mediaType: 'banner', - source: 'client', - requestId: bidId2, - cpm: 0.12, - creativeId: 'cridprebidrtb', - dealId: null, - currency: 'USD', - netRevenue: true, - ad: '
divvy mcdiv
', - ttl: 60000, - responseTimestamp: auctionStartTimestamp + 150, - requestTimestamp: auctionStartTimestamp + 100, - bidder: bidderCode, - adUnitCode: adUnitCode2, - timeToRespond: 50, - pbLg: '0.10', - pbMg: '0.10', - pbHg: '0.10', - pbAg: '0.10', - pbDg: '0.10', - pbCg: '', - size: '300x250', - adserverTargeting: { - hb_bidder: bidderCode, - hb_adid: '9999e27a5752fb', - hb_pb: '0.10' - }, - status: 'rendered' -}; -let bidAdjustment = {}; -for (var k in bidResponse) bidAdjustment[k] = bidResponse[k]; -bidAdjustment.cpm = 0.8; -let bidAdjustmentNoMatchingRequest = { - bidderCode: 'not-sovrn', - width: 300, - height: 250, - statusMessage: 'Bid available', - adId: '1', - mediaType: 'banner', - source: 'client', - requestId: '1', - cpm: 0.10, - creativeId: '', - dealId: null, - currency: 'USD', - netRevenue: true, - ad: '
divvy mcdiv
', - ttl: 60000, - responseTimestamp: auctionStartTimestamp + 150, - requestTimestamp: auctionStartTimestamp + 100, - bidder: 'not-sovrn', - adUnitCode: '', - timeToRespond: 50, - pbLg: '0.00', - pbMg: '0.10', - pbHg: '0.10', - pbAg: '0.10', - pbDg: '0.10', - pbCg: '', - size: '300x250', - adserverTargeting: { - hb_bidder: 'not-sovrn', - hb_adid: '1', - hb_pb: '0.10' - }, -}; -let bidResponseNoMatchingRequest = bidAdjustmentNoMatchingRequest; - -describe('Sovrn Analytics Adapter', function () { - let xhr; - let requests; - beforeEach(() => { - xhr = sinon.useFakeXMLHttpRequest(); - xhr.onCreate = request => requests.push(request); - requests = []; - sinon.stub(events, 'getEvents').returns([]); - }); - afterEach(() => { - xhr.restore(); - events.getEvents.restore(); - }); - - describe('enableAnalytics ', function () { - beforeEach(() => { - sinon.spy(sovrnAnalyticsAdapter, 'track'); - }); - afterEach(() => { - sovrnAnalyticsAdapter.disableAnalytics(); - sovrnAnalyticsAdapter.track.restore(); - }); - - it('should catch all events if affiliate id present', function () { - adaptermanager.enableAnalytics({ - provider: 'sovrn', - options: { - sovrnId: 123 - } - }); - - events.emit(constants.EVENTS.AUCTION_INIT, {}); - events.emit(constants.EVENTS.AUCTION_END, {}); - events.emit(constants.EVENTS.BID_REQUESTED, {}); - events.emit(constants.EVENTS.BID_RESPONSE, {}); - events.emit(constants.EVENTS.BID_WON, {}); - - sinon.assert.callCount(sovrnAnalyticsAdapter.track, 5); - }); - - it('should catch no events if no affiliate id', function () { - adaptermanager.enableAnalytics({ - provider: 'sovrn', - options: { - } - }); - - events.emit(constants.EVENTS.AUCTION_INIT, {}); - events.emit(constants.EVENTS.AUCTION_END, {}); - events.emit(constants.EVENTS.BID_REQUESTED, {}); - events.emit(constants.EVENTS.BID_RESPONSE, {}); - events.emit(constants.EVENTS.BID_WON, {}); - - sinon.assert.callCount(sovrnAnalyticsAdapter.track, 0); - }); - }); - - describe('sovrnAnalyticsAdapter ', function() { - beforeEach(() => { - sovrnAnalyticsAdapter.enableAnalytics({ - provider: 'sovrn', - options: { - sovrnId: 123 - } - }); - sinon.spy(sovrnAnalyticsAdapter, 'track'); - }); - afterEach(() => { - sovrnAnalyticsAdapter.disableAnalytics(); - sovrnAnalyticsAdapter.track.restore(); - }); - it('should have correct type', function () { - assert.equal(sovrnAnalyticsAdapter.getAdapterType(), 'endpoint') - }) - }); - - describe('auction data collector ', function() { - beforeEach(() => { - sovrnAnalyticsAdapter.enableAnalytics({ - provider: 'sovrn', - options: { - sovrnId: 123 - } - }); - sinon.spy(sovrnAnalyticsAdapter, 'track'); - }); - afterEach(() => { - sovrnAnalyticsAdapter.disableAnalytics(); - sovrnAnalyticsAdapter.track.restore(); - }); - it('should create auctiondata record from init ', function () { - let auctionId = '123.123.123.123'; - emitEvent('AUCTION_INIT', auctionInit, auctionId); - - let auctionData = sovrnAnalyticsAdapter.getAuctions(); - let currentAuction = auctionData[auctionId]; - assert(currentAuction); - let expectedTimeOutData = { - buffer: config.getConfig('timeoutBuffer'), - bidder: config.getConfig('bidderTimeout'), - }; - expect(currentAuction.auction.timeouts).to.deep.equal(expectedTimeOutData); - assert.equal(currentAuction.auction.payload, 'auction'); - assert.equal(currentAuction.auction.priceGranularity, config.getConfig('priceGranularity')) - assert.equal(currentAuction.auction.auctionId, auctionId); - assert.equal(currentAuction.auction.sovrnId, 123); - }); - it('should create a bidrequest object ', function() { - let auctionId = '234.234.234.234'; - emitEvent('AUCTION_INIT', auctionInit, auctionId); - emitEvent('BID_REQUESTED', bidRequested, auctionId); - - let auctionData = sovrnAnalyticsAdapter.getAuctions(); - let currentAuction = auctionData[auctionId]; - assert(currentAuction); - let requests = currentAuction.auction.requests; - assert(requests); - assert.equal(requests.length, 1); - assert.equal(requests[0].bidderCode, bidderCode); - assert.equal(requests[0].bidderRequestId, bidderRequestId); - assert.equal(requests[0].timeout, timeout); - let bids = requests[0].bids; - assert(bids); - assert.equal(bids.length, 2); - assert.equal(bids[0].bidId, bidId); - assert.equal(bids[0].bidder, bidderCode); - assert.equal(bids[0].transactionId, tId); - assert.equal(bids[0].sizes.length, 1); - assert.equal(bids[0].sizes[0][0], 300); - assert.equal(bids[0].sizes[0][1], 250); - expect(requests[0]).to.not.have.property('doneCbCallCount'); - expect(requests[0]).to.not.have.property('auctionId'); - }); - it('should add results to the bid with response ', function () { - let auctionId = '345.345.345.345'; - emitEvent('AUCTION_INIT', auctionInit, auctionId); - emitEvent('BID_REQUESTED', bidRequested, auctionId); - emitEvent('BID_RESPONSE', bidResponse, auctionId); - - let auctionData = sovrnAnalyticsAdapter.getAuctions(); - let currentAuction = auctionData[auctionId]; - let returnedBid = currentAuction.auction.requests[0].bids[0]; - assert.equal(returnedBid.bidId, bidId); - assert.equal(returnedBid.bidder, bidderCode); - assert.equal(returnedBid.transactionId, tId); - assert.equal(returnedBid.sizes.length, 1); - assert.equal(returnedBid.sizes[0][0], 300); - assert.equal(returnedBid.sizes[0][1], 250); - assert.equal(returnedBid.adserverTargeting.hb_adid, '3870e27a5752fb'); - assert.equal(returnedBid.adserverTargeting.hb_bidder, bidderCode); - assert.equal(returnedBid.adserverTargeting.hb_pb, '0.85'); - assert.equal(returnedBid.cpm, 0.8584999918937682); - }); - it('should add new unsynced bid if no request exists for response ', function () { - let auctionId = '456.456.456.456'; - emitEvent('AUCTION_INIT', auctionInit, auctionId); - emitEvent('BID_REQUESTED', bidRequested, auctionId); - emitEvent('BID_RESPONSE', bidResponseNoMatchingRequest, auctionId); - - let auctionData = sovrnAnalyticsAdapter.getAuctions(); - let currentAuction = auctionData[auctionId]; - let requests = currentAuction.auction.requests; - assert(requests); - assert.equal(requests.length, 1); - let bidRequest = requests[0].bids[0]; - expect(bidRequest).to.not.have.property('adserverTargeting'); - expect(bidRequest).to.not.have.property('cpm'); - expect(currentAuction.auction.unsynced[0]).to.deep.equal(bidResponseNoMatchingRequest); - }); - it('should adjust the bid ', function () { - let auctionId = '567.567.567.567'; - emitEvent('AUCTION_INIT', auctionInit, auctionId); - emitEvent('BID_REQUESTED', bidRequested, auctionId); - emitEvent('BID_ADJUSTMENT', bidResponse, auctionId); - emitEvent('BID_RESPONSE', bidAdjustment, auctionId); - - let auctionData = sovrnAnalyticsAdapter.getAuctions(); - let currentAuction = auctionData[auctionId]; - let returnedBid = currentAuction.auction.requests[0].bids[0]; - assert.equal(returnedBid.cpm, 0.8); - assert.equal(returnedBid.originalValues.cpm, 0.8584999918937682); - }); - }); - describe('auction data send ', function() { - let expectedPostBody = { - sovrnId: 123, - auctionId: '678.678.678.678', - payload: 'auction', - priceGranularity: 'medium', - }; - let expectedRequests = { - bidderCode: 'sovrn', - bidderRequestId: '123bri', - timeout: 3000 - }; - let expectedBids = { - adUnitCode: 'div', - bidId: 'bidid', - bidder: 'sovrn', - bidderRequestId: '10340af0c7dc72', - transactionId: '7aafa3ee-a80a-46d7-a4a0-cbcba463d97a', - width: 300, - height: 250, - statusMessage: 'Bid available', - adId: '3870e27a5752fb', - mediaType: 'banner', - source: 'client', - cpm: 0.8584999918937682, - creativeId: 'cridprebidrtb', - dealId: null, - currency: 'USD', - netRevenue: true, - ttl: 60000, - timeToRespond: 50, - size: '300x250', - status: 'rendered', - isAuctionWinner: true - }; - let SecondAdUnitExpectedBids = { - adUnitCode: 'div2', - bidId: 'bidid2', - bidder: 'sovrn', - bidderRequestId: '10340af0c7dc72', - transactionId: '99dca3ee-a80a-46d7-a4a0-cbcba463d97e', - width: 300, - height: 250, - statusMessage: 'Bid available', - adId: '9999e27a5752fb', - mediaType: 'banner', - source: 'client', - cpm: 0.12, - creativeId: 'cridprebidrtb', - dealId: null, - currency: 'USD', - netRevenue: true, - ttl: 60000, - timeToRespond: 50, - size: '300x250', - status: 'rendered', - isAuctionWinner: true - }; - let expectedAdServerTargeting = { - hb_bidder: 'sovrn', - hb_adid: '3870e27a5752fb', - hb_pb: '0.85' - }; - beforeEach(() => { - sovrnAnalyticsAdapter.enableAnalytics({ - provider: 'sovrn', - options: { - sovrnId: 123 - } - }); - sinon.spy(sovrnAnalyticsAdapter, 'track'); - }); - afterEach(() => { - sovrnAnalyticsAdapter.disableAnalytics(); - sovrnAnalyticsAdapter.track.restore(); - }); - it('should send auction data ', function () { - let auctionId = '678.678.678.678'; - emitEvent('AUCTION_INIT', auctionInit, auctionId); - emitEvent('BID_REQUESTED', bidRequested, auctionId); - emitEvent('BID_RESPONSE', bidResponse, auctionId); - emitEvent('BID_RESPONSE', bidResponse2, auctionId) - emitEvent('AUCTION_END', {}, auctionId); - let requestBody = JSON.parse(requests[0].requestBody); - let requestsFromRequestBody = requestBody.requests[0]; - let bidsFromRequests = requestsFromRequestBody.bids[0]; - expect(requestBody).to.deep.include(expectedPostBody); - expect(requestBody.timeouts).to.deep.equal({buffer: 400, bidder: 3000}); - expect(requestsFromRequestBody).to.deep.include(expectedRequests); - expect(bidsFromRequests).to.deep.include(expectedBids); - let bidsFromRequests2 = requestsFromRequestBody.bids[1]; - expect(bidsFromRequests2).to.deep.include(SecondAdUnitExpectedBids); - expect(bidsFromRequests.adserverTargeting).to.deep.include(expectedAdServerTargeting); - }); - }); - describe('bid won data send ', function() { - let auctionId = '789.789.789.789'; - let creativeId = 'cridprebidrtb'; - let requestId = 'requestId69'; - let bidWonEvent = { - ad: 'html', - adId: 'adId', - adUnitCode: adUnitCode, - auctionId: auctionId, - bidder: bidderCode, - bidderCode: bidderCode, - cpm: 1.01, - creativeId: creativeId, - currency: 'USD', - height: 250, - mediaType: 'banner', - requestId: requestId, - size: '300x250', - source: 'client', - status: 'rendered', - statusMessage: 'Bid available', - timeToRespond: 421, - ttl: 60, - width: 300 - }; - let expectedBidWonBody = { - sovrnId: 123, - payload: 'winner' - }; - let expectedWinningBid = { - bidderCode: bidderCode, - width: 300, - height: 250, - statusMessage: 'Bid available', - adId: 'adId', - mediaType: 'banner', - source: 'client', - requestId: requestId, - cpm: 1.01, - creativeId: creativeId, - currency: 'USD', - ttl: 60, - auctionId: auctionId, - bidder: bidderCode, - adUnitCode: adUnitCode, - timeToRespond: 421, - size: '300x250', - }; - beforeEach(() => { - sovrnAnalyticsAdapter.enableAnalytics({ - provider: 'sovrn', - options: { - sovrnId: 123 - } - }); - sinon.spy(sovrnAnalyticsAdapter, 'track'); - }); - afterEach(() => { - sovrnAnalyticsAdapter.disableAnalytics(); - sovrnAnalyticsAdapter.track.restore(); - }); - it('should send bid won data ', function () { - emitEvent('AUCTION_INIT', auctionInit, auctionId); - emitEvent('BID_WON', bidWonEvent, auctionId); - let requestBody = JSON.parse(requests[0].requestBody); - expect(requestBody).to.deep.include(expectedBidWonBody); - expect(requestBody.winningBid).to.deep.include(expectedWinningBid); - }); - }); - describe('Error Tracking', function() { - beforeEach(() => { - sovrnAnalyticsAdapter.enableAnalytics({ - provider: 'sovrn', - options: { - sovrnId: 123 - } - }); - sinon.spy(sovrnAnalyticsAdapter, 'track'); - }); - afterEach(() => { - sovrnAnalyticsAdapter.disableAnalytics() - sovrnAnalyticsAdapter.track.restore() - }); - it('should send an error message when a bid is received for a closed auction', function() { - let auctionId = '678.678.678.678'; - emitEvent('AUCTION_INIT', auctionInit, auctionId) - emitEvent('BID_REQUESTED', bidRequested, auctionId) - emitEvent('AUCTION_END', {}, auctionId) - requests[0].respond(200) - emitEvent('BID_RESPONSE', bidResponse, auctionId) - let requestBody = JSON.parse(requests[1].requestBody) - expect(requestBody.payload).to.equal('error') - expect(requestBody.message).to.include('Event Received after Auction Close Auction Id') - }) - }) -}) diff --git a/test/spec/modules/spotxBidAdapter_spec.js b/test/spec/modules/spotxBidAdapter_spec.js index be550e8fc837..d1be55865835 100644 --- a/test/spec/modules/spotxBidAdapter_spec.js +++ b/test/spec/modules/spotxBidAdapter_spec.js @@ -100,7 +100,7 @@ describe('the spotx adapter', function () { it('should build a very basic request', function() { var request = spec.buildRequests([bid], bidRequestObj)[0]; expect(request.method).to.equal('POST'); - expect(request.url).to.equal('//search.spotxchange.com/openrtb/2.3/dados/12345'); + expect(request.url).to.equal('https://search.spotxchange.com/openrtb/2.3/dados/12345'); expect(request.bidRequest).to.equal(bidRequestObj); expect(request.data.id).to.equal(12345); expect(request.data.ext.wrap_response).to.equal(1); @@ -359,7 +359,7 @@ describe('the spotx adapter', function () { expect(responses[0].netRevenue).to.equal(true); expect(responses[0].requestId).to.equal(123); expect(responses[0].ttl).to.equal(360); - expect(responses[0].vastUrl).to.equal('//search.spotxchange.com/ad/vast.html?key=cache123'); + expect(responses[0].vastUrl).to.equal('https://search.spotxchange.com/ad/vast.html?key=cache123'); expect(responses[0].width).to.equal(400); expect(responses[1].cache_key).to.equal('cache124'); expect(responses[1].channel_id).to.equal(12345); @@ -371,7 +371,7 @@ describe('the spotx adapter', function () { expect(responses[1].netRevenue).to.equal(true); expect(responses[1].requestId).to.equal(124); expect(responses[1].ttl).to.equal(360); - expect(responses[1].vastUrl).to.equal('//search.spotxchange.com/ad/vast.html?key=cache124'); + expect(responses[1].vastUrl).to.equal('https://search.spotxchange.com/ad/vast.html?key=cache124'); expect(responses[1].width).to.equal(200); }); }); @@ -440,9 +440,9 @@ describe('the spotx adapter', function () { responses[0].renderer.render(responses[0]); expect(scriptTag.getAttribute('type')).to.equal('text/javascript'); - expect(scriptTag.getAttribute('src')).to.equal('//js.spotx.tv/easi/v1/12345.js'); + expect(scriptTag.getAttribute('src')).to.equal('https://js.spotx.tv/easi/v1/12345.js'); expect(scriptTag.getAttribute('data-spotx_channel_id')).to.equal('12345'); - expect(scriptTag.getAttribute('data-spotx_vast_url')).to.equal('//search.spotxchange.com/ad/vast.html?key=cache123'); + expect(scriptTag.getAttribute('data-spotx_vast_url')).to.equal('https://search.spotxchange.com/ad/vast.html?key=cache123'); expect(scriptTag.getAttribute('data-spotx_ad_unit')).to.equal('incontent'); expect(scriptTag.getAttribute('data-spotx_collapse')).to.equal('0'); expect(scriptTag.getAttribute('data-spotx_autoplay')).to.equal('1'); @@ -472,9 +472,9 @@ describe('the spotx adapter', function () { responses[0].renderer.render(responses[0]); expect(scriptTag.getAttribute('type')).to.equal('text/javascript'); - expect(scriptTag.getAttribute('src')).to.equal('//js.spotx.tv/easi/v1/12345.js'); + expect(scriptTag.getAttribute('src')).to.equal('https://js.spotx.tv/easi/v1/12345.js'); expect(scriptTag.getAttribute('data-spotx_channel_id')).to.equal('12345'); - expect(scriptTag.getAttribute('data-spotx_vast_url')).to.equal('//search.spotxchange.com/ad/vast.html?key=cache123'); + expect(scriptTag.getAttribute('data-spotx_vast_url')).to.equal('https://search.spotxchange.com/ad/vast.html?key=cache123'); expect(scriptTag.getAttribute('data-spotx_ad_unit')).to.equal('incontent'); expect(scriptTag.getAttribute('data-spotx_collapse')).to.equal('0'); expect(scriptTag.getAttribute('data-spotx_autoplay')).to.equal('1'); diff --git a/test/spec/modules/staqAnalyticsAdapter_spec.js b/test/spec/modules/staqAnalyticsAdapter_spec.js index 593871fd9d61..1b35f4918547 100644 --- a/test/spec/modules/staqAnalyticsAdapter_spec.js +++ b/test/spec/modules/staqAnalyticsAdapter_spec.js @@ -60,35 +60,35 @@ describe('', function() { it('should parse first direct visit as (direct)', function() { stubGetItem.withArgs('adk_dpt_analytics').returns(undefined); stubSetItem.returns(undefined); - let source = getUmtSource('http://example.com'); + let source = getUmtSource('https://example.com'); expect(source).to.be.eql(DIRECT); }); it('should parse visit from google as organic', function() { stubGetItem.withArgs('adk_dpt_analytics').returns(undefined); stubSetItem.returns(undefined); - let source = getUmtSource('http://example.com', 'https://www.google.com/search?q=pikachu'); + let source = getUmtSource('https://example.com', 'https://www.google.com/search?q=pikachu'); expect(source).to.be.eql(GOOGLE_ORGANIC); }); it('should parse referral visit', function() { stubGetItem.withArgs('adk_dpt_analytics').returns(undefined); stubSetItem.returns(undefined); - let source = getUmtSource('http://example.com', 'http://lander.com/lander.html'); + let source = getUmtSource('https://example.com', 'https://lander.com/lander.html'); expect(source).to.be.eql(REFERRER); }); it('should parse referral visit from same domain as direct', function() { stubGetItem.withArgs('adk_dpt_analytics').returns(undefined); stubSetItem.returns(undefined); - let source = getUmtSource('http://lander.com/news.html', 'http://lander.com/lander.html'); + let source = getUmtSource('https://lander.com/news.html', 'https://lander.com/lander.html'); expect(source).to.be.eql(DIRECT); }); it('should parse campaign visit', function() { stubGetItem.withArgs('adk_dpt_analytics').returns(undefined); stubSetItem.returns(undefined); - let source = getUmtSource('http://lander.com/index.html?utm_campaign=new_campaign&utm_source=adkernel&utm_medium=email&utm_c1=1&utm_c2=2&utm_c3=3&utm_c4=4&utm_c5=5'); + let source = getUmtSource('https://lander.com/index.html?utm_campaign=new_campaign&utm_source=adkernel&utm_medium=email&utm_c1=1&utm_c2=2&utm_c3=3&utm_c4=4&utm_c5=5'); expect(source).to.be.eql(CAMPAIGN); }); }); @@ -208,7 +208,7 @@ describe('', function() { options: { connId: 777, queueTimeout: 1000, - url: 'http://localhost/prebid' + url: 'https://localhost/prebid' } }); diff --git a/test/spec/modules/supply2BidAdapter_spec.js b/test/spec/modules/supply2BidAdapter_spec.js deleted file mode 100644 index 8abbecd801c4..000000000000 --- a/test/spec/modules/supply2BidAdapter_spec.js +++ /dev/null @@ -1,332 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/supply2BidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; - -describe('Supply2Adapter', function () { - const adapter = newBidder(spec); - - describe('inherited functions', function () { - it('exists and is a function', function () { - expect(adapter.callBids).to.exist.and.to.be.a('function'); - }); - }); - - describe('isBidRequestValid', function () { - let bid = { - 'bidder': 'supply2', - 'params': { - 'uid': '16' - }, - 'adUnitCode': 'adunit-code', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - }; - - it('should return true when required params found', function () { - expect(spec.isBidRequestValid(bid)).to.equal(true); - }); - - it('should return false when required params are not passed', function () { - let bid = Object.assign({}, bid); - delete bid.params; - bid.params = { - 'uid': 0 - }; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - }); - - describe('buildRequests', function () { - function parseRequest(url) { - const res = {}; - url.split('&').forEach((it) => { - const couple = it.split('='); - res[couple[0]] = decodeURIComponent(couple[1]); - }); - return res; - } - let bidRequests = [ - { - 'bidder': 'supply2', - 'params': { - 'uid': '16' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - }, - { - 'bidder': 'supply2', - 'params': { - 'uid': '16' - }, - 'adUnitCode': 'adunit-code-2', - 'sizes': [[728, 90]], - 'bidId': '3150ccb55da321', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - }, - { - 'bidder': 'supply2', - 'params': { - 'uid': '17' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '42dbe3a7168a6a', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - } - ]; - - it('should attach valid params to the tag', function () { - const request = spec.buildRequests([bidRequests[0]]); - expect(request.data).to.be.an('string'); - const payload = parseRequest(request.data); - expect(payload).to.have.property('u').that.is.a('string'); - expect(payload).to.have.property('pt', 'net'); - expect(payload).to.have.property('auids', '16'); - expect(payload).to.have.property('r', '22edbae2733bf6'); - }); - - it('auids must not be duplicated', function () { - const request = spec.buildRequests(bidRequests); - expect(request.data).to.be.an('string'); - const payload = parseRequest(request.data); - expect(payload).to.have.property('u').that.is.a('string'); - expect(payload).to.have.property('pt', 'net'); - expect(payload).to.have.property('auids', '16,17'); - expect(payload).to.have.property('r', '22edbae2733bf6'); - }); - - it('if timeout is present, payload must have wtimeout parameter', function () { - const request = spec.buildRequests(bidRequests, {timeout: 2000}); - expect(request.data).to.be.an('string'); - const payload = parseRequest(request.data); - expect(payload).to.have.property('wtimeout', '2000'); - }); - - it('pt parameter must be "gross" if params.priceType === "gross"', function () { - bidRequests[1].params.priceType = 'gross'; - const request = spec.buildRequests(bidRequests); - expect(request.data).to.be.an('string'); - const payload = parseRequest(request.data); - expect(payload).to.have.property('u').that.is.a('string'); - expect(payload).to.have.property('pt', 'gross'); - expect(payload).to.have.property('auids', '16,17'); - expect(payload).to.have.property('r', '22edbae2733bf6'); - delete bidRequests[1].params.priceType; - }); - - it('pt parameter must be "net" or "gross"', function () { - bidRequests[1].params.priceType = 'some'; - const request = spec.buildRequests(bidRequests); - expect(request.data).to.be.an('string'); - const payload = parseRequest(request.data); - expect(payload).to.have.property('u').that.is.a('string'); - expect(payload).to.have.property('pt', 'net'); - expect(payload).to.have.property('auids', '16,17'); - expect(payload).to.have.property('r', '22edbae2733bf6'); - delete bidRequests[1].params.priceType; - }); - - it('if gdprConsent is present payload must have gdpr params', function () { - const request = spec.buildRequests(bidRequests, {gdprConsent: {consentString: 'AAA', gdprApplies: true}}); - expect(request.data).to.be.an('string'); - const payload = parseRequest(request.data); - expect(payload).to.have.property('gdpr_consent', 'AAA'); - expect(payload).to.have.property('gdpr_applies', '1'); - }); - - it('if gdprApplies is false gdpr_applies must be 0', function () { - const request = spec.buildRequests(bidRequests, {gdprConsent: {consentString: 'AAA', gdprApplies: false}}); - expect(request.data).to.be.an('string'); - const payload = parseRequest(request.data); - expect(payload).to.have.property('gdpr_consent', 'AAA'); - expect(payload).to.have.property('gdpr_applies', '0'); - }); - - it('if gdprApplies is undefined gdpr_applies must be 1', function () { - const request = spec.buildRequests(bidRequests, {gdprConsent: {consentString: 'AAA'}}); - expect(request.data).to.be.an('string'); - const payload = parseRequest(request.data); - expect(payload).to.have.property('gdpr_consent', 'AAA'); - expect(payload).to.have.property('gdpr_applies', '1'); - }); - }); - - describe('interpretResponse', function () { - const responses = [ - {'bid': [{'price': 1.15, 'adm': '
test content 1
', 'auid': 23, 'h': 250, 'w': 300}], 'seat': '1'}, - {'bid': [{'price': 0.5, 'adm': '
test content 2
', 'auid': 24, 'h': 90, 'w': 728}], 'seat': '1'}, - {'bid': [{'price': 0, 'auid': 25, 'h': 250, 'w': 300}], 'seat': '1'}, - {'bid': [{'price': 0, 'adm': '
test content 4
', 'h': 250, 'w': 300}], 'seat': '1'}, - undefined, - {'bid': [], 'seat': '1'}, - {'seat': '1'}, - ]; - - it('should get correct bid response', function () { - const bidRequests = [ - { - 'bidder': 'supply2', - 'params': { - 'uid': '23' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '659423fff799cb', - 'bidderRequestId': '5f2009617a7c0a', - 'auctionId': '1cbd2feafe5e8b', - } - ]; - const request = spec.buildRequests(bidRequests); - const expectedResponse = [ - { - 'requestId': '659423fff799cb', - 'cpm': 1.15, - 'creativeId': 23, - 'dealId': undefined, - 'width': 300, - 'height': 250, - 'ad': '
test content 1
', - 'bidderCode': 'supply2', - 'currency': 'USD', - 'netRevenue': true, - 'ttl': 360, - } - ]; - - const result = spec.interpretResponse({'body': {'seatbid': [responses[0]]}}, request); - expect(result).to.deep.equal(expectedResponse); - }); - - it('should get correct multi bid response', function () { - const bidRequests = [ - { - 'bidder': 'supply2', - 'params': { - 'uid': '23' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '300bfeb0d71a5b', - 'bidderRequestId': '2c2bb1972df9a', - 'auctionId': '1fa09aee5c8c99', - }, - { - 'bidder': 'supply2', - 'params': { - 'uid': '24' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '4dff80cc4ee346', - 'bidderRequestId': '2c2bb1972df9a', - 'auctionId': '1fa09aee5c8c99', - }, - { - 'bidder': 'supply2', - 'params': { - 'uid': '23' - }, - 'adUnitCode': 'adunit-code-2', - 'sizes': [[728, 90]], - 'bidId': '5703af74d0472a', - 'bidderRequestId': '2c2bb1972df9a', - 'auctionId': '1fa09aee5c8c99', - } - ]; - const request = spec.buildRequests(bidRequests); - const expectedResponse = [ - { - 'requestId': '300bfeb0d71a5b', - 'cpm': 1.15, - 'creativeId': 23, - 'dealId': undefined, - 'width': 300, - 'height': 250, - 'ad': '
test content 1
', - 'bidderCode': 'supply2', - 'currency': 'USD', - 'netRevenue': true, - 'ttl': 360, - }, - { - 'requestId': '5703af74d0472a', - 'cpm': 1.15, - 'creativeId': 23, - 'dealId': undefined, - 'width': 300, - 'height': 250, - 'ad': '
test content 1
', - 'bidderCode': 'supply2', - 'currency': 'USD', - 'netRevenue': true, - 'ttl': 360, - }, - { - 'requestId': '4dff80cc4ee346', - 'cpm': 0.5, - 'creativeId': 24, - 'dealId': undefined, - 'width': 728, - 'height': 90, - 'ad': '
test content 2
', - 'bidderCode': 'supply2', - 'currency': 'USD', - 'netRevenue': true, - 'ttl': 360, - } - ]; - - const result = spec.interpretResponse({'body': {'seatbid': [responses[0], responses[1]]}}, request); - expect(result).to.deep.equal(expectedResponse); - }); - - it('handles wrong and nobid responses', function () { - const bidRequests = [ - { - 'bidder': 'supply2', - 'params': { - 'uid': '25' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '300bfeb0d7190gf', - 'bidderRequestId': '2c2bb1972d23af', - 'auctionId': '1fa09aee5c84d34', - }, - { - 'bidder': 'supply2', - 'params': { - 'uid': '26' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '300bfeb0d71321', - 'bidderRequestId': '2c2bb1972d23af', - 'auctionId': '1fa09aee5c84d34', - }, - { - 'bidder': 'supply2', - 'params': { - 'uid': '27' - }, - 'adUnitCode': 'adunit-code-2', - 'sizes': [[728, 90]], - 'bidId': '300bfeb0d7183bb', - 'bidderRequestId': '2c2bb1972d23af', - 'auctionId': '1fa09aee5c84d34', - } - ]; - const request = spec.buildRequests(bidRequests); - const result = spec.interpretResponse({'body': {'seatbid': responses.slice(2)}}, request); - expect(result.length).to.equal(0); - }); - }); -}); diff --git a/test/spec/modules/synacormediaBidAdapter_spec.js b/test/spec/modules/synacormediaBidAdapter_spec.js index d2f024181a42..918e4e394bd0 100644 --- a/test/spec/modules/synacormediaBidAdapter_spec.js +++ b/test/spec/modules/synacormediaBidAdapter_spec.js @@ -133,10 +133,10 @@ describe('synacormediaBidAdapter ', function () { auctionStart: 1553624929697, timeout: 700, refererInfo: { - referer: 'http://localhost:9999/test/pages/video.html?pbjs_debug=true', + referer: 'https://localhost:9999/test/pages/video.html?pbjs_debug=true', reachedTop: true, numIframes: 0, - stack: [ 'http://localhost:9999/test/pages/video.html?pbjs_debug=true' ] + stack: [ 'https://localhost:9999/test/pages/video.html?pbjs_debug=true' ] }, start: 1553624929700 }; @@ -197,7 +197,7 @@ describe('synacormediaBidAdapter ', function () { expect(req).be.an('object'); expect(req).to.have.property('method', 'POST'); expect(req).to.have.property('url'); - expect(req.url).to.contain('//prebid.technoratimedia.com/openrtb/bids/prebid?'); + expect(req.url).to.contain('https://prebid.technoratimedia.com/openrtb/bids/prebid?'); expect(req.data).to.exist.and.to.be.an('object'); expect(req.data.id).to.equal('xyz123'); expect(req.data.imp).to.eql([expectedDataImp1, expectedDataImp2]); @@ -207,7 +207,7 @@ describe('synacormediaBidAdapter ', function () { expect(reqVideo).be.an('object'); expect(reqVideo).to.have.property('method', 'POST'); expect(reqVideo).to.have.property('url'); - expect(reqVideo.url).to.contain('//prebid.technoratimedia.com/openrtb/bids/prebid?'); + expect(reqVideo.url).to.contain('https://prebid.technoratimedia.com/openrtb/bids/prebid?'); expect(reqVideo.data).to.exist.and.to.be.an('object'); expect(reqVideo.data.id).to.equal('VideoAuctionId124'); expect(reqVideo.data.imp).to.eql([expectedDataVideo1]); @@ -227,7 +227,7 @@ describe('synacormediaBidAdapter ', function () { expect(req).to.exist.and.be.an('object'); expect(req).to.have.property('method', 'POST'); expect(req).to.have.property('url'); - expect(req.url).to.contain('//prebid.technoratimedia.com/openrtb/bids/prebid?'); + expect(req.url).to.contain('https://prebid.technoratimedia.com/openrtb/bids/prebid?'); expect(req.data.id).to.equal('xyz123'); expect(req.data.imp).to.eql([expectedDataImp1, expectedDataImp2, { banner: { @@ -254,7 +254,7 @@ describe('synacormediaBidAdapter ', function () { let req = spec.buildRequests([mismatchedSeatBidRequest, validBidRequest], bidderRequest); expect(req).to.have.property('method', 'POST'); expect(req).to.have.property('url'); - expect(req.url).to.contain('//prebid.technoratimedia.com/openrtb/bids/somethingelse?'); + expect(req.url).to.contain('https://prebid.technoratimedia.com/openrtb/bids/somethingelse?'); expect(req.data.id).to.equal('xyz123'); expect(req.data.imp).to.eql([ { @@ -283,7 +283,7 @@ describe('synacormediaBidAdapter ', function () { let req = spec.buildRequests([badFloorBidRequest], bidderRequest); expect(req).to.have.property('method', 'POST'); expect(req).to.have.property('url'); - expect(req.url).to.contain('//prebid.technoratimedia.com/openrtb/bids/prebid?src=$$REPO_AND_VERSION$$'); + expect(req.url).to.contain('https://prebid.technoratimedia.com/openrtb/bids/prebid?src=$$REPO_AND_VERSION$$'); expect(req.data.id).to.equal('xyz123'); expect(req.data.imp).to.eql([ { @@ -310,7 +310,7 @@ describe('synacormediaBidAdapter ', function () { let req = spec.buildRequests([badFloorBidRequest], bidderRequest); expect(req).to.have.property('method', 'POST'); expect(req).to.have.property('url'); - expect(req.url).to.contain('//prebid.technoratimedia.com/openrtb/bids/prebid?src=$$REPO_AND_VERSION$$'); + expect(req.url).to.contain('https://prebid.technoratimedia.com/openrtb/bids/prebid?src=$$REPO_AND_VERSION$$'); expect(req.data.id).to.equal('xyz123'); expect(req.data.imp).to.eql([ { @@ -338,7 +338,7 @@ describe('synacormediaBidAdapter ', function () { let req = spec.buildRequests([newPosBidRequest], bidderRequest); expect(req).to.have.property('method', 'POST'); expect(req).to.have.property('url'); - expect(req.url).to.contain('//prebid.technoratimedia.com/openrtb/bids/prebid?src=$$REPO_AND_VERSION$$'); + expect(req.url).to.contain('https://prebid.technoratimedia.com/openrtb/bids/prebid?src=$$REPO_AND_VERSION$$'); expect(req.data.id).to.equal('xyz123'); expect(req.data.imp).to.eql([ { @@ -365,7 +365,7 @@ describe('synacormediaBidAdapter ', function () { let req = spec.buildRequests([newPosBidRequest], bidderRequest); expect(req).to.have.property('method', 'POST'); expect(req).to.have.property('url'); - expect(req.url).to.contain('//prebid.technoratimedia.com/openrtb/bids/prebid?src=$$REPO_AND_VERSION$$'); + expect(req.url).to.contain('https://prebid.technoratimedia.com/openrtb/bids/prebid?src=$$REPO_AND_VERSION$$'); expect(req.data.id).to.equal('xyz123'); expect(req.data.imp).to.eql([ { @@ -453,7 +453,7 @@ describe('synacormediaBidAdapter ', function () { let req = spec.buildRequests([validBidRequestVideo], bidderRequest); expect(req).to.have.property('method', 'POST'); expect(req).to.have.property('url'); - expect(req.url).to.contain('//prebid.technoratimedia.com/openrtb/bids/prebid?src=$$REPO_AND_VERSION$$'); + expect(req.url).to.contain('https://prebid.technoratimedia.com/openrtb/bids/prebid?src=$$REPO_AND_VERSION$$'); expect(req.data.id).to.equal('xyz123'); expect(req.data.imp).to.eql([ { @@ -511,7 +511,7 @@ describe('synacormediaBidAdapter ', function () { let req = spec.buildRequests([validBidRequestVideo], bidderRequest); expect(req).to.have.property('method', 'POST'); expect(req).to.have.property('url'); - expect(req.url).to.contain('//prebid.technoratimedia.com/openrtb/bids/prebid?src=$$REPO_AND_VERSION$$'); + expect(req.url).to.contain('https://prebid.technoratimedia.com/openrtb/bids/prebid?src=$$REPO_AND_VERSION$$'); expect(req.data.id).to.equal('xyz123'); expect(req.data.imp).to.eql([ { @@ -542,7 +542,7 @@ describe('synacormediaBidAdapter ', function () { price: 0.13, crid: '1022-250', adm: '', - nurl: '//uat-net.technoratimedia.com/openrtb/tags?ID=k5JkFVQ1RJT05fSU1QX0lEPXYyZjczN&AUCTION_PRICE=${AUCTION_PRICE}' + nurl: 'https://uat-net.technoratimedia.com/openrtb/tags?ID=k5JkFVQ1RJT05fSU1QX0lEPXYyZjczN&AUCTION_PRICE=${AUCTION_PRICE}' }; let bidResponse2 = { id: '10865933907263800~9999~0', @@ -550,7 +550,7 @@ describe('synacormediaBidAdapter ', function () { price: 1.99, crid: '9993-013', adm: '', - nurl: '//uat-net.technoratimedia.com/openrtb/tags?ID=OTk5OX4wJkFVQ1RJT05fU0VBVF9JR&AUCTION_PRICE=${AUCTION_PRICE}' + nurl: 'https://uat-net.technoratimedia.com/openrtb/tags?ID=OTk5OX4wJkFVQ1RJT05fU0VBVF9JR&AUCTION_PRICE=${AUCTION_PRICE}' }; let serverResponse; @@ -685,7 +685,7 @@ describe('synacormediaBidAdapter ', function () { expect(usersyncs).to.be.an('array').that.is.not.empty; expect(usersyncs[0]).to.have.property('type', 'iframe'); expect(usersyncs[0]).to.have.property('url'); - expect(usersyncs[0].url).to.contain('//ad-cdn.technoratimedia.com/html/usersync.html'); + expect(usersyncs[0].url).to.contain('https://ad-cdn.technoratimedia.com/html/usersync.html'); }); it('should not return a usersync when iframes are not enabled', function () { diff --git a/test/spec/modules/teadsBidAdapter_spec.js b/test/spec/modules/teadsBidAdapter_spec.js index 5d92f9d7a08f..5809be995dd1 100644 --- a/test/spec/modules/teadsBidAdapter_spec.js +++ b/test/spec/modules/teadsBidAdapter_spec.js @@ -2,8 +2,8 @@ import {expect} from 'chai'; import {spec} from 'modules/teadsBidAdapter'; import {newBidder} from 'src/adapters/bidderFactory'; -const ENDPOINT = '//a.teads.tv/hb/bid-request'; -const AD_SCRIPT = '"'; +const ENDPOINT = 'https://a.teads.tv/hb/bid-request'; +const AD_SCRIPT = '"'; describe('teadsBidAdapter', () => { const adapter = newBidder(spec); @@ -136,7 +136,7 @@ describe('teadsBidAdapter', () => { const bidRequest = Object.assign({}, bidRequests[0]) const bidderRequest = { refererInfo: { - referer: 'http://example.com/page.html', + referer: 'https://example.com/page.html', reachedTop: true, numIframes: 2 } @@ -145,7 +145,7 @@ describe('teadsBidAdapter', () => { const payload = JSON.parse(request.data); expect(payload.referrer).to.exist; - expect(payload.referrer).to.deep.equal('http://example.com/page.html') + expect(payload.referrer).to.deep.equal('https://example.com/page.html') }); it('should send GDPR to endpoint with 11 status', function() { @@ -380,7 +380,7 @@ describe('teadsBidAdapter', () => { } }; let hb_version = '$prebid.version$' - let finalUrl = `//sync.teads.tv/iframe?hb_provider=prebid&hb_version=${hb_version}&gdprIab={"status":12,"consent":"${consentString}"}&placementId=34&`; + let finalUrl = `https://sync.teads.tv/iframe?hb_provider=prebid&hb_version=${hb_version}&gdprIab={"status":12,"consent":"${consentString}"}&placementId=34&`; const userSync = spec.getUserSyncs(syncOptions, bids, gdprConsent); expect(userSync[0].type).to.equal('iframe'); @@ -413,7 +413,7 @@ describe('teadsBidAdapter', () => { } }; let hb_version = '$prebid.version$' - let finalUrl = `//sync.teads.tv/iframe?hb_provider=prebid&hb_version=${hb_version}&gdprIab={"status":12,"consent":"${consentString}"}&`; + let finalUrl = `https://sync.teads.tv/iframe?hb_provider=prebid&hb_version=${hb_version}&gdprIab={"status":12,"consent":"${consentString}"}&`; const userSync = spec.getUserSyncs(syncOptions, bids, gdprConsent); expect(userSync[0].type).to.equal('iframe'); diff --git a/test/spec/modules/theAdxBidAdapter_spec.js b/test/spec/modules/theAdxBidAdapter_spec.js index 5381709369c6..4874fbd08411 100644 --- a/test/spec/modules/theAdxBidAdapter_spec.js +++ b/test/spec/modules/theAdxBidAdapter_spec.js @@ -13,8 +13,8 @@ describe('TheAdxAdapter', function () { const adapter = newBidder(spec); describe('getUserSyncs', () => { - const USER_SYNC_IFRAME_URL = '//ssp.theadx.com/async_usersync_iframe.html' - const USER_SYNC_IMAGE_URL = '//ssp.theadx.com/async_usersync_image.gif' + const USER_SYNC_IFRAME_URL = 'https://ssp.theadx.com/async_usersync_iframe.html' + const USER_SYNC_IMAGE_URL = 'https://ssp.theadx.com/async_usersync_image.gif' expect(spec.getUserSyncs({ iframeEnabled: true, @@ -87,8 +87,8 @@ describe('TheAdxAdapter', function () { const sampleBidderRequest = { bidderRequestId: 'sample', refererInfo: { - canonicalUrl: 'http://domain.com/to', - referer: 'http://domain.com/from' + canonicalUrl: 'https://domain.com/to', + referer: 'https://domain.com/from' } } @@ -449,7 +449,7 @@ describe('TheAdxAdapter', function () { it('returns an valid bid response on sucessful video request', function () { let incomingRequestId = 'XXtesting-275XX'; let responsePrice = 6 - let vast_url = 'http://theadx.com/vast?rid=a8ae0b48-a8db-4220-ba0c-7458f452b1f5&{FOR_COVARAGE}' + let vast_url = 'https://theadx.com/vast?rid=a8ae0b48-a8db-4220-ba0c-7458f452b1f5&{FOR_COVARAGE}' let responseCreativeId = '1556'; let responseCurrency = 'TRY'; @@ -544,7 +544,7 @@ describe('TheAdxAdapter', function () { assets: [{ id: 3, img: { - url: '//ads.theadx.com/winwords/120/17508/154712307258.73.jpg', + url: 'https://ads.theadx.com/winwords/120/17508/154712307258.73.jpg', h: 627, w: 1200 } @@ -566,7 +566,7 @@ describe('TheAdxAdapter', function () { }, { id: 2, img: { - url: '//ads.theadx.com/winwords/120/17508/154712307258.74.png', + url: 'https://ads.theadx.com/winwords/120/17508/154712307258.74.png', h: 128, w: 128 } diff --git a/test/spec/modules/timBidAdapter_spec.js b/test/spec/modules/timBidAdapter_spec.js index 0dc14bf3e037..8e22d4716d72 100644 --- a/test/spec/modules/timBidAdapter_spec.js +++ b/test/spec/modules/timBidAdapter_spec.js @@ -77,7 +77,7 @@ describe('timAdapterTests', function () { describe('interpretResponse', function () { const bidRequest = { 'method': 'GET', - 'url': '//bidder.url/api/prebid/testpublisherid/header-bid-tag-0?br=%7B%22id%22%3A%223a3ac0d7fc2548%22%2C%22imp%22%3A%5B%7B%22id%22%3A%22251b8a6d3aac3e%22%2C%22banner%22%3A%7B%22w%22%3A300%2C%22h%22%3A250%7D%2C%22tagid%22%3A%22header-bid-tag-0%22%7D%5D%2C%22site%22%3A%7B%22domain%22%3A%22www.chinatimes.com%22%2C%22page%22%3A%22http%3A%2F%2Fwww.chinatimes.com%2Fa%22%2C%22publisher%22%3A%7B%22id%22%3A%22testpublisherid%22%7D%7D%2C%22device%22%3A%7B%22language%22%3A%22en%22%2C%22w%22%3A300%2C%22h%22%3A250%2C%22js%22%3A1%2C%22ua%22%3A%22Mozilla%2F5.0%20(Windows%20NT%2010.0%3B%20Win64%3B%20x64)%20AppleWebKit%2F537.36%20(KHTML%2C%20like%20Gecko)%20Chrome%2F71.0.3578.98%20Safari%2F537.36%22%7D%2C%22bidId%22%3A%22251b8a6d3aac3e%22%7D', + 'url': 'https://bidder.url/api/prebid/testpublisherid/header-bid-tag-0?br=%7B%22id%22%3A%223a3ac0d7fc2548%22%2C%22imp%22%3A%5B%7B%22id%22%3A%22251b8a6d3aac3e%22%2C%22banner%22%3A%7B%22w%22%3A300%2C%22h%22%3A250%7D%2C%22tagid%22%3A%22header-bid-tag-0%22%7D%5D%2C%22site%22%3A%7B%22domain%22%3A%22www.chinatimes.com%22%2C%22page%22%3A%22https%3A%2F%2Fwww.chinatimes.com%2Fa%22%2C%22publisher%22%3A%7B%22id%22%3A%22testpublisherid%22%7D%7D%2C%22device%22%3A%7B%22language%22%3A%22en%22%2C%22w%22%3A300%2C%22h%22%3A250%2C%22js%22%3A1%2C%22ua%22%3A%22Mozilla%2F5.0%20(Windows%20NT%2010.0%3B%20Win64%3B%20x64)%20AppleWebKit%2F537.36%20(KHTML%2C%20like%20Gecko)%20Chrome%2F71.0.3578.98%20Safari%2F537.36%22%7D%2C%22bidId%22%3A%22251b8a6d3aac3e%22%7D', 'data': '', 'options': {'withCredentials': false} }; @@ -97,7 +97,7 @@ describe('timAdapterTests', function () { const validBidRequest = { 'method': 'GET', - 'url': '//bidder.url/api/v2/services/prebid/testpublisherid/placementCodeTest?br=%7B%22id%22%3A%2248640869bd9db94%22%2C%22imp%22%3A%5B%7B%22id%22%3A%224746fcaa11197f3%22%2C%22banner%22%3A%7B%22w%22%3A300%2C%22h%22%3A250%7D%2C%22tagid%22%3A%22placementCodeTest%22%7D%5D%2C%22site%22%3A%7B%22domain%22%3A%22mediamart.tv%22%2C%22page%22%3A%22http%3A%2F%2Fmediamart.tv%2Fsas%2Ftests%2FDesktop%2Fcaesar%2Fdfptest.html%22%2C%22publisher%22%3A%7B%22id%22%3A%22testpublisherid%22%7D%7D%2C%22device%22%3A%7B%22language%22%3A%22en%22%2C%22w%22%3A300%2C%22h%22%3A250%2C%22js%22%3A1%2C%22ua%22%3A%22Mozilla%2F5.0%20(Windows%20NT%2010.0%3B%20Win64%3B%20x64)%20AppleWebKit%2F537.36%20(KHTML%2C%20like%20Gecko)%20Chrome%2F71.0.3578.98%20Safari%2F537.36%22%7D%2C%22bidId%22%3A%224746fcaa11197f3%22%7D', + 'url': 'https://bidder.url/api/v2/services/prebid/testpublisherid/placementCodeTest?br=%7B%22id%22%3A%2248640869bd9db94%22%2C%22imp%22%3A%5B%7B%22id%22%3A%224746fcaa11197f3%22%2C%22banner%22%3A%7B%22w%22%3A300%2C%22h%22%3A250%7D%2C%22tagid%22%3A%22placementCodeTest%22%7D%5D%2C%22site%22%3A%7B%22domain%22%3A%22mediamart.tv%22%2C%22page%22%3A%22https%3A%2F%2Fmediamart.tv%2Fsas%2Ftests%2FDesktop%2Fcaesar%2Fdfptest.html%22%2C%22publisher%22%3A%7B%22id%22%3A%22testpublisherid%22%7D%7D%2C%22device%22%3A%7B%22language%22%3A%22en%22%2C%22w%22%3A300%2C%22h%22%3A250%2C%22js%22%3A1%2C%22ua%22%3A%22Mozilla%2F5.0%20(Windows%20NT%2010.0%3B%20Win64%3B%20x64)%20AppleWebKit%2F537.36%20(KHTML%2C%20like%20Gecko)%20Chrome%2F71.0.3578.98%20Safari%2F537.36%22%7D%2C%22bidId%22%3A%224746fcaa11197f3%22%7D', 'data': '', 'options': {'withCredentials': false} }; diff --git a/test/spec/modules/topRTBBidAdapter_spec.js b/test/spec/modules/topRTBBidAdapter_spec.js index 83e5de3e4b9b..1c88658d6df4 100644 --- a/test/spec/modules/topRTBBidAdapter_spec.js +++ b/test/spec/modules/topRTBBidAdapter_spec.js @@ -39,7 +39,7 @@ describe('topRTBBidAdapterTests', function () { let serverResponse = { body: [{ 'cpm': 1, - 'mediadata': "Banner 728x90", + 'mediadata': "Banner 728x90", 'width': 728, 'currency': 'USD', 'id': 'cd95dffec6b645afbc4e5aa9f68f2ff3', diff --git a/test/spec/modules/trafficrootsBidAdapter_spec.js b/test/spec/modules/trafficrootsBidAdapter_spec.js deleted file mode 100644 index 54c102d33efd..000000000000 --- a/test/spec/modules/trafficrootsBidAdapter_spec.js +++ /dev/null @@ -1,149 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/trafficrootsBidAdapter'; - -describe('trafficrootsAdapterTests', () => { - describe('bidRequestValidity', () => { - it('bidRequest with zoneId and deliveryUrl params', () => { - expect(spec.isBidRequestValid({ - bidder: 'trafficroots', - params: { - zoneId: 'aa0444af31', - deliveryUrl: 'https://service.trafficroosts.com/prebid' - } - })).to.equal(true); - }); - - it('bidRequest with only zoneId', () => { - expect(spec.isBidRequestValid({ - bidder: 'trafficroots', - params: { - zoneId: '8f527a4835' - } - })).to.equal(true); - }); - - it('bidRequest with only deliveryUrl', () => { - expect(spec.isBidRequestValid({ - bidder: 'trafficroots', - params: { - deliveryUrl: 'https://service.trafficroosts.com/prebid' - } - })).to.equal(false); - }); - }); - - describe('bidRequest', () => { - const bidRequests = [{ - 'bidder': 'trafficroots', - 'bidId': '29fa5c08928bde', - 'params': { - 'zoneId': 'aa0444af31', - }, - 'adUnitCode': 'div-gpt-ad-1460505748561-0', - 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', - 'sizes': [[300, 250], [300, 600]], - 'bidderRequestId': '418b37f85e772c', - 'auctionId': '18fd8b8b0bd757' - }, { - 'bidder': 'trafficroots', - 'bidId': '29fa5c08928bde', - 'params': { - 'zoneId': '8f527a4835', - 'deliveryUrl': 'https://service.trafficroosts.com/prebid' - }, - 'adUnitCode': 'div-gpt-ad-1460505748561-0', - 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', - 'sizes': [[300, 250], [300, 600]], - 'bidderRequestId': '418b37f85e772c', - 'auctionId': '18fd8b8b0bd757' - }]; - - it('bidRequest method', () => { - const request = spec.buildRequests(bidRequests); - expect(request.method).to.equal('GET'); - }); - - it('bidRequest url', () => { - const request = spec.buildRequests(bidRequests); - expect(request.url).to.match(new RegExp(`${bidRequests[1].params.deliveryUrl}`)); - }); - - it('bidRequest data', () => { - const request = spec.buildRequests(bidRequests); - expect(request.data).to.exist; - }); - - it('bidRequest zoneIds', () => { - const request = spec.buildRequests(bidRequests); - expect(request.data.zoneId).to.equal('aa0444af31;8f527a4835'); - }); - - it('bidRequest gdpr consent', () => { - const consentString = 'consentString'; - const bidderRequest = { - bidderCode: 'trafficroots', - auctionId: '18fd8b8b0bd757', - bidderRequestId: '418b37f85e772c', - timeout: 3000, - gdprConsent: { - consentString: consentString, - gdprApplies: true - } - }; - - const request = spec.buildRequests(bidRequests, bidderRequest); - - expect(request.data.gdpr).to.exist; - expect(request.data.gdpr.applies).to.exist.and.to.be.true; - expect(request.data.gdpr.consent).to.exist.and.to.equal(consentString); - }); - }); - - describe('interpretResponse', () => { - const bidRequest = [{ - 'bidder': 'trafficroots', - 'bidId': '29fa5c08928bde', - 'params': { - 'zoneId': 'aa0444af31', - }, - 'adUnitCode': 'div-gpt-ad-1460505748561-0', - 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', - 'sizes': [[300, 250], [300, 600]], - 'bidderRequestId': '418b37f85e772c', - 'auctionId': '18fd8b8b0bd757' - }]; - - const bidResponse = { - body: [{ - 'id': 'div-gpt-ad-1460505748561-0', - 'ad': 'test ad', - 'width': 320, - 'height': 250, - 'cpm': 5.2 - }], - headers: {} - }; - - it('required keys', () => { - const result = spec.interpretResponse(bidResponse, bidRequest); - - let requiredKeys = [ - 'requestId', - 'creativeId', - 'adId', - 'cpm', - 'width', - 'height', - 'currency', - 'netRevenue', - 'ttl', - 'ad' - ]; - - let resultKeys = Object.keys(result[0]); - resultKeys.forEach(function(key) { - expect(requiredKeys.indexOf(key) !== -1).to.equal(true); - }); - }) - }); -}); diff --git a/test/spec/modules/trionBidAdapter_spec.js b/test/spec/modules/trionBidAdapter_spec.js deleted file mode 100644 index 63c2b71a31a7..000000000000 --- a/test/spec/modules/trionBidAdapter_spec.js +++ /dev/null @@ -1,274 +0,0 @@ -import {expect} from 'chai'; -import * as utils from 'src/utils'; -import {spec, acceptPostMessage, getStorageData, setStorageData} from 'modules/trionBidAdapter'; -const CONSTANTS = require('src/constants.json'); -const adloader = require('src/adloader'); - -const PLACEMENT_CODE = 'ad-tag'; -const BID_REQUEST_BASE_URL = 'https://in-appadvertising.com/api/bidRequest'; - -const TRION_BID = { - bidder: 'trion', - params: { - pubId: '1', - sectionId: '2' - }, - adUnitCode: 'adunit-code', - sizes: [[300, 250], [300, 600]], - bidId: 'test-bid-id', - bidRequest: 'test-bid-request' -}; - -const TRION_BID_REQUEST = [TRION_BID]; - -const TRION_BID_RESPONSE = { - bidId: 'test-bid-id', - sizes: [[300, 250], [300, 600]], - result: { - cpm: 100, - placeBid: true, - height: '250', - width: '300', - ad: 'test', - msg: 'response messaging' - } - -}; - -describe('Trion adapter tests', function () { - let adapter; - - beforeEach(function () { - // adapter = trionAdapter.createNew(); - sinon.stub(document.body, 'appendChild'); - }); - - afterEach(function () { - document.body.appendChild.restore(); - }); - - describe('isBidRequestValid', function () { - it('should return true with correct params', function () { - expect(spec.isBidRequestValid(TRION_BID)).to.equal(true); - }); - - it('should return false when params are missing', function () { - TRION_BID.params = {}; - - expect(spec.isBidRequestValid(TRION_BID)).to.equal(false); - TRION_BID.params = { - pubId: '1', - sectionId: '2' - }; - }); - - it('should return false when pubId is missing', function () { - TRION_BID.params = { - sectionId: '2' - }; - - expect(spec.isBidRequestValid(TRION_BID)).to.equal(false); - TRION_BID.params = { - pubId: '1', - sectionId: '2' - }; - }); - - it('should return false when sectionId is missing', function () { - TRION_BID.params = { - pubId: '1' - }; - - expect(spec.isBidRequestValid(TRION_BID)).to.equal(false); - TRION_BID.params = { - pubId: '1', - sectionId: '2' - }; - }); - }); - - describe('buildRequests', function () { - it('should return bids requests with empty params', function () { - let bidRequests = spec.buildRequests([]); - expect(bidRequests.length).to.equal(0); - }); - - it('should include the base bidrequest url', function () { - let bidRequests = spec.buildRequests(TRION_BID_REQUEST); - - let bidUrl = bidRequests[0].url; - expect(bidUrl).to.include(BID_REQUEST_BASE_URL); - }); - - it('should call buildRequests with the correct required params', function () { - let bidRequests = spec.buildRequests(TRION_BID_REQUEST); - - let bidUrlParams = bidRequests[0].data; - expect(bidUrlParams).to.include('pubId=1'); - expect(bidUrlParams).to.include('sectionId=2'); - expect(bidUrlParams).to.include('sizes=300x250,300x600'); - }); - - it('should call buildRequests with the correct optional params', function () { - let params = TRION_BID_REQUEST[0].params; - params.re = 1; - let bidRequests = spec.buildRequests(TRION_BID_REQUEST); - - let bidUrlParams = bidRequests[0].data; - expect(bidUrlParams).to.include('re=1'); - expect(bidUrlParams).to.include(utils.getTopWindowUrl()); - delete params.re; - }); - - describe('webdriver', function () { - let originalWD; - - beforeEach(function () { - originalWD = window.navigator.webdriver; - window.navigator['__defineGetter__']('webdriver', function () { - return 1; - }); - }); - - afterEach(function () { - window.navigator['__defineGetter__']('webdriver', function () { - return originalWD; - }); - }); - - it('should send the correct state when there is non human traffic', function () { - let bidRequests = spec.buildRequests(TRION_BID_REQUEST); - let bidUrlParams = bidRequests[0].data; - expect(bidUrlParams).to.include('tr_wd=1'); - }); - }); - - describe('visibility', function () { - let originalHD; - let originalVS; - - beforeEach(function () { - originalHD = document.hidden; - originalVS = document.visibilityState; - document['__defineGetter__']('hidden', function () { - return 1; - }); - document['__defineGetter__']('visibilityState', function () { - return 'hidden'; - }); - }); - - afterEach(function () { - document['__defineGetter__']('hidden', function () { - return originalHD; - }); - document['__defineGetter__']('visibilityState', function () { - return originalVS; - }); - }); - - it('should send the correct states when the document is not visible', function () { - let bidRequests = spec.buildRequests(TRION_BID_REQUEST); - let bidUrlParams = bidRequests[0].data; - expect(bidUrlParams).to.include('tr_hd=1'); - expect(bidUrlParams).to.include('tr_vs=hidden'); - }); - }); - }); - - describe('interpretResponse', function () { - it('when there is no response do not bid', function () { - let response = spec.interpretResponse(null, {bidRequest: TRION_BID}); - expect(response).to.deep.equal([]); - }); - - it('when place bid is returned as false', function () { - TRION_BID_RESPONSE.result.placeBid = false; - let response = spec.interpretResponse({body: TRION_BID_RESPONSE}, {bidRequest: TRION_BID}); - - expect(response).to.deep.equal([]); - - TRION_BID_RESPONSE.result.placeBid = true; - }); - - it('when no cpm is in the response', function () { - TRION_BID_RESPONSE.result.cpm = 0; - let response = spec.interpretResponse({body: TRION_BID_RESPONSE}, {bidRequest: TRION_BID}); - expect(response).to.deep.equal([]); - TRION_BID_RESPONSE.result.cpm = 1; - }); - - it('when no ad is in the response', function () { - TRION_BID_RESPONSE.result.ad = null; - let response = spec.interpretResponse({body: TRION_BID_RESPONSE}, {bidRequest: TRION_BID}); - expect(response).to.deep.equal([]); - TRION_BID_RESPONSE.result.ad = 'test'; - }); - - it('height and width are appropriately set', function () { - let bidWidth = '1'; - let bidHeight = '2'; - TRION_BID_RESPONSE.result.width = bidWidth; - TRION_BID_RESPONSE.result.height = bidHeight; - let response = spec.interpretResponse({body: TRION_BID_RESPONSE}, {bidRequest: TRION_BID}); - expect(response[0].width).to.equal(bidWidth); - expect(response[0].height).to.equal(bidHeight); - TRION_BID_RESPONSE.result.width = '300'; - TRION_BID_RESPONSE.result.height = '250'; - }); - - it('cpm is properly set and transformed to cents', function () { - let bidCpm = 2; - TRION_BID_RESPONSE.result.cpm = bidCpm * 100; - let response = spec.interpretResponse({body: TRION_BID_RESPONSE}, {bidRequest: TRION_BID}); - expect(response[0].cpm).to.equal(bidCpm); - TRION_BID_RESPONSE.result.cpm = 100; - }); - }); - - describe('getUserSyncs', function () { - const USER_SYNC_URL = 'https://in-appadvertising.com/api/userSync.html'; - const BASE_KEY = '_trion_'; - - beforeEach(function () { - delete window.TR_INT_T; - }); - - it('trion int is included in bid url', function () { - window.TR_INT_T = 'test_user_sync'; - let userTag = encodeURIComponent(window.TR_INT_T); - let bidRequests = spec.buildRequests(TRION_BID_REQUEST); - let bidUrlParams = bidRequests[0].data; - - expect(bidUrlParams).to.include(userTag); - }); - - it('should register trion user script', function () { - let syncs = spec.getUserSyncs({iframeEnabled: true}); - let url = utils.getTopWindowUrl(); - let pubId = 1; - let sectionId = 2; - let syncString = `?p=${pubId}&s=${sectionId}&u=${url}`; - expect(syncs[0]).to.deep.equal({type: 'iframe', url: USER_SYNC_URL + syncString}); - }); - - it('should except posted messages from user sync script', function () { - let testId = 'testId'; - let message = BASE_KEY + 'userId=' + testId; - setStorageData(BASE_KEY + 'int_t', null); - acceptPostMessage({data: message}); - let newKey = getStorageData(BASE_KEY + 'int_t'); - expect(newKey).to.equal(testId); - }); - - it('should not try to post messages not from trion', function () { - let testId = 'testId'; - let badId = 'badId'; - let message = 'Not Trion: userId=' + testId; - setStorageData(BASE_KEY + 'int_t', badId); - acceptPostMessage({data: message}); - let newKey = getStorageData(BASE_KEY + 'int_t'); - expect(newKey).to.equal(badId); - }); - }); -}); diff --git a/test/spec/modules/tripleliftBidAdapter_spec.js b/test/spec/modules/tripleliftBidAdapter_spec.js index aee4c4d25861..76c549c98ab5 100644 --- a/test/spec/modules/tripleliftBidAdapter_spec.js +++ b/test/spec/modules/tripleliftBidAdapter_spec.js @@ -105,7 +105,7 @@ describe('triplelift adapter', function () { } ], refererInfo: { - referer: 'http://examplereferer.com' + referer: 'https://examplereferer.com' }, gdprConsent: { consentString: GDPR_CONSENT_STR, @@ -279,7 +279,7 @@ describe('triplelift adapter', function () { } ], refererInfo: { - referer: 'http://examplereferer.com' + referer: 'https://examplereferer.com' }, gdprConsent: { consentString: GDPR_CONSENT_STR, @@ -353,7 +353,7 @@ describe('triplelift adapter', function () { } ], refererInfo: { - referer: 'http://examplereferer.com' + referer: 'https://examplereferer.com' }, gdprConsent: { consentString: GDPR_CONSENT_STR, diff --git a/test/spec/modules/trustxBidAdapter_spec.js b/test/spec/modules/trustxBidAdapter_spec.js index aee6311cb857..bf9c0d9c895b 100644 --- a/test/spec/modules/trustxBidAdapter_spec.js +++ b/test/spec/modules/trustxBidAdapter_spec.js @@ -50,7 +50,7 @@ describe('TrustXAdapter', function () { const bidderRequest = { refererInfo: { - referer: 'http://example.com' + referer: 'https://example.com' } }; const referrer = bidderRequest.refererInfo.referer; @@ -792,12 +792,12 @@ describe('TrustXAdapter', function () { expect(spyRendererInstall.calledTwice).to.equal(true); expect(spyRendererInstall.getCall(0).args[0]).to.deep.equal({ id: 'e6e65553fc8', - url: '//acdn.adnxs.com/video/outstream/ANOutstreamVideo.js', + url: 'https://acdn.adnxs.com/video/outstream/ANOutstreamVideo.js', loaded: false }); expect(spyRendererInstall.getCall(1).args[0]).to.deep.equal({ id: 'c8fdcb3f269f', - url: '//acdn.adnxs.com/video/outstream/ANOutstreamVideo.js', + url: 'https://acdn.adnxs.com/video/outstream/ANOutstreamVideo.js', loaded: false }); diff --git a/test/spec/modules/turktelekomBidAdapter_spec.js b/test/spec/modules/turktelekomBidAdapter_spec.js index 066d2724a978..e591da905630 100644 --- a/test/spec/modules/turktelekomBidAdapter_spec.js +++ b/test/spec/modules/turktelekomBidAdapter_spec.js @@ -50,7 +50,7 @@ describe('TurkTelekomAdapter', function () { const bidderRequest = { refererInfo: { - referer: 'http://example.com' + referer: 'https://example.com' } }; const referrer = bidderRequest.refererInfo.referer; @@ -735,12 +735,12 @@ describe('TurkTelekomAdapter', function () { expect(spyRendererInstall.calledTwice).to.equal(true); expect(spyRendererInstall.getCall(0).args[0]).to.deep.equal({ id: 'e6e65553fc8', - url: '//acdn.adnxs.com/video/outstream/ANOutstreamVideo.js', + url: 'https://acdn.adnxs.com/video/outstream/ANOutstreamVideo.js', loaded: false }); expect(spyRendererInstall.getCall(1).args[0]).to.deep.equal({ id: 'c8fdcb3f269f', - url: '//acdn.adnxs.com/video/outstream/ANOutstreamVideo.js', + url: 'https://acdn.adnxs.com/video/outstream/ANOutstreamVideo.js', loaded: false }); diff --git a/test/spec/modules/ucfunnelBidAdapter_spec.js b/test/spec/modules/ucfunnelBidAdapter_spec.js deleted file mode 100644 index bebd780a5870..000000000000 --- a/test/spec/modules/ucfunnelBidAdapter_spec.js +++ /dev/null @@ -1,243 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/ucfunnelBidAdapter'; -import {BANNER, VIDEO, NATIVE} from 'src/mediaTypes'; - -const URL = '//hb.aralego.com/header'; -const BIDDER_CODE = 'ucfunnel'; -const validBannerBidReq = { - bidder: BIDDER_CODE, - params: { - adid: 'ad-34BBD2AA24B678BBFD4E7B9EE3B872D', - bidfloor: 1.0 - }, - sizes: [[300, 250]], - bidId: '263be71e91dd9d', - auctionId: '9ad1fa8d-2297-4660-a018-b39945054746', - 'schain': { - 'ver': '1.0', - 'complete': 1, - 'nodes': [ - { - 'asi': 'exchange1.com', - 'sid': '1234', - 'hp': 1, - 'rid': 'bid-request-1', - 'name': 'publisher', - 'domain': 'publisher.com' - } - ] - } -}; - -const invalidBannerBidReq = { - bidder: BIDDER_CODE, - params: { - adid: 123456789 - }, - sizes: [[300, 250]], - bidId: '263be71e91dd9d', - auctionId: '9ad1fa8d-2297-4660-a018-b39945054746' -}; - -const validBannerBidRes = { - creative_type: BANNER, - ad_id: 'ad-34BBD2AA24B678BBFD4E7B9EE3B872D', - adm: '
', - cpm: 1.01, - height: 250, - width: 300 -}; - -const invalidBannerBidRes = ''; - -const validVideoBidReq = { - bidder: BIDDER_CODE, - params: { - adid: 'ad-9A22D466494297EAC443D967B2622DA9' - }, - sizes: [[640, 360]], - bidId: '263be71e91dd9f', - auctionId: '9ad1fa8d-2297-4660-a018-b39945054746', -}; - -const validVideoBidRes = { - creative_type: VIDEO, - ad_id: 'ad-9A22D466494297EAC443D967B2622DA9', - vastUrl: 'https://ads.aralego.com/ads/58f9749f-0553-4993-8d9a-013a38b29e55', - vastXml: 'ucX I-Primo 00:00:30', - cpm: 1.01, - width: 640, - height: 360 -}; - -const validNativeBidReq = { - bidder: BIDDER_CODE, - params: { - adid: 'ad-627736446B2BD3A60E8AEABDB7BD833E' - }, - sizes: [[1, 1]], - bidId: '263be71e91dda0', - auctionId: '9ad1fa8d-2297-4660-a018-b39945054746', -}; - -const validNativeBidRes = { - creative_type: NATIVE, - ad_id: 'ad-9A22D466494297EAC443D967B2622DA9', - native: { - title: 'ucfunnel adExchange', - body: 'We monetize your traffic via historic data driven protocol', - cta: 'Learn more', - sponsoredBy: 'ucfunnel Co., Ltd.', - image: { - url: 'https://cdn.aralego.net/img/main/AdGent-1200x627.jpg', - width: 1200, - height: 627 - }, - icon: { - url: 'https://cdn.aralego.net/img/logo/logo-84x84.jpg', - widt: 84, - heigh: 84 - }, - clickUrl: 'https://www.ucfunnel.com', - impressionTrackers: ['https://www.aralego.net/imp?mf=native&adid=ad-9A22D466494297EAC443D967B2622DA9&auc=9ad1fa8d-2297-4660-a018-b39945054746'], - }, - cpm: 1.01, - height: 1, - width: 1 -}; - -describe('ucfunnel Adapter', function () { - describe('request', function () { - it('should validate bid request', function () { - expect(spec.isBidRequestValid(validBannerBidReq)).to.equal(true); - }); - it('should not validate incorrect bid request', function () { - expect(spec.isBidRequestValid(invalidBannerBidReq)).to.equal(false); - }); - }); - describe('build request', function () { - const request = spec.buildRequests([validBannerBidReq]); - it('should create a POST request for every bid', function () { - expect(request[0].method).to.equal('GET'); - expect(request[0].url).to.equal(location.protocol + spec.ENDPOINT); - }); - - it('should attach the bid request object', function () { - expect(request[0].bidRequest).to.equal(validBannerBidReq); - }); - - it('should attach request data', function () { - const data = request[0].data; - const [ width, height ] = validBannerBidReq.sizes[0]; - expect(data.w).to.equal(width); - expect(data.h).to.equal(height); - expect(data.schain).to.equal('1.0,1!exchange1.com,1234,1,bid-request-1,publisher,publisher.com'); - }); - - it('must parse bid size from a nested array', function () { - const width = 640; - const height = 480; - validBannerBidReq.sizes = [[ width, height ]]; - const requests = spec.buildRequests([ validBannerBidReq ]); - const data = requests[0].data; - expect(data.w).to.equal(width); - expect(data.h).to.equal(height); - }); - }); - - describe('interpretResponse', function () { - describe('should support banner', function () { - const request = spec.buildRequests([ validBannerBidReq ]); - const result = spec.interpretResponse({body: validBannerBidRes}, request[0]); - it('should build bid array for banner', function () { - expect(result.length).to.equal(1); - }); - - it('should have all relevant fields', function () { - const bid = result[0]; - - expect(bid.mediaType).to.equal(BANNER); - expect(bid.ad).to.exist; - expect(bid.requestId).to.equal('263be71e91dd9d'); - expect(bid.cpm).to.equal(1.01); - expect(bid.width).to.equal(300); - expect(bid.height).to.equal(250); - }); - }); - - describe('handle banner no ad', function () { - const request = spec.buildRequests([ validBannerBidReq ]); - const result = spec.interpretResponse({body: invalidBannerBidRes}, request[0]); - it('should build bid array for banner', function () { - expect(result.length).to.equal(1); - }); - - it('should have all relevant fields', function () { - const bid = result[0]; - - expect(bid.ad).to.exist; - expect(bid.requestId).to.equal('263be71e91dd9d'); - expect(bid.cpm).to.equal(0); - expect(bid.width).to.equal(300); - expect(bid.height).to.equal(250); - }); - }); - - describe('handle banner cpm under bidfloor', function () { - const request = spec.buildRequests([ validBannerBidReq ]); - const result = spec.interpretResponse({body: invalidBannerBidRes}, request[0]); - it('should build bid array for banner', function () { - expect(result.length).to.equal(1); - }); - - it('should have all relevant fields', function () { - const bid = result[0]; - - expect(bid.ad).to.exist; - expect(bid.requestId).to.equal('263be71e91dd9d'); - expect(bid.cpm).to.equal(0); - expect(bid.width).to.equal(300); - expect(bid.height).to.equal(250); - }); - }); - - describe('should support video', function () { - const request = spec.buildRequests([ validVideoBidReq ]); - const result = spec.interpretResponse({body: validVideoBidRes}, request[0]); - it('should build bid array', function () { - expect(result.length).to.equal(1); - }); - - it('should have all relevant fields', function () { - const bid = result[0]; - - expect(bid.mediaType).to.equal(VIDEO); - expect(bid.vastUrl).to.exist; - expect(bid.vastXml).to.exist; - expect(bid.requestId).to.equal('263be71e91dd9f'); - expect(bid.cpm).to.equal(1.01); - expect(bid.width).to.equal(640); - expect(bid.height).to.equal(360); - }); - }); - - describe('should support native', function () { - const request = spec.buildRequests([ validNativeBidReq ]); - const result = spec.interpretResponse({body: validNativeBidRes}, request[0]); - it('should build bid array', function () { - expect(result.length).to.equal(1); - }); - - it('should have all relevant fields', function () { - const bid = result[0]; - - expect(bid.mediaType).to.equal(NATIVE); - expect(bid.native).to.exist; - expect(bid.requestId).to.equal('263be71e91dda0'); - expect(bid.cpm).to.equal(1.01); - expect(bid.width).to.equal(1); - expect(bid.height).to.equal(1); - }); - }); - }); -}); diff --git a/test/spec/modules/undertoneBidAdapter_spec.js b/test/spec/modules/undertoneBidAdapter_spec.js index 676f27146932..7e8084dcb0ca 100644 --- a/test/spec/modules/undertoneBidAdapter_spec.js +++ b/test/spec/modules/undertoneBidAdapter_spec.js @@ -1,7 +1,7 @@ import { expect } from 'chai'; import { spec } from 'modules/undertoneBidAdapter'; -const URL = '//hb.undertone.com/hb'; +const URL = 'https://hb.undertone.com/hb'; const BIDDER_CODE = 'undertone'; const validBidReq = { bidder: BIDDER_CODE, @@ -218,7 +218,7 @@ describe('Undertone Adapter', function () { arguments: [{ iframeEnabled: true, pixelEnabled: true }, {}, null], expect: { type: 'iframe', - pixels: ['//cdn.undertone.com/js/usersync.html'] + pixels: ['https://cdn.undertone.com/js/usersync.html'] } }, { @@ -226,7 +226,7 @@ describe('Undertone Adapter', function () { arguments: [{ iframeEnabled: true, pixelEnabled: true }, {}, {gdprApplies: true, consentString: '234234'}], expect: { type: 'iframe', - pixels: ['//cdn.undertone.com/js/usersync.html?gdpr=1&gdprstr=234234'] + pixels: ['https://cdn.undertone.com/js/usersync.html?gdpr=1&gdprstr=234234'] } }, { @@ -234,7 +234,7 @@ describe('Undertone Adapter', function () { arguments: [{ iframeEnabled: true, pixelEnabled: true }, {}, {gdprApplies: false}], expect: { type: 'iframe', - pixels: ['//cdn.undertone.com/js/usersync.html?gdpr=0&gdprstr='] + pixels: ['https://cdn.undertone.com/js/usersync.html?gdpr=0&gdprstr='] } }, { @@ -242,8 +242,8 @@ describe('Undertone Adapter', function () { arguments: [{ pixelEnabled: true }, {}, null], expect: { type: 'image', - pixels: ['//usr.undertone.com/userPixel/syncOne?id=1&of=2', - '//usr.undertone.com/userPixel/syncOne?id=2&of=2'] + pixels: ['https://usr.undertone.com/userPixel/syncOne?id=1&of=2', + 'https://usr.undertone.com/userPixel/syncOne?id=2&of=2'] } }, { @@ -251,8 +251,8 @@ describe('Undertone Adapter', function () { arguments: [{ pixelEnabled: true }, {}, {gdprApplies: true, consentString: '234234'}], expect: { type: 'image', - pixels: ['//usr.undertone.com/userPixel/syncOne?id=1&of=2&gdpr=1&gdprstr=234234', - '//usr.undertone.com/userPixel/syncOne?id=2&of=2&gdpr=1&gdprstr=234234'] + pixels: ['https://usr.undertone.com/userPixel/syncOne?id=1&of=2&gdpr=1&gdprstr=234234', + 'https://usr.undertone.com/userPixel/syncOne?id=2&of=2&gdpr=1&gdprstr=234234'] } }, { @@ -260,8 +260,8 @@ describe('Undertone Adapter', function () { arguments: [{ pixelEnabled: true }, {}, {gdprApplies: false}], expect: { type: 'image', - pixels: ['//usr.undertone.com/userPixel/syncOne?id=1&of=2&gdpr=0&gdprstr=', - '//usr.undertone.com/userPixel/syncOne?id=2&of=2&gdpr=0&gdprstr='] + pixels: ['https://usr.undertone.com/userPixel/syncOne?id=1&of=2&gdpr=0&gdprstr=', + 'https://usr.undertone.com/userPixel/syncOne?id=2&of=2&gdpr=0&gdprstr='] } } ]; diff --git a/test/spec/modules/unrulyBidAdapter_spec.js b/test/spec/modules/unrulyBidAdapter_spec.js index cb30fcf1a9d6..3cab4d865917 100644 --- a/test/spec/modules/unrulyBidAdapter_spec.js +++ b/test/spec/modules/unrulyBidAdapter_spec.js @@ -11,7 +11,7 @@ describe('UnrulyAdapter', function () { adUnitCode = 'placement2', statusCode = 1, bidId = 'foo', - vastUrl = 'https://targeting.unrulymedia.com/in_article?uuid=74544e00-d43b-4f3a-a799-69d22ce979ce&supported_mime_type=application/javascript&supported_mime_type=video/mp4&tj=%7B%22site%22%3A%7B%22lang%22%3A%22en-GB%22%2C%22ref%22%3A%22%22%2C%22page%22%3A%22http%3A%2F%2Fdemo.unrulymedia.com%2FinArticle%2Finarticle_nypost_upbeat%2Ftravel_magazines.html%22%2C%22domain%22%3A%22demo.unrulymedia.com%22%7D%2C%22user%22%3A%7B%22profile%22%3A%7B%22quantcast%22%3A%7B%22segments%22%3A%5B%7B%22id%22%3A%22D%22%7D%2C%7B%22id%22%3A%22T%22%7D%5D%7D%7D%7D%7D&video_width=618&video_height=347' + vastUrl = 'https://targeting.unrulymedia.com/in_article?uuid=74544e00-d43b-4f3a-a799-69d22ce979ce&supported_mime_type=application/javascript&supported_mime_type=video/mp4&tj=%7B%22site%22%3A%7B%22lang%22%3A%22en-GB%22%2C%22ref%22%3A%22%22%2C%22page%22%3A%22https%3A%2F%2Fdemo.unrulymedia.com%2FinArticle%2Finarticle_nypost_upbeat%2Ftravel_magazines.html%22%2C%22domain%22%3A%22demo.unrulymedia.com%22%7D%2C%22user%22%3A%7B%22profile%22%3A%7B%22quantcast%22%3A%7B%22segments%22%3A%5B%7B%22id%22%3A%22D%22%7D%2C%7B%22id%22%3A%22T%22%7D%5D%7D%7D%7D%7D&video_width=618&video_height=347' }) { return { 'ext': { @@ -144,7 +144,7 @@ describe('UnrulyAdapter', function () { cpm: 20, width: 323, height: 323, - vastUrl: 'https://targeting.unrulymedia.com/in_article?uuid=74544e00-d43b-4f3a-a799-69d22ce979ce&supported_mime_type=application/javascript&supported_mime_type=video/mp4&tj=%7B%22site%22%3A%7B%22lang%22%3A%22en-GB%22%2C%22ref%22%3A%22%22%2C%22page%22%3A%22http%3A%2F%2Fdemo.unrulymedia.com%2FinArticle%2Finarticle_nypost_upbeat%2Ftravel_magazines.html%22%2C%22domain%22%3A%22demo.unrulymedia.com%22%7D%2C%22user%22%3A%7B%22profile%22%3A%7B%22quantcast%22%3A%7B%22segments%22%3A%5B%7B%22id%22%3A%22D%22%7D%2C%7B%22id%22%3A%22T%22%7D%5D%7D%7D%7D%7D&video_width=618&video_height=347', + vastUrl: 'https://targeting.unrulymedia.com/in_article?uuid=74544e00-d43b-4f3a-a799-69d22ce979ce&supported_mime_type=application/javascript&supported_mime_type=video/mp4&tj=%7B%22site%22%3A%7B%22lang%22%3A%22en-GB%22%2C%22ref%22%3A%22%22%2C%22page%22%3A%22https%3A%2F%2Fdemo.unrulymedia.com%2FinArticle%2Finarticle_nypost_upbeat%2Ftravel_magazines.html%22%2C%22domain%22%3A%22demo.unrulymedia.com%22%7D%2C%22user%22%3A%7B%22profile%22%3A%7B%22quantcast%22%3A%7B%22segments%22%3A%5B%7B%22id%22%3A%22D%22%7D%2C%7B%22id%22%3A%22T%22%7D%5D%7D%7D%7D%7D&video_width=618&video_height=347', netRevenue: true, creativeId: 'mockBidId', ttl: 360, diff --git a/test/spec/modules/uolBidAdapter_spec.js b/test/spec/modules/uolBidAdapter_spec.js deleted file mode 100644 index e9341772e7d9..000000000000 --- a/test/spec/modules/uolBidAdapter_spec.js +++ /dev/null @@ -1,308 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/uolBidAdapter'; - -const ENDPOINT = 'https://prebid.adilligo.com/v1/prebid.json'; - -describe('UOL Bid Adapter', function () { - let sandbox; - let queryStub; - let getCurrentPositionStub; - - beforeEach(function() { - sandbox = sinon.sandbox.create(); - }); - - afterEach(function() { - sandbox.restore(); - }); - - describe('isBidRequestValid', function () { - let bid = { - 'bidder': 'uol', - 'params': { - 'placementId': '19571273' - }, - 'adUnitCode': '/uol/unit/code', - 'sizes': [[300, 250], [970, 250]], - 'bidId': '3ddb6ed2d73b45', - 'bidderRequestId': 'd2b12f9d2bad975b7', - 'auctionId': 'eb511c63-df7e-4240-9b65-2f8ae50303e4', - }; - - it('should return true for valid params', function () { - let clonedBid = Object.assign({}, bid); - expect(spec.isBidRequestValid(clonedBid)).to.equal(true); - - delete clonedBid.params; - clonedBid.params = { - 'placementId': '19571277', - 'test': 'true' - } - expect(spec.isBidRequestValid(clonedBid)).to.equal(true); - - delete clonedBid.params; - clonedBid.params = { - 'placementId': '19571278', - 'test': 'true', - 'cpmFactor': 2 - } - expect(spec.isBidRequestValid(clonedBid)).to.equal(true); - }); - - it('should return false when required params are not passed', function () { - let clonedBid = Object.assign({}, bid); - delete clonedBid.params; - expect(spec.isBidRequestValid(clonedBid)).to.equal(false); - }); - - it('should return false when params are invalid', function () { - let clonedBid = Object.assign({}, bid); - delete clonedBid.params; - clonedBid.params = { - 'placementId': 0 - } - expect(spec.isBidRequestValid(clonedBid)).to.equal(false); - - delete clonedBid.params; - clonedBid.params = { - 'placementId': '19571281', - 'cpmFactor': 2 - } - expect(spec.isBidRequestValid(clonedBid)).to.equal(false); - - delete clonedBid.params; - clonedBid.params = { - 'placementId': '19571282', - 'cpmFactor': 'two' - } - expect(spec.isBidRequestValid(clonedBid)).to.equal(false); - }); - - it('should return false when cpmFactor is passed and test flag isn\'t active', function () { - let clonedBid = Object.assign({}, bid); - delete clonedBid.params; - clonedBid.params = { - 'placementId': '19571283', - 'test': false, - 'cpmFactor': 2 - }; - expect(spec.isBidRequestValid(clonedBid)).to.equal(false); - }); - - it('should not allow empty size', function () { - let clonedBid = Object.assign({}, bid); - delete clonedBid.sizes; - expect(spec.isBidRequestValid(clonedBid)).to.equal(false); - }); - }); - - describe('buildRequests', function () { - let bidRequests = [ - { - 'bidder': 'uol', - 'params': { - 'placementId': '19571273' - }, - 'adUnitCode': '/uol/unit/code', - 'sizes': [[300, 250]], - 'bidId': '3ddb6ed2d73b45', - 'bidderRequestId': 'd2b12f9d2bad975b7', - 'auctionId': 'eb511c63-df7e-4240-9b65-2f8ae50303e4', - }, { - 'bidder': 'uol', - 'params': { - 'placementId': '19571274' - }, - 'adUnitCode': '/uol/unit/code2', - 'sizes': [[300, 600], [970, 250]], - 'bidId': '3a3ea8e80a2dc5', - 'bidderRequestId': 'd2b12f9d2bad975b7', - 'auctionId': 'eb511c63-df7e-4240-9b65-2f8ae50303e4', - } - ]; - - let bidderRequest = { - 'auctionId': 'eb511c63-df7e-4240-9b65-2f8ae50303e4', - 'auctionStart': 1530133180799, - 'bidderCode': 'uol', - 'bidderRequestId': 'd2b12f9d2bad975b7', - 'bids': bidRequests, - 'doneCbCallCount': 1, - 'start': 1530133180801, - 'timeout': 3000 - }; - - describe('buildRequest basic params', function () { - const requestObject = spec.buildRequests(bidRequests, bidderRequest); - const payload = JSON.parse(requestObject.data); - - it('should send bid requests to expected endpoint via POST method', function () { - expect(requestObject.url).to.equal(ENDPOINT); - expect(requestObject.method).to.equal('POST'); - }); - - it('should contain referrer URL', function () { - expect(payload.referrerURL).to.exist.and.to.match(/^http(s)?:\/\/.+$/) - }); - - it('should contain an array of requests with length equivalent to bid count', function () { - expect(payload.requests).to.have.length(bidRequests.length); - }); - it('should return propper ad size if at least one entry is provided', function () { - expect(payload.requests[0].sizes).to.deep.equal(bidRequests[0].sizes); - }); - }); - - if (navigator.permissions && navigator.permissions.query && navigator.geolocation) { - describe('buildRequest geolocation param', function () { // shall only be tested if browser engine supports geolocation and permissions API. - let geolocation = { lat: 4, long: 3, timestamp: 123121451 }; - - beforeEach(function() { - getCurrentPositionStub = sandbox.stub(navigator.geolocation, 'getCurrentPosition'); - queryStub = sandbox.stub(navigator.permissions, 'query'); - }); - - it('should not contain user coordinates if browser doesnt support permission query', function () { - localStorage.setItem('uolLocationTracker', JSON.stringify(geolocation)); - navigator.permissions.query = undefined; - const requestObject = spec.buildRequests(bidRequests, bidderRequest); - const payload = JSON.parse(requestObject.data); - expect(payload.geolocation).to.not.exist; - }) - - it('should contain user coordinates if (i) DNT is off; (ii) browser supports implementation; (iii) localStorage contains geolocation history', function (done) { - localStorage.setItem('uolLocationTracker', JSON.stringify(geolocation)); - queryStub.callsFake(function() { - return new Promise((resolve, reject) => { - resolve({state: 'granted'}); - }); - }); - getCurrentPositionStub.callsFake(() => done()); - const requestObject = spec.buildRequests(bidRequests, bidderRequest); - const payload = JSON.parse(requestObject.data); - expect(payload.geolocation).to.exist.and.not.be.empty; - }) - - it('should not contain user coordinates if localStorage is empty', function () { - localStorage.removeItem('uolLocationTracker'); - queryStub.callsFake(function() { - return new Promise((resolve, reject) => { - resolve({state: 'prompt'}); - }); - }); - const requestObject = spec.buildRequests(bidRequests, bidderRequest); - const payload = JSON.parse(requestObject.data); - expect(payload.geolocation).to.not.exist; - }) - }) - } - describe('buildRequest test params', function () { - it('should return test and cpmFactor params if defined', function () { - let clonedBid = JSON.parse(JSON.stringify(bidRequests)); - delete clonedBid[0].params; - clonedBid.splice(1, 1); - clonedBid[0].params = { - 'placementId': '19571277', - 'test': true - } - let requestObject = spec.buildRequests(clonedBid, bidderRequest); - let payload = JSON.parse(requestObject.data); - expect(payload.requests[0].customParams.test).to.exist.and.equal(true); - expect(payload.requests[0].customParams.cpmFactor).to.be.an('undefined'); - - delete clonedBid[0].params; - clonedBid[0].params = { - 'placementId': '19571278', - 'test': true, - 'cpmFactor': 2 - } - requestObject = spec.buildRequests(clonedBid, bidderRequest); - payload = JSON.parse(requestObject.data); - expect(payload.requests[0].customParams.test).to.exist.and.equal(true); - expect(payload.requests[0].customParams.cpmFactor).to.exist.and.equal(2); - }); - }) - }); - - describe('interpretResponse', function () { - let serverResponse = { - 'body': { - 'bidderRequestId': '2a21a2fc993ef9', - 'ads': [{ - 'currency': 'BRL', - 'creativeId': '12334', - 'cpm': 1.9, - 'ttl': 300, - 'netRevenue': false, - 'ad': '', - 'width': 300, - 'height': 250, - 'bidId': '26df49c6447b82', - 'mediaType': 'banner' - }, { - 'currency': 'BRL', - 'creativeId': '12335', - 'cpm': 1.99, - 'ttl': 300, - 'netRevenue': false, - 'ad': '', - 'width': 300, - 'height': 600, - 'bidId': '26df49c6447b82', - 'mediaType': 'banner' - }] - }, - 'headers': {} - }; - let bidRequest = {}; - - it('should return the correct bid response structure', function () { - let expectedResponse = [ - { - 'requestId': '2a21a2fc993ef9', - 'cpm': 1.9, - 'width': 300, - 'height': 250, - 'creativeId': '12335', - 'currency': 'BRL', - 'dealId': null, - 'mediaType': 'banner', - 'netRevenue': false, - 'ttl': 300, - 'ad': '' - } - ]; - let result = spec.interpretResponse(serverResponse, {bidRequest}); - expect(Object.keys(result[0])).to.have.members(Object.keys(expectedResponse[0])); - }); - - it('should corretly return an empty array of bidResponses if no ads were received', function () { - let emptyResponse = Object.assign({}, serverResponse); - emptyResponse.body.ads = []; - let result = spec.interpretResponse(emptyResponse, {bidRequest}); - expect(result.length).to.equal(0); - }); - }); - - describe('getUserSyncs', function () { - let syncOptions = { iframeEnabled: true }; - let serverResponses = [{ body: { trackingPixel: 'https://www.uol.com.br' } }, { body: { trackingPixel: 'http://www.dynad.net/' } }]; - - it('should return the two sync params for iframeEnabled bids with a trackingPixel response', function () { - expect(spec.getUserSyncs(syncOptions, serverResponses)).to.have.length(2); - }) - - it('should not return any sync params if iframe is disabled or no trackingPixel is received', function () { - let cloneOptions = Object.assign({}, syncOptions); - delete cloneOptions.iframeEnabled; - expect(spec.getUserSyncs(cloneOptions, serverResponses)).to.have.length(0); - - let cloneResponses = Object.assign({}, serverResponses); - delete cloneResponses[0].body.trackingPixel; - delete cloneResponses[1].body.trackingPixel; - expect(spec.getUserSyncs(syncOptions, cloneResponses)).to.have.length(0); - - expect(spec.getUserSyncs(cloneOptions, cloneResponses)).to.have.length(0); - }) - }); -}); diff --git a/test/spec/modules/userId_spec.js b/test/spec/modules/userId_spec.js index 40ffb726051c..ed4d565c0993 100644 --- a/test/spec/modules/userId_spec.js +++ b/test/spec/modules/userId_spec.js @@ -10,8 +10,8 @@ import {config} from 'src/config'; import * as utils from 'src/utils'; import events from 'src/events'; import CONSTANTS from 'src/constants.json'; -import {unifiedIdSubmodule} from 'modules/userId/unifiedIdSystem'; -import {pubCommonIdSubmodule} from 'modules/userId/pubCommonIdSystem'; +import {unifiedIdSubmodule} from 'modules/unifiedIdSystem'; +import {pubCommonIdSubmodule} from 'modules/pubCommonIdSystem'; import {britepoolIdSubmodule} from 'modules/britepoolIdSystem'; import {id5IdSubmodule} from 'modules/id5IdSystem'; import {identityLinkSubmodule} from 'modules/identityLinkIdSystem'; diff --git a/test/spec/modules/vertamediaBidAdapter_spec.js b/test/spec/modules/vertamediaBidAdapter_spec.js deleted file mode 100644 index fefa8e446ed8..000000000000 --- a/test/spec/modules/vertamediaBidAdapter_spec.js +++ /dev/null @@ -1,218 +0,0 @@ -import {expect} from 'chai'; -import {spec} from 'modules/vertamediaBidAdapter'; -import {newBidder} from 'src/adapters/bidderFactory'; - -const ENDPOINT = '//hb2.vertamedia.com/auction/'; - -const DISPLAY_REQUEST = { - 'bidder': 'vertamedia', - 'params': { - 'aid': 12345 - }, - 'bidderRequestId': '7101db09af0db2', - 'auctionId': '2e41f65424c87c', - 'adUnitCode': 'adunit-code', - 'bidId': '84ab500420319d', - 'sizes': [300, 250] -}; - -const VIDEO_REQUEST = { - 'bidder': 'vertamedia', - 'mediaTypes': { - 'video': {} - }, - 'params': { - 'aid': 12345 - }, - 'bidderRequestId': '7101db09af0db2', - 'auctionId': '2e41f65424c87c', - 'adUnitCode': 'adunit-code', - 'bidId': '84ab500420319d', - 'sizes': [[480, 360], [640, 480]] -}; - -const SERVER_VIDEO_RESPONSE = { - 'source': {'aid': 12345, 'pubId': 54321}, - 'bids': [{ - 'vastUrl': 'http://rtb.vertamedia.com/vast/?adid=44F2AEB9BFC881B3', - 'requestId': '2e41f65424c87c', - 'url': '44F2AEB9BFC881B3', - 'creative_id': 342516, - 'cmpId': 342516, - 'height': 480, - 'cur': 'USD', - 'width': 640, - 'cpm': 0.9 - } - ] -}; -const SERVER_DISPLAY_RESPONSE = { - 'source': {'aid': 12345, 'pubId': 54321}, - 'bids': [{ - 'ad': '', - 'requestId': '2e41f65424c87c', - 'creative_id': 342516, - 'cmpId': 342516, - 'height': 250, - 'cur': 'USD', - 'width': 300, - 'cpm': 0.9 - }] -}; - -const videoBidderRequest = { - bidderCode: 'bidderCode', - bids: [{mediaTypes: {video: {}}, bidId: '2e41f65424c87c'}] -}; - -const displayBidderRequest = { - bidderCode: 'bidderCode', - bids: [{bidId: '2e41f65424c87c'}] -}; - -const videoEqResponse = [{ - vastUrl: 'http://rtb.vertamedia.com/vast/?adid=44F2AEB9BFC881B3', - requestId: '2e41f65424c87c', - creativeId: 342516, - mediaType: 'video', - netRevenue: true, - currency: 'USD', - height: 480, - width: 640, - ttl: 3600, - cpm: 0.9 -}]; - -const displayEqResponse = [{ - requestId: '2e41f65424c87c', - creativeId: 342516, - mediaType: 'display', - netRevenue: true, - currency: 'USD', - ad: '', - height: 250, - width: 300, - ttl: 3600, - cpm: 0.9 -}]; - -describe('vertamediaBidAdapter', function () { - const adapter = newBidder(spec); - - describe('inherited functions', function () { - it('exists and is a function', function () { - expect(adapter.callBids).to.exist.and.to.be.a('function'); - }); - }); - - describe('isBidRequestValid', function () { - it('should return true when required params found', function () { - expect(spec.isBidRequestValid(VIDEO_REQUEST)).to.equal(12345); - }); - - it('should return false when required params are not passed', function () { - let bid = Object.assign({}, VIDEO_REQUEST); - delete bid.params; - expect(spec.isBidRequestValid(bid)).to.equal(undefined); - }); - }); - - describe('buildRequests', function () { - let videoBidRequests = [VIDEO_REQUEST]; - let dispalyBidRequests = [DISPLAY_REQUEST]; - - const displayRequest = spec.buildRequests(dispalyBidRequests, {}); - const videoRequest = spec.buildRequests(videoBidRequests, {}); - - it('sends bid request to ENDPOINT via GET', function () { - expect(videoRequest.method).to.equal('GET'); - expect(displayRequest.method).to.equal('GET'); - }); - - it('sends bid request to correct ENDPOINT', function () { - expect(videoRequest.url).to.equal(ENDPOINT); - expect(displayRequest.url).to.equal(ENDPOINT); - }); - - it('sends correct video bid parameters', function () { - const bid = Object.assign({}, videoRequest.data); - delete bid.domain; - - const eq = { - callbackId: '84ab500420319d', - ad_type: 'video', - aid: 12345, - sizes: '480x360,640x480' - }; - - expect(bid).to.deep.equal(eq); - }); - - it('sends correct display bid parameters', function () { - const bid = Object.assign({}, displayRequest.data); - delete bid.domain; - - const eq = { - callbackId: '84ab500420319d', - ad_type: 'display', - aid: 12345, - sizes: '300x250' - }; - - expect(bid).to.deep.equal(eq); - }); - }); - - describe('interpretResponse', function () { - let serverResponse; - let bidderRequest; - let eqResponse; - - afterEach(function () { - serverResponse = null; - bidderRequest = null; - eqResponse = null; - }); - - it('should get correct video bid response', function () { - serverResponse = SERVER_VIDEO_RESPONSE; - bidderRequest = videoBidderRequest; - eqResponse = videoEqResponse; - - bidServerResponseCheck(); - }); - - it('should get correct display bid response', function () { - serverResponse = SERVER_DISPLAY_RESPONSE; - bidderRequest = displayBidderRequest; - eqResponse = displayEqResponse; - - bidServerResponseCheck(); - }); - - function bidServerResponseCheck() { - const result = spec.interpretResponse({body: serverResponse}, {bidderRequest}); - - expect(result).to.deep.equal(eqResponse); - } - - function nobidServerResponseCheck() { - const noBidServerResponse = {bids: []}; - const noBidResult = spec.interpretResponse({body: noBidServerResponse}, {bidderRequest}); - - expect(noBidResult.length).to.equal(0); - } - - it('handles video nobid responses', function () { - bidderRequest = videoBidderRequest; - - nobidServerResponseCheck(); - }); - - it('handles display nobid responses', function () { - bidderRequest = displayBidderRequest; - - nobidServerResponseCheck(); - }); - }); -}); diff --git a/test/spec/modules/vertozBidAdapter_spec.js b/test/spec/modules/vertozBidAdapter_spec.js deleted file mode 100644 index 1eb85b6b5668..000000000000 --- a/test/spec/modules/vertozBidAdapter_spec.js +++ /dev/null @@ -1,112 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/vertozBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; - -const BASE_URI = '//hb.vrtzads.com/vzhbidder/bid?'; - -describe('VertozAdapter', function () { - const adapter = newBidder(spec); - - describe('inherited functions', function () { - it('exists and is a function', function () { - expect(adapter.callBids).to.exist.and.to.be.a('function'); - }); - }); - - describe('isBidRequestValid', function () { - let bid = { - 'bidder': 'vertoz', - 'params': { - 'placementId': 'VZ-HB-B784382V6C6G3C' - }, - 'adUnitCode': 'adunit-code', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - }; - - it('should return true when required params found', function () { - expect(spec.isBidRequestValid(bid)).to.equal(true); - }); - - it('should return false when required params are not passed', function () { - let bid = Object.assign({}, bid); - delete bid.params; - bid.params = { - 'placementId': 0 - }; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - }); - - describe('buildRequests', function () { - let bidRequests = [ - { - 'bidder': 'vertoz', - 'params': { - 'placementId': '10433394' - }, - 'adUnitCode': 'adunit-code', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - } - ]; - - it('sends bid request to ENDPOINT via POST', function () { - const request = spec.buildRequests(bidRequests)[0]; - expect(request.url).to.equal(BASE_URI); - expect(request.method).to.equal('POST'); - }); - }); - - describe('interpretResponse', function () { - let response = { - 'vzhPlacementId': 'VZ-HB-B784382V6C6G3C', - 'bid': '76021e56-adaf-4114-b68d-ccacd1b3e551_1', - 'adWidth': '300', - 'adHeight': '250', - 'cpm': '0.16312590000000002', - 'ad': '', - 'slotBidId': '44b3fcfd24aa93', - 'nurl': '', - 'statusText': 'Vertoz:Success' - }; - - it('should get correct bid response', function () { - let expectedResponse = [ - { - 'requestId': '44b3fcfd24aa93', - 'cpm': 0.16312590000000002, - 'width': 300, - 'height': 250, - 'netRevenue': true, - 'mediaType': 'banner', - 'currency': 'USD', - 'dealId': null, - 'creativeId': null, - 'ttl': 300, - 'ad': '' - } - ]; - let bidderRequest; - let result = spec.interpretResponse({body: response}); - expect(Object.keys(result[0])).to.have.members(Object.keys(expectedResponse[0])); - expect(result[0].cpm).to.not.equal(null); - }); - - it('handles nobid responses', function () { - let response = { - 'vzhPlacementId': 'VZ-HB-I617046VBGE3EH', - 'slotBidId': 'f00412ac86b79', - 'statusText': 'NO_BIDS' - }; - let bidderRequest; - - let result = spec.interpretResponse({body: response}); - expect(result.length).to.equal(0); - }); - }); -}); diff --git a/test/spec/modules/vidazooBidAdapter_spec.js b/test/spec/modules/vidazooBidAdapter_spec.js index 3251a1ef8517..c1fd63f599ce 100644 --- a/test/spec/modules/vidazooBidAdapter_spec.js +++ b/test/spec/modules/vidazooBidAdapter_spec.js @@ -25,7 +25,7 @@ const BIDDER_REQUEST = { 'consentString': 'consent_string' }, 'refererInfo': { - 'referer': 'http://www.greatsite.com' + 'referer': 'https://www.greatsite.com' } }; @@ -127,7 +127,7 @@ describe('VidazooBidAdapter', function () { consent: 'consent_string', width: '300', height: '250', - url: 'http%3A%2F%2Fwww.greatsite.com', + url: 'https%3A%2F%2Fwww.greatsite.com', cb: 1000, bidFloor: 0.1, bidId: '2d52001cabd527', @@ -143,7 +143,7 @@ describe('VidazooBidAdapter', function () { consent: 'consent_string', width: '300', height: '600', - url: 'http%3A%2F%2Fwww.greatsite.com', + url: 'https%3A%2F%2Fwww.greatsite.com', cb: 1000, bidFloor: 0.1, bidId: '2d52001cabd527', diff --git a/test/spec/modules/videoNowBidAdapter_spec.js b/test/spec/modules/videoNowBidAdapter_spec.js index 337960c6edd8..f1e5b88272bd 100644 --- a/test/spec/modules/videoNowBidAdapter_spec.js +++ b/test/spec/modules/videoNowBidAdapter_spec.js @@ -18,7 +18,7 @@ const getValidServerResponse = () => { id: 'e3bf2b82e3e9485113fad6c9b27f8768.1', impid: '1', price: 10.97, - nurl: 'http://localhost:8086/event/nurl', + nurl: 'https://localhost:8086/event/nurl', netRevenue: false, ttl: 800, adm: '', @@ -26,10 +26,10 @@ const getValidServerResponse = () => { h: 640, w: 480, ext: { - init: 'http://localhost:8086/vn_init.js', + init: 'https://localhost:8086/vn_init.js', module: { - min: 'http://localhost:8086/vn_module.js', - log: 'http://localhost:8086/vn_module.js?log=1' + min: 'https://localhost:8086/vn_module.js', + log: 'https://localhost:8086/vn_module.js?log=1' }, format: { name: 'flyRoll', @@ -45,12 +45,12 @@ const getValidServerResponse = () => { ext: { placementId, pixels: [ - 'http://localhost:8086/event/pxlcookiematching?uiid=1', - 'http://localhost:8086/event/pxlcookiematching?uiid=2', + 'https://localhost:8086/event/pxlcookiematching?uiid=1', + 'https://localhost:8086/event/pxlcookiematching?uiid=2', ], iframes: [ - 'http://localhost:8086/event/ifrcookiematching?uiid=1', - 'http://localhost:8086/event/ifrcookiematching?uiid=2', + 'https://localhost:8086/event/ifrcookiematching?uiid=1', + 'https://localhost:8086/event/ifrcookiematching?uiid=2', ], }, }, @@ -95,7 +95,7 @@ describe('videonowAdapterTests', function() { params: { pId: '1', placementId, - url: 'http://localhost:8086/bid?p=exists', + url: 'https://localhost:8086/bid?p=exists', bidFloor: 10, cur: 'RUB' }, @@ -128,7 +128,7 @@ describe('videonowAdapterTests', function() { params: { pId: '1', placementId, - url: 'http://localhost:8086/bid', + url: 'https://localhost:8086/bid', bidFloor: 10, cur: 'RUB', }, @@ -153,11 +153,11 @@ describe('videonowAdapterTests', function() { auctionStart: 1565794308584, timeout: 3000, refererInfo: { - referer: 'http://localhost:8086/page', + referer: 'https://localhost:8086/page', reachedTop: true, numIframes: 0, stack: [ - 'http://localhost:8086/page', + 'https://localhost:8086/page', ], }, start: 1565794308589, @@ -175,7 +175,7 @@ describe('videonowAdapterTests', function() { }) it('bidRequest url', function() { - expect(request.url).to.equal('http://localhost:8086/bid?p=exists&profile_id=1') + expect(request.url).to.equal('https://localhost:8086/bid?p=exists&profile_id=1') }) it('bidRequest data', function() { @@ -235,7 +235,7 @@ describe('videonowAdapterTests', function() { describe('onBidWon', function() { const cpm = 10 - const nurl = 'http://fakedomain.nld?price=${AUCTION_PRICE}' + const nurl = 'https://fakedomain.nld?price=${AUCTION_PRICE}' const imgSrc = replaceAuctionPrice(nurl, cpm) const foundPixels = () => window.document.body.querySelectorAll(`img[src="${imgSrc}"]`) @@ -304,14 +304,14 @@ describe('videonowAdapterTests', function() { describe('interpretResponse', function() { const bidRequest = { method: 'POST', - url: 'http://localhost:8086/bid?profile_id=1', + url: 'https://localhost:8086/bid?profile_id=1', data: { id: '217b8ab59a18e8', cpm: 10, sizes: [[640, 480], [320, 200]], cur: 'RUB', placementId, - ref: 'http://localhost:8086/page', + ref: 'https://localhost:8086/page', }, } diff --git a/test/spec/modules/videoreachBidAdapter_spec.js b/test/spec/modules/videoreachBidAdapter_spec.js deleted file mode 100644 index 237821f71026..000000000000 --- a/test/spec/modules/videoreachBidAdapter_spec.js +++ /dev/null @@ -1,141 +0,0 @@ -import {expect} from 'chai'; -import {spec} from 'modules/videoreachBidAdapter'; -import {newBidder} from 'src/adapters/bidderFactory'; - -const ENDPOINT_URL = '//a.videoreach.com/hb/'; - -describe('videoreachBidAdapter', function () { - describe('isBidRequestValid', function () { - let bid = { - 'params': { - 'TagId': 'ABCDE' - }, - 'bidId': '242d506d4e4f15', - 'bidderRequestId': '1893a2136a84a2', - 'auctionId': '8fb7b1c7-317b-4edf-83f0-c4669a318522', - 'transactionId': '85a2e190-0684-4f95-ad32-6c90757ed622' - }; - - it('should return true when required params found', function () { - expect(spec.isBidRequestValid(bid)).to.equal(true); - }); - - it('should return false when required params are not passed', function () { - let bid = Object.assign({}, bid); - delete bid.params; - bid.params = { - 'TagId': '' - }; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - }); - - describe('buildRequests', function () { - let bidRequests = [ - { - 'bidder': 'videoreach', - 'params': { - 'TagId': 'ABCDE' - }, - 'adUnitCode': 'adzone', - 'auctionId': '8fb7b1c7-317b-4edf-83f0-c4669a318522', - 'sizes': [[1, 1]], - 'bidId': '242d506d4e4f15', - 'bidderRequestId': '1893a2136a84a2', - 'transactionId': '85a2e190-0684-4f95-ad32-6c90757ed622', - 'mediaTypes': { - 'banner': { - 'sizes': [1, 1] - }, - } - } - ]; - - it('send bid request to endpoint', function () { - const request = spec.buildRequests(bidRequests); - - expect(request.url).to.equal(ENDPOINT_URL); - expect(request.method).to.equal('POST'); - }); - - it('send bid request with GDPR to endpoint', function () { - let consentString = 'BOEFEAyOEFEAyAHABDENAI4AAAB9vABAASA'; - - let bidderRequest = { - 'gdprConsent': { - 'consentString': consentString, - 'gdprApplies': true - } - }; - - const request = spec.buildRequests(bidRequests, bidderRequest); - const payload = JSON.parse(request.data); - - expect(payload.gdpr.consent_required).to.exist; - expect(payload.gdpr.consent_string).to.equal(consentString); - }); - }); - - describe('interpretResponse', function () { - let serverResponse = - { - 'body': { - 'responses': [{ - 'bidId': '242d506d4e4f15', - 'transactionId': '85a2e190-0684-4f95-ad32-6c90757ed622', - 'cpm': 10.0, - 'width': '1', - 'height': '1', - 'ad': '', - 'ttl': 360, - 'creativeId': '5cb5dc9375c0e', - 'netRevenue': true, - 'currency': 'EUR', - 'sync': ['https:\/\/SYNC_URL'] - }] - } - }; - - it('should handle response', function() { - let expectedResponse = [ - { - cpm: 10.0, - width: '1', - height: '1', - currency: 'EUR', - netRevenue: true, - ttl: 360, - ad: '', - requestId: '242d506d4e4f15', - creativeId: '5cb5dc9375c0e' - } - ]; - - let result = spec.interpretResponse(serverResponse); - expect(Object.keys(result[0])).to.deep.equal(Object.keys(expectedResponse[0])); - }); - - it('should handles empty response', function() { - let serverResponse = { - 'body': { - 'responses': [] - } - }; - - let result = spec.interpretResponse(serverResponse); - expect(result.length).to.equal(0); - }); - - describe('getUserSyncs', () => { - it('should push user sync images if enabled', () => { - const syncOptions = { pixelEnabled: true }; - const syncs = spec.getUserSyncs(syncOptions, [serverResponse]); - - expect(syncs[0]).to.deep.equal({ - type: 'image', - url: 'https://SYNC_URL' - }); - }) - }); - }); -}); diff --git a/test/spec/modules/visxBidAdapter_spec.js b/test/spec/modules/visxBidAdapter_spec.js index 167d54e37a60..b14f5331fd1d 100755 --- a/test/spec/modules/visxBidAdapter_spec.js +++ b/test/spec/modules/visxBidAdapter_spec.js @@ -42,7 +42,7 @@ describe('VisxAdapter', function () { describe('buildRequests', function () { const bidderRequest = { refererInfo: { - referer: 'http://example.com' + referer: 'https://example.com' } }; const referrer = bidderRequest.refererInfo.referer; diff --git a/test/spec/modules/vubleAnalyticsAdapter_spec.js b/test/spec/modules/vubleAnalyticsAdapter_spec.js deleted file mode 100644 index 841a53c6dee4..000000000000 --- a/test/spec/modules/vubleAnalyticsAdapter_spec.js +++ /dev/null @@ -1,122 +0,0 @@ -import vubleAnalytics from 'modules/vubleAnalyticsAdapter'; -import { expect } from 'chai'; -let events = require('src/events'); -let adapterManager = require('src/adapterManager').default; -let constants = require('src/constants.json'); - -describe('Vuble Prebid Analytic', function () { - let xhr; - before(function () { - xhr = sinon.useFakeXMLHttpRequest(); - }); - after(function () { - vubleAnalytics.disableAnalytics(); - xhr.restore(); - }); - - describe('enableAnalytics', function () { - beforeEach(function () { - sinon.spy(vubleAnalytics, 'track'); - sinon.stub(events, 'getEvents').returns([]); - }); - - afterEach(function () { - vubleAnalytics.track.restore(); - events.getEvents.restore(); - }); - it('should catch all events', function () { - adapterManager.registerAnalyticsAdapter({ - code: 'vuble', - adapter: vubleAnalytics - }); - - adapterManager.enableAnalytics({ - provider: 'vuble', - options: { - pubId: 18, - env: 'net' - } - }); - - let auction_id = 'test'; - - // Step 1: Auction init - events.emit(constants.EVENTS.AUCTION_INIT, { - auctionId: auction_id, - timestamp: 1496510254313, - }); - - // Step 2: Bid request - events.emit(constants.EVENTS.BID_REQUESTED, { - auctionId: auction_id, - auctionStart: 1509369418387, - timeout: 3000, - bids: [ - { - bidder: 'vuble', - params: { - env: 'net', - pubId: '3', - zoneId: '12345', - floorPrice: 5.50 // optional - }, - sizes: [[640, 360]], - mediaTypes: { - video: { - context: 'instream' - } - }, - bidId: 'abdc' - }, - { - bidder: 'vuble', - params: { - env: 'com', - pubId: '8', - zoneId: '2468', - referrer: 'http://www.vuble.fr/' - }, - sizes: '640x360', - mediaTypes: { - video: { - context: 'outstream' - } - }, - bidId: 'efgh', - }, - ], - }); - - // Step 3: Bid response - events.emit(constants.EVENTS.BID_RESPONSE, { - width: '640', - height: '360', - pub_id: '3', - dealId: 'aDealId', - zone_id: '12345', - context: 'instream', - floor_price: 5.5, - url: 'http://www.vuble.tv/', - env: 'net', - bid_id: 'abdc' - }); - - // Step 4: Bid won - events.emit(constants.EVENTS.BID_WON, { - adId: 'adIdTestWin', - ad: 'adContentTestWin', - auctionId: auction_id, - width: 640, - height: 360 - }); - - // Step 4: Auction end - events.emit(constants.EVENTS.AUCTION_END, { - auctionId: auction_id - }); - - // Step 5: Check if the number of call is good (5) - sinon.assert.callCount(vubleAnalytics.track, 5); - }); - }); -}); diff --git a/test/spec/modules/weboramaBidAdapter_spec.js b/test/spec/modules/weboramaBidAdapter_spec.js deleted file mode 100644 index d0b119825a67..000000000000 --- a/test/spec/modules/weboramaBidAdapter_spec.js +++ /dev/null @@ -1,118 +0,0 @@ -import {expect} from 'chai'; -import {spec} from '../../../modules/weboramaBidAdapter'; - -describe('WeboramaAdapter', function () { - let bid = { - bidId: '2dd581a2b6281d', - bidder: 'weborama', - bidderRequestId: '145e1d6a7837c9', - params: { - placementId: 123, - traffic: 'banner' - }, - placementCode: 'placement_0', - auctionId: '74f78609-a92d-4cf1-869f-1b244bbfb5d2', - sizes: [[300, 250]], - transactionId: '3bb2f6da-87a6-4029-aeb0-bfe951372e62' - }; - - describe('isBidRequestValid', function () { - it('Should return true when placementId can be cast to a number', function () { - expect(spec.isBidRequestValid(bid)).to.be.true; - }); - it('Should return false when placementId is not a number', function () { - bid.params.placementId = 'aaa'; - expect(spec.isBidRequestValid(bid)).to.be.false; - }); - }); - - describe('buildRequests', function () { - let serverRequest = spec.buildRequests([bid]); - it('Creates a ServerRequest object with method, URL and data', function () { - expect(serverRequest).to.exist; - expect(serverRequest.method).to.exist; - expect(serverRequest.url).to.exist; - expect(serverRequest.data).to.exist; - }); - it('Returns POST method', function () { - expect(serverRequest.method).to.equal('POST'); - }); - it('Returns valid URL', function () { - expect(serverRequest.url).to.equal('//supply.nl.weborama.fr/?c=o&m=multi'); - }); - it('Returns valid data if array of bids is valid', function () { - let data = serverRequest.data; - expect(data).to.be.an('object'); - expect(data).to.have.all.keys('deviceWidth', 'deviceHeight', 'secure', 'host', 'page', 'placements'); - expect(data.deviceWidth).to.be.a('number'); - expect(data.deviceHeight).to.be.a('number'); - expect(data.secure).to.be.within(0, 1); - expect(data.host).to.be.a('string'); - expect(data.page).to.be.a('string'); - let placements = data['placements']; - for (let i = 0; i < placements.length; i++) { - let placement = placements[i]; - expect(placement).to.have.all.keys('placementId', 'bidId', 'traffic', 'sizes'); - expect(placement.placementId).to.be.a('number'); - expect(placement.bidId).to.be.a('string'); - expect(placement.traffic).to.be.a('string'); - expect(placement.sizes).to.be.an('array'); - } - }); - it('Returns empty data if no valid requests are passed', function () { - serverRequest = spec.buildRequests([]); - let data = serverRequest.data; - expect(data.placements).to.be.an('array').that.is.empty; - }); - }); - describe('interpretResponse', function () { - let resObject = { - body: [ { - requestId: '123', - mediaType: 'banner', - cpm: 0.3, - width: 320, - height: 50, - ad: '

Hello ad

', - ttl: 1000, - creativeId: '123asd', - netRevenue: true, - currency: 'USD' - } ] - }; - let serverResponses = spec.interpretResponse(resObject); - it('Returns an array of valid server responses if response object is valid', function () { - expect(serverResponses).to.be.an('array').that.is.not.empty; - for (let i = 0; i < serverResponses.length; i++) { - let dataItem = serverResponses[i]; - expect(dataItem).to.have.all.keys('requestId', 'cpm', 'width', 'height', 'ad', 'ttl', 'creativeId', - 'netRevenue', 'currency', 'mediaType'); - expect(dataItem.requestId).to.be.a('string'); - expect(dataItem.cpm).to.be.a('number'); - expect(dataItem.width).to.be.a('number'); - expect(dataItem.height).to.be.a('number'); - expect(dataItem.ad).to.be.a('string'); - expect(dataItem.ttl).to.be.a('number'); - expect(dataItem.creativeId).to.be.a('string'); - expect(dataItem.netRevenue).to.be.a('boolean'); - expect(dataItem.currency).to.be.a('string'); - expect(dataItem.mediaType).to.be.a('string'); - } - it('Returns an empty array if invalid response is passed', function () { - serverResponses = spec.interpretResponse('invalid_response'); - expect(serverResponses).to.be.an('array').that.is.empty; - }); - }); - }); - - describe('getUserSyncs', function () { - let userSync = spec.getUserSyncs(); - it('Returns valid URL and `', function () { - expect(userSync).to.be.an('array').with.lengthOf(1); - expect(userSync[0].type).to.exist; - expect(userSync[0].url).to.exist; - expect(userSync[0].type).to.be.equal('image'); - expect(userSync[0].url).to.be.equal('//supply.nl.weborama.fr/?c=o&m=cookie'); - }); - }); -}); diff --git a/test/spec/modules/widespaceBidAdapter_spec.js b/test/spec/modules/widespaceBidAdapter_spec.js deleted file mode 100644 index b3884a90b84a..000000000000 --- a/test/spec/modules/widespaceBidAdapter_spec.js +++ /dev/null @@ -1,262 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/widespaceBidAdapter'; -import includes from 'core-js/library/fn/array/includes'; - -describe('+widespaceAdatperTest', function () { - // Dummy bid request - const bidRequest = [{ - 'adUnitCode': 'div-gpt-ad-1460505748561-0', - 'auctionId': 'bf1e57ee-fff2-4304-8143-91aaf423a948', - 'bidId': '4045696e2278cd', - 'bidder': 'widespace', - 'params': { - sid: '7b6589bf-95c8-4656-90b9-af9737bb9ad3', - currency: 'EUR', - demo: { - gender: 'M', - country: 'Sweden', - region: 'Stockholm', - postal: '15115', - city: 'Stockholm', - yob: '1984' - } - }, - 'bidderRequestId': '37a5f053efef34', - 'sizes': [[320, 320], [300, 250], [300, 300]], - 'transactionId': '4f68b713-04ba-4d7f-8df9-643bcdab5efb' - }, { - 'adUnitCode': 'div-gpt-ad-1460505748561-1', - 'auctionId': 'bf1e57ee-fff2-4304-8143-91aaf423a944', - 'bidId': '4045696e2278ab', - 'bidder': 'widespace', - 'params': { - sid: '7b6589bf-95c8-4656-90b9-af9737bb9ad4', - demo: { - gender: 'M', - country: 'Sweden', - region: 'Stockholm', - postal: '15115', - city: 'Stockholm', - yob: '1984' - } - }, - 'bidderRequestId': '37a5f053efef34', - 'sizes': [[300, 300]], - 'transactionId': '4f68b713-04ba-4d7f-8df9-643bcdab5efv' - }]; - - // Dummy bidderRequest object - const bidderRequest = { - auctionId: 'bf1e57ee-fff2-4304-8143-91aaf423a944', - auctionStart: 1527418994278, - bidderCode: 'widespace', - bidderRequestId: '37a5f053efef34', - timeout: 3000, - gdprConsent: { - consentString: 'consentString', - gdprApplies: true, - vendorData: { - hasGlobalScope: false - } - } - }; - - // Dummy bid response with ad code - const bidResponse = { - body: [{ - 'adId': '12345', - 'bidId': '67890', - 'code': '
', - 'cpm': 6.6, - 'currency': 'EUR', - 'height': 300, - 'netRev': true, - 'reqId': '224804081406', - 'status': 'ad', - 'ttl': 30, - 'width': 300, - 'syncPixels': ['https://url1.com/url', 'https://url2.com/url'] - }], - headers: {} - }; - - // Dummy bid response of noad - const bidResponseNoAd = { - body: [{ - 'status': 'noad', - }], - headers: {} - }; - - // Appending a div with id of adUnitCode so we can calculate vol - const div1 = document.createElement('div'); - div1.id = bidRequest[0].adUnitCode; - document.body.appendChild(div1); - const div2 = document.createElement('div'); - div2.id = bidRequest[0].adUnitCode; - document.body.appendChild(div2); - - // Adding custom data cookie se we can test cookie is readable - const theDate = new Date(); - const expDate = new Date(theDate.setMonth(theDate.getMonth() + 1)).toGMTString(); - window.document.cookie = `wsCustomData1={id: test};path=/;expires=${expDate};`; - const PERF_DATA = JSON.stringify({perf_status: 'OK', perf_reqid: '226920425154', perf_ms: '747'}); - window.document.cookie = `wsPerfData123=${PERF_DATA};path=/;expires=${expDate};`; - - // Connect dummy data test - const CONNECTION = navigator.connection || navigator.webkitConnection; - if (CONNECTION && CONNECTION.type && CONNECTION.downlinkMax) { - navigator.connection.downlinkMax = 80; - navigator.connection.type = 'wifi'; - } - - describe('+bidRequestValidity', function () { - it('bidRequest with sid and currency params', function () { - expect(spec.isBidRequestValid({ - bidder: 'widespace', - params: { - sid: '7b6589bf-95c8-4656-90b9-af9737bb9ad3', - currency: 'EUR' - } - })).to.equal(true); - }); - - it('-bidRequest with missing sid', function () { - expect(spec.isBidRequestValid({ - bidder: 'widespace', - params: { - currency: 'EUR' - } - })).to.equal(false); - }); - - it('-bidRequest with missing currency', function () { - expect(spec.isBidRequestValid({ - bidder: 'widespace', - params: { - sid: '7b6589bf-95c8-4656-90b9-af9737bb9ad3' - } - })).to.equal(true); - }); - }); - - describe('+bidRequest', function () { - const request = spec.buildRequests(bidRequest, bidderRequest); - const UrlRegExp = /^((ftp|http|https):)?\/\/[^ "]+$/; - - let fakeLocalStorage = {}; - let lsSetStub; - let lsGetStub; - let lsRemoveStub; - - beforeEach(function() { - lsSetStub = sinon.stub(window.localStorage, 'setItem').callsFake(function (name, value) { - fakeLocalStorage[name] = value; - }); - - lsGetStub = sinon.stub(window.localStorage, 'getItem').callsFake(function (key) { - return fakeLocalStorage[key] || null; - }); - - lsRemoveStub = sinon.stub(window.localStorage, 'removeItem').callsFake(function (key) { - if (key && (fakeLocalStorage[key] !== null || fakeLocalStorage[key] !== undefined)) { - delete fakeLocalStorage[key]; - } - return true; - }); - }); - - afterEach(function() { - lsSetStub.restore(); - lsGetStub.restore(); - lsRemoveStub.restore(); - fakeLocalStorage = {}; - }); - - it('-bidRequest method is POST', function () { - expect(request[0].method).to.equal('POST'); - }); - - it('-bidRequest url is valid', function () { - expect(UrlRegExp.test(request[0].url)).to.equal(true); - }); - - it('-bidRequest data exist', function () { - expect(request[0].data).to.exist; - }); - - it('-bidRequest data is form data', function () { - expect(typeof request[0].data).to.equal('string'); - }); - - it('-bidRequest options have header type', function () { - expect(request[0].options.contentType).to.exist; - }); - - it('-cookie test for wsCustomData ', function () { - expect(request[0].data.indexOf('hb.cd') > -1).to.equal(true); - }); - }); - - describe('+interpretResponse', function () { - it('-required params available in response', function () { - const result = spec.interpretResponse(bidResponse, bidRequest); - let requiredKeys = [ - 'requestId', - 'cpm', - 'width', - 'height', - 'creativeId', - 'currency', - 'netRevenue', - 'ttl', - 'referrer', - 'ad' - ]; - const resultKeys = Object.keys(result[0]); - requiredKeys.forEach((key) => { - expect(includes(resultKeys, key)).to.equal(true); - }); - - // Each value except referrer should not be empty|null|undefined - result.forEach((res) => { - Object.keys(res).forEach((resKey) => { - if (resKey !== 'referrer') { - expect(res[resKey]).to.not.be.null; - expect(res[resKey]).to.not.be.undefined; - expect(res[resKey]).to.not.equal(''); - } - }); - }); - }); - - it('-empty result if noad responded', function () { - const noAdResult = spec.interpretResponse(bidResponseNoAd, bidRequest); - expect(noAdResult.length).to.equal(0); - }); - - it('-empty response should not breake anything in adapter', function () { - const noResponse = spec.interpretResponse({}, bidRequest); - expect(noResponse.length).to.equal(0); - }); - }); - - describe('+getUserSyncs', function () { - it('-always return an array', function () { - const userSync_test1 = spec.getUserSyncs({}, [bidResponse]); - expect(Array.isArray(userSync_test1)).to.equal(true); - - const userSync_test2 = spec.getUserSyncs({}, [bidResponseNoAd]); - expect(Array.isArray(userSync_test2)).to.equal(true); - - const userSync_test3 = spec.getUserSyncs({}, [bidResponse, bidResponseNoAd]); - expect(Array.isArray(userSync_test3)).to.equal(true); - - const userSync_test4 = spec.getUserSyncs(); - expect(Array.isArray(userSync_test4)).to.equal(true); - - const userSync_test5 = spec.getUserSyncs({}, []); - expect(Array.isArray(userSync_test5)).to.equal(true); - }); - }); -}); diff --git a/test/spec/modules/xendizBidAdapter_spec.js b/test/spec/modules/xendizBidAdapter_spec.js deleted file mode 100644 index 4d1aa3c935f7..000000000000 --- a/test/spec/modules/xendizBidAdapter_spec.js +++ /dev/null @@ -1,119 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/xendizBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; - -const VALID_ENDPOINT = '//prebid.xendiz.com/request'; -const bidRequest = { - bidder: 'xendiz', - adUnitCode: 'test-div', - sizes: [[300, 250], [300, 600]], - params: { - pid: '550e8400-e29b-41d4-a716-446655440000' - }, - bidId: '30b31c1838de1e', - bidderRequestId: '22edbae2733bf6', - auctionId: '1d1a030790a475', -}; - -const bidResponse = { - body: { - id: '1d1a030790a475', - bids: [{ - id: '30b31c1838de1e', - price: 3, - cur: 'USD', - h: 250, - w: 300, - crid: 'test', - dealid: '1', - exp: 900, - adm: 'tag' - }] - } -}; - -const noBidResponse = { body: { id: '1d1a030790a475', bids: [] } }; - -describe('xendizBidAdapter', function () { - const adapter = newBidder(spec); - - describe('inherited functions', function () { - it('exists and is a function', function () { - expect(adapter.callBids).to.exist.and.to.be.a('function'); - }); - }); - - describe('isBidRequestValid', function () { - it('should return false', function () { - let bid = Object.assign({}, bidRequest); - bid.params = {}; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - - it('should return true', function () { - expect(spec.isBidRequestValid(bidRequest)).to.equal(true); - }); - }); - - describe('buildRequests', function () { - it('should format valid url', function () { - const request = spec.buildRequests([bidRequest]); - expect(request.url).to.equal(VALID_ENDPOINT); - }); - - it('should format valid url', function () { - const request = spec.buildRequests([bidRequest]); - expect(request.url).to.equal(VALID_ENDPOINT); - }); - - it('should format valid request body', function () { - const request = spec.buildRequests([bidRequest]); - const payload = JSON.parse(request.data); - expect(payload.id).to.exist; - expect(payload.items).to.exist; - expect(payload.device).to.exist; - }); - - it('should attach valid device info', function () { - const request = spec.buildRequests([bidRequest]); - const payload = JSON.parse(request.data); - expect(payload.device).to.deep.equal([ - navigator.language || '', - window.screen.width, - window.screen.height - ]); - }); - - it('should transform sizes', function () { - const request = spec.buildRequests([bidRequest]); - const payload = JSON.parse(request.data); - const item = payload.items[0]; - expect(item[item.length - 1]).to.deep.equal(['300x250', '300x600']); - }); - }); - - describe('interpretResponse', function () { - it('should get correct bid response', function () { - const result = spec.interpretResponse(bidResponse); - const validResponse = [{ - requestId: '30b31c1838de1e', - cpm: 3, - width: 300, - height: 250, - creativeId: 'test', - netRevenue: true, - dealId: '1', - currency: 'USD', - ttl: 900, - ad: 'tag' - }]; - - expect(result).to.deep.equal(validResponse); - }); - - it('handles nobid responses', function () { - let result = spec.interpretResponse(noBidResponse); - expect(result.length).to.equal(0); - }); - }); -}); diff --git a/test/spec/modules/xhbBidAdapter_spec.js b/test/spec/modules/xhbBidAdapter_spec.js index e48d3011ed28..004bdcc4b542 100644 --- a/test/spec/modules/xhbBidAdapter_spec.js +++ b/test/spec/modules/xhbBidAdapter_spec.js @@ -3,7 +3,7 @@ import { spec } from 'modules/xhbBidAdapter'; import { newBidder } from 'src/adapters/bidderFactory'; import { deepClone } from 'src/utils'; -const ENDPOINT = '//ib.adnxs.com/ut/v3/prebid'; +const ENDPOINT = 'https://ib.adnxs.com/ut/v3/prebid'; describe('xhbAdapter', function () { const adapter = newBidder(spec); @@ -337,7 +337,7 @@ describe('xhbAdapter', function () { 'tag_id': 10433394, 'auction_id': '4534722592064951574', 'nobid': false, - 'no_ad_url': 'http://lax1-ib.adnxs.com/no-ad', + 'no_ad_url': 'https://lax1-ib.adnxs.com/no-ad', 'timeout_ms': 10000, 'ad_profile_id': 27079, 'ads': [ @@ -361,7 +361,7 @@ describe('xhbAdapter', function () { 'trackers': [ { 'impression_urls': [ - 'http://lax1-ib.adnxs.com/impression' + 'https://lax1-ib.adnxs.com/impression' ], 'video_events': {} } @@ -448,19 +448,19 @@ describe('xhbAdapter', function () { 'icon': { 'width': 0, 'height': 0, - 'url': 'http://cdn.adnxs.com/icon.png' + 'url': 'https://cdn.adnxs.com/icon.png' }, 'main_img': { 'width': 2352, 'height': 1516, - 'url': 'http://cdn.adnxs.com/img.png' + 'url': 'https://cdn.adnxs.com/img.png' }, 'link': { 'url': 'https://www.appnexus.com', 'fallback_url': '', - 'click_trackers': ['http://nym1-ib.adnxs.com/click'] + 'click_trackers': ['https://nym1-ib.adnxs.com/click'] }, - 'impression_trackers': ['http://example.com'], + 'impression_trackers': ['https://example.com'], }; let bidderRequest; @@ -468,7 +468,7 @@ describe('xhbAdapter', function () { expect(result[0].native.title).to.equal('Native Creative'); expect(result[0].native.body).to.equal('Cool description great stuff'); expect(result[0].native.cta).to.equal('Do it'); - expect(result[0].native.image.url).to.equal('http://cdn.adnxs.com/img.png'); + expect(result[0].native.image.url).to.equal('https://cdn.adnxs.com/img.png'); }); it('supports configuring outstream renderers', function () { diff --git a/test/spec/modules/yieldbotBidAdapter_spec.js b/test/spec/modules/yieldbotBidAdapter_spec.js deleted file mode 100644 index 2548bb31fdce..000000000000 --- a/test/spec/modules/yieldbotBidAdapter_spec.js +++ /dev/null @@ -1,1383 +0,0 @@ -import { expect } from 'chai'; -import find from 'core-js/library/fn/array/find'; -import { newBidder } from 'src/adapters/bidderFactory'; -import AdapterManager from 'src/adapterManager'; -import { newAuctionManager } from 'src/auctionManager'; -import * as utils from 'src/utils'; -import * as urlUtils from 'src/url'; -import events from 'src/events'; -import { YieldbotAdapter, spec } from 'modules/yieldbotBidAdapter'; - -before(function() { - YieldbotAdapter.clearAllCookies(); -}); -describe('Yieldbot Adapter Unit Tests', function() { - const ALL_SEARCH_PARAMS = ['apie', 'bt', 'cb', 'cts_ad', 'cts_imp', 'cts_ini', 'cts_js', 'cts_ns', 'cts_rend', 'cts_res', 'e', 'ioa', 'it', 'la', 'lo', 'lpv', 'lpvi', 'mtp', 'np', 'pvd', 'pvi', 'r', 'ri', 'sb', 'sd', 'si', 'slot', 'sn', 'ssz', 'to', 'ua', 'v', 'vi']; - - const BID_LEADERBOARD_728x90 = { - bidder: 'yieldbot', - params: { - psn: '1234', - slot: 'leaderboard' - }, - adUnitCode: '/0000000/leaderboard', - transactionId: '3bcca099-e22a-4e1e-ab60-365a74a87c19', - sizes: [728, 90], - bidId: '2240b2af6064bb', - bidderRequestId: '1e878e3676fb85', - auctionId: 'c9964bd5-f835-4c91-916e-00295819f932' - }; - - const BID_MEDREC_300x600 = { - bidder: 'yieldbot', - params: { - psn: '1234', - slot: 'medrec' - }, - adUnitCode: '/0000000/side-bar', - transactionId: '3bcca099-e22a-4e1e-ab60-365a74a87c20', - sizes: [300, 600], - bidId: '332067957eaa33', - bidderRequestId: '1e878e3676fb85', - auctionId: 'c9964bd5-f835-4c91-916e-00295819f932' - }; - - const BID_MEDREC_300x250 = { - bidder: 'yieldbot', - params: { - psn: '1234', - slot: 'medrec' - }, - adUnitCode: '/0000000/medrec', - transactionId: '3bcca099-e22a-4e1e-ab60-365a74a87c21', - sizes: [[300, 250]], - bidId: '49d7fe5c3a15ed', - bidderRequestId: '1e878e3676fb85', - auctionId: 'c9964bd5-f835-4c91-916e-00295819f932' - }; - - const BID_SKY160x600 = { - bidder: 'yieldbot', - params: { - psn: '1234', - slot: 'skyscraper' - }, - adUnitCode: '/0000000/side-bar', - transactionId: '3bcca099-e22a-4e1e-ab60-365a74a87c21', - sizes: [160, 600], - bidId: '49d7fe5c3a16ee', - bidderRequestId: '1e878e3676fb85', - auctionId: 'c9964bd5-f835-4c91-916e-00295819f932' - }; - - const AD_UNITS = [ - { - transactionId: '3bcca099-e22a-4e1e-ab60-365a74a87c19', - code: '/00000000/leaderboard', - sizes: [728, 90], - bids: [ - { - bidder: 'yieldbot', - params: { - psn: '1234', - slot: 'leaderboard' - } - } - ] - }, - { - transactionId: '3bcca099-e22a-4e1e-ab60-365a74a87c20', - code: '/00000000/medrec', - sizes: [[300, 250]], - bids: [ - { - bidder: 'yieldbot', - params: { - psn: '1234', - slot: 'medrec' - } - } - ] - }, - { - transactionId: '3bcca099-e22a-4e1e-ab60-365a74a87c21', - code: '/00000000/multi-size', - sizes: [[300, 600]], - bids: [ - { - bidder: 'yieldbot', - params: { - psn: '1234', - slot: 'medrec' - } - } - ] - }, - { - transactionId: '3bcca099-e22a-4e1e-ab60-365a74a87c22', - code: '/00000000/skyscraper', - sizes: [[160, 600]], - bids: [ - { - bidder: 'yieldbot', - params: { - psn: '1234', - slot: 'skyscraper' - } - } - ] - } - ]; - - const INTERPRET_RESPONSE_BID_REQUEST = { - method: 'GET', - url: '//i.yldbt.com/m/1234/v1/init', - data: { - cts_js: 1518184900582, - cts_ns: 1518184900582, - v: 'pbjs-yb-1.0.0', - vi: 'jdg00eijgpvemqlz73', - si: 'jdg00eil9y4mcdo850', - pvd: 6, - pvi: 'jdg03ai5kp9k1rkheh', - lpv: 1518184868108, - lpvi: 'jdg02lfwmdx8n0ncgc', - bt: 'init', - ua: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36', - np: 'MacIntel', - la: 'en-US', - to: 5, - sd: '2560x1440', - lo: 'http://localhost:9999/test/spec/e2e/gpt-examples/gpt_yieldbot.html', - r: '', - e: '', - sn: 'leaderboard|medrec|medrec|skyscraper', - ssz: '728x90|300x250|300x600|160x600', - cts_ini: 1518184900591 - }, - yieldbotSlotParams: { - psn: '1234', - sn: 'leaderboard|medrec|medrec|skyscraper', - ssz: '728x90|300x250|300x600|160x600', - bidIdMap: { - 'jdg03ai5kp9k1rkheh:leaderboard:728x90': '2240b2af6064bb', - 'jdg03ai5kp9k1rkheh:medrec:300x250': '49d7fe5c3a15ed', - 'jdg03ai5kp9k1rkheh:medrec:300x600': '332067957eaa33', - 'jdg03ai5kp9k1rkheh:skyscraper:160x600': '49d7fe5c3a16ee' - } - }, - options: { - withCredentials: true, - customHeaders: { - Accept: 'application/json' - } - } - }; - - const INTERPRET_RESPONSE_SERVER_RESPONSE = { - body: { - pvi: 'jdg03ai5kp9k1rkheh', - subdomain_iframe: 'ads-adseast-vpc', - url_prefix: 'http://ads-adseast-vpc.yldbt.com/m/', - slots: [ - { - slot: 'leaderboard', - cpm: '800', - size: '728x90' - }, - { - slot: 'medrec', - cpm: '300', - size: '300x250' - }, - { - slot: 'medrec', - cpm: '800', - size: '300x600' - }, - { - slot: 'skyscraper', - cpm: '300', - size: '160x600' - } - ], - user_syncs: [ - 'https://usersync.dd9693a32aa1.com/00000000.gif?p=a', - 'https://usersync.3b19503b37d8.com/00000000.gif?p=b', - 'https://usersync.5cb389d36d30.com/00000000.gif?p=c' - ] - }, - headers: {} - }; - - let FIXTURE_AD_UNITS, FIXTURE_SERVER_RESPONSE, FIXTURE_BID_REQUEST, FIXTURE_BID_REQUESTS, FIXTURE_BIDS; - beforeEach(function() { - FIXTURE_AD_UNITS = utils.deepClone(AD_UNITS); - FIXTURE_BIDS = { - BID_LEADERBOARD_728x90: utils.deepClone(BID_LEADERBOARD_728x90), - BID_MEDREC_300x600: utils.deepClone(BID_MEDREC_300x600), - BID_MEDREC_300x250: utils.deepClone(BID_MEDREC_300x250), - BID_SKY160x600: utils.deepClone(BID_SKY160x600) - }; - - FIXTURE_BID_REQUEST = utils.deepClone(INTERPRET_RESPONSE_BID_REQUEST); - FIXTURE_SERVER_RESPONSE = utils.deepClone(INTERPRET_RESPONSE_SERVER_RESPONSE); - FIXTURE_BID_REQUESTS = [ - FIXTURE_BIDS.BID_LEADERBOARD_728x90, - FIXTURE_BIDS.BID_MEDREC_300x600, - FIXTURE_BIDS.BID_MEDREC_300x250, - FIXTURE_BIDS.BID_SKY160x600 - ]; - }); - - afterEach(function() { - YieldbotAdapter._optOut = false; - YieldbotAdapter.clearAllCookies(); - YieldbotAdapter._isInitialized = false; - YieldbotAdapter.initialize(); - }); - - describe('Adapter exposes BidderSpec API', function() { - it('code', function() { - expect(spec.code).to.equal('yieldbot'); - }); - it('supportedMediaTypes', function() { - expect(spec.supportedMediaTypes).to.deep.equal(['banner']); - }); - it('isBidRequestValid', function() { - expect(spec.isBidRequestValid).to.be.a('function'); - }); - it('buildRequests', function() { - expect(spec.buildRequests).to.be.a('function'); - }); - it('interpretResponse', function() { - expect(spec.interpretResponse).to.be.a('function'); - }); - }); - - describe('isBidRequestValid', function() { - let bid = { - bidder: 'yieldbot', - 'params': { - psn: 'foo', - slot: 'bar' - }, - sizes: [[300, 250], [300, 600]] - }; - - it('valid parameters', function() { - expect(spec.isBidRequestValid({ - bidder: 'yieldbot', - 'params': { - psn: 'foo', - slot: 'bar' - }, - sizes: [[300, 250], [300, 600]] - })).to.equal(true); - }); - - it('undefined parameters', function() { - expect(spec.isBidRequestValid({ - bidder: 'yieldbot', - 'params': { - }, - sizes: [[300, 250], [300, 600]] - })).to.equal(false); - - expect(spec.isBidRequestValid({ - bidder: 'yieldbot', - 'params': { - psn: 'foo' - }, - sizes: [[300, 250], [300, 600]] - })).to.equal(false); - - expect(spec.isBidRequestValid({ - bidder: 'yieldbot', - 'params': { - slot: 'bar' - }, - sizes: [[300, 250], [300, 600]] - })).to.equal(false); - }); - - it('falsey string parameters', function() { - expect(spec.isBidRequestValid({ - bidder: 'yieldbot', - 'params': { - psn: '', - slot: 'bar' - }, - sizes: [[300, 250], [300, 600]] - })).to.equal(false); - - expect(spec.isBidRequestValid({ - bidder: 'yieldbot', - 'params': { - psn: 'foo', - slot: '' - }, - sizes: [[300, 250], [300, 600]] - })).to.equal(false); - - expect(spec.isBidRequestValid({ - bidder: 'yieldbot', - 'params': { - psn: 'foo', - slot: 0 - }, - sizes: [[300, 250], [300, 600]] - })).to.equal(false); - }); - - it('parameters type invalid', function() { - expect(spec.isBidRequestValid({ - bidder: 'yieldbot', - 'params': { - psn: 'foo', - slot: 0 - }, - sizes: [[300, 250], [300, 600]] - })).to.equal(false); - - expect(spec.isBidRequestValid({ - bidder: 'yieldbot', - 'params': { - psn: { name: 'foo' }, - slot: 'bar' - }, - sizes: [[300, 250], [300, 600]] - })).to.equal(false); - }); - - it('invalid sizes type', function() { - expect(spec.isBidRequestValid({ - bidder: 'yieldbot', - 'params': { - psn: 'foo', - slot: 'bar' - }, - sizes: {} - })).to.equal(true); - }); - }); - - describe('getSlotRequestParams', function() { - const EMPTY_SLOT_PARAMS = { sn: '', ssz: '', bidIdMap: {} }; - - it('should default to empty slot params', function() { - expect(YieldbotAdapter.getSlotRequestParams('')).to.deep.equal(EMPTY_SLOT_PARAMS); - expect(YieldbotAdapter.getSlotRequestParams()).to.deep.equal(EMPTY_SLOT_PARAMS); - expect(YieldbotAdapter.getSlotRequestParams('', [])).to.deep.equal(EMPTY_SLOT_PARAMS); - expect(YieldbotAdapter.getSlotRequestParams(0, [])).to.deep.equal(EMPTY_SLOT_PARAMS); - }); - - it('should build slot bid request parameters', function() { - const bidRequests = [ - FIXTURE_BIDS.BID_LEADERBOARD_728x90, - FIXTURE_BIDS.BID_MEDREC_300x600, - FIXTURE_BIDS.BID_MEDREC_300x250 - ]; - const slotParams = YieldbotAdapter.getSlotRequestParams('f0e1d2c', bidRequests); - - expect(slotParams.psn).to.equal('1234'); - expect(slotParams.sn).to.equal('leaderboard|medrec'); - expect(slotParams.ssz).to.equal('728x90|300x600.300x250'); - - let bidId = slotParams.bidIdMap['f0e1d2c:leaderboard:728x90']; - expect(bidId).to.equal('2240b2af6064bb'); - - bidId = slotParams.bidIdMap['f0e1d2c:medrec:300x250']; - expect(bidId).to.equal('49d7fe5c3a15ed'); - - bidId = slotParams.bidIdMap['f0e1d2c:medrec:300x600']; - expect(bidId).to.equal('332067957eaa33'); - }); - - it('should build slot bid request parameters in order of bidRequests', function() { - const bidRequests = [ - FIXTURE_BIDS.BID_MEDREC_300x600, - FIXTURE_BIDS.BID_LEADERBOARD_728x90, - FIXTURE_BIDS.BID_MEDREC_300x250 - ]; - - const slotParams = YieldbotAdapter.getSlotRequestParams('f0e1d2c', bidRequests); - - expect(slotParams.psn).to.equal('1234'); - expect(slotParams.sn).to.equal('medrec|leaderboard'); - expect(slotParams.ssz).to.equal('300x600.300x250|728x90'); - - let bidId = slotParams.bidIdMap['f0e1d2c:leaderboard:728x90']; - expect(bidId).to.equal('2240b2af6064bb'); - - bidId = slotParams.bidIdMap['f0e1d2c:medrec:300x250']; - expect(bidId).to.equal('49d7fe5c3a15ed'); - - bidId = slotParams.bidIdMap['f0e1d2c:medrec:300x600']; - expect(bidId).to.equal('332067957eaa33'); - }); - - it('should exclude slot bid requests with malformed sizes', function() { - const bid = FIXTURE_BIDS.BID_MEDREC_300x250; - bid.sizes = ['300x250']; - const bidRequests = [bid, FIXTURE_BIDS.BID_LEADERBOARD_728x90]; - const slotParams = YieldbotAdapter.getSlotRequestParams('affffffe', bidRequests); - expect(slotParams.psn).to.equal('1234'); - expect(slotParams.sn).to.equal('leaderboard'); - expect(slotParams.ssz).to.equal('728x90'); - }); - }); - - describe('getCookie', function() { - it('should return null if cookie name not found', function() { - const cookieName = YieldbotAdapter.newId(); - expect(YieldbotAdapter.getCookie(cookieName)).to.equal(null); - }); - }); - - describe('setCookie', function() { - it('should set a root path first-party cookie with temporal expiry', function() { - const cookieName = YieldbotAdapter.newId(); - const cookieValue = YieldbotAdapter.newId(); - - YieldbotAdapter.setCookie(cookieName, cookieValue, 2000, '/'); - expect(YieldbotAdapter.getCookie(cookieName)).to.equal(cookieValue); - - YieldbotAdapter.deleteCookie(cookieName); - expect(YieldbotAdapter.getCookie(cookieName)).to.equal(null); - }); - - it('should set a root path first-party cookie with session expiry', function() { - const cookieName = YieldbotAdapter.newId(); - const cookieValue = YieldbotAdapter.newId(); - - YieldbotAdapter.setCookie(cookieName, cookieValue, null, '/'); - expect(YieldbotAdapter.getCookie(cookieName)).to.equal(cookieValue); - - YieldbotAdapter.deleteCookie(cookieName); - expect(YieldbotAdapter.getCookie(cookieName)).to.equal(null); - }); - - it('should fail to set a cookie x-domain', function() { - const cookieName = YieldbotAdapter.newId(); - const cookieValue = YieldbotAdapter.newId(); - - YieldbotAdapter.setCookie(cookieName, cookieValue, null, '/', `${cookieName}.com`); - expect(YieldbotAdapter.getCookie(cookieName)).to.equal(null); - }); - }); - - describe('clearAllcookies', function() { - it('should delete all first-party cookies', function() { - let idx, cookieLabels = YieldbotAdapter._cookieLabels, cookieName, cookieValue; - for (idx = 0; idx < cookieLabels.length; idx++) { - YieldbotAdapter.deleteCookie('__ybot' + cookieLabels[idx]); - } - - YieldbotAdapter.sessionBlocked = true; - expect(YieldbotAdapter.sessionBlocked, 'sessionBlocked').to.equal(true); - - const userId = YieldbotAdapter.userId; - expect(YieldbotAdapter.userId, 'userId').to.equal(userId); - - const sessionId = YieldbotAdapter.sessionId; - expect(YieldbotAdapter.sessionId, 'sessionId').to.equal(sessionId); - - const pageviewDepth = YieldbotAdapter.pageviewDepth; - expect(pageviewDepth, 'returned pageviewDepth').to.equal(1); - expect(YieldbotAdapter.pageviewDepth, 'get pageviewDepth').to.equal(2); - - const lastPageviewId = YieldbotAdapter.newId(); - YieldbotAdapter.lastPageviewId = lastPageviewId; - expect(YieldbotAdapter.lastPageviewId, 'get lastPageviewId').to.equal(lastPageviewId); - - const lastPageviewTime = Date.now(); - YieldbotAdapter.lastPageviewTime = lastPageviewTime; - expect(YieldbotAdapter.lastPageviewTime, 'lastPageviewTime').to.equal(lastPageviewTime); - - const urlPrefix = YieldbotAdapter.urlPrefix('http://here.there.com/ad/'); - expect(YieldbotAdapter.urlPrefix(), 'urlPrefix').to.equal('http://here.there.com/ad/'); - - for (idx = 0; idx < cookieLabels.length; idx++) { - cookieValue = YieldbotAdapter.getCookie('__ybot' + cookieLabels[idx]); - expect(!!cookieValue, 'setter: ' + cookieLabels[idx]).to.equal(true); - } - - YieldbotAdapter.clearAllCookies(); - - for (idx = 0; idx < cookieLabels.length; idx++) { - cookieName = '__ybot' + cookieLabels[idx]; - cookieValue = YieldbotAdapter.getCookie(cookieName); - expect(cookieValue, cookieName).to.equal(null); - }; - }); - }); - - describe('sessionBlocked', function() { - const cookieName = '__ybotn'; - beforeEach(function() { - YieldbotAdapter.deleteCookie(cookieName); - }); - - afterEach(function() { - YieldbotAdapter.deleteCookie(cookieName); - expect(YieldbotAdapter.getCookie(cookieName)).to.equal(null); - }); - - it('should return true if cookie value is interpreted as non-zero', function() { - YieldbotAdapter.setCookie(cookieName, '1', 2000, '/'); - expect(YieldbotAdapter.sessionBlocked, 'cookie value: the string "1"').to.equal(true); - - YieldbotAdapter.setCookie(cookieName, '10.01', 2000, '/'); - expect(YieldbotAdapter.sessionBlocked, 'cookie value: the string "10.01"').to.equal(true); - - YieldbotAdapter.setCookie(cookieName, '-10.01', 2000, '/'); - expect(YieldbotAdapter.sessionBlocked, 'cookie value: the string "-10.01"').to.equal(true); - - YieldbotAdapter.setCookie(cookieName, 1, 2000, '/'); - expect(YieldbotAdapter.sessionBlocked, 'cookie value: the number 1').to.equal(true); - }); - - it('should return false if cookie name not found', function() { - expect(YieldbotAdapter.sessionBlocked).to.equal(false); - }); - - it('should return false if cookie value is interpreted as zero', function() { - YieldbotAdapter.setCookie(cookieName, '0', 2000, '/'); - expect(YieldbotAdapter.sessionBlocked, 'cookie value: the string "0"').to.equal(false); - - YieldbotAdapter.setCookie(cookieName, '.01', 2000, '/'); - expect(YieldbotAdapter.sessionBlocked, 'cookie value: the string ".01"').to.equal(false); - - YieldbotAdapter.setCookie(cookieName, '-.9', 2000, '/'); - expect(YieldbotAdapter.sessionBlocked, 'cookie value: the string "-.9"').to.equal(false); - - YieldbotAdapter.setCookie(cookieName, 0, 2000, '/'); - expect(YieldbotAdapter.sessionBlocked, 'cookie value: the number 0').to.equal(false); - }); - - it('should return false if cookie value source is a non-numeric string', function() { - YieldbotAdapter.setCookie(cookieName, 'true', 2000, '/'); - expect(YieldbotAdapter.sessionBlocked).to.equal(false); - }); - - it('should return false if cookie value source is a boolean', function() { - YieldbotAdapter.setCookie(cookieName, true, 2000, '/'); - expect(YieldbotAdapter.sessionBlocked).to.equal(false); - }); - - it('should set sessionBlocked', function() { - YieldbotAdapter.sessionBlocked = true; - expect(YieldbotAdapter.sessionBlocked).to.equal(true); - YieldbotAdapter.sessionBlocked = false; - expect(YieldbotAdapter.sessionBlocked).to.equal(false); - - YieldbotAdapter.sessionBlocked = 1; - expect(YieldbotAdapter.sessionBlocked).to.equal(true); - YieldbotAdapter.sessionBlocked = 0; - expect(YieldbotAdapter.sessionBlocked).to.equal(false); - - YieldbotAdapter.sessionBlocked = '1'; - expect(YieldbotAdapter.sessionBlocked).to.equal(true); - YieldbotAdapter.sessionBlocked = ''; - expect(YieldbotAdapter.sessionBlocked).to.equal(false); - }); - }); - - describe('userId', function() { - const cookieName = '__ybotu'; - beforeEach(function() { - YieldbotAdapter.deleteCookie(cookieName); - }); - - afterEach(function() { - YieldbotAdapter.deleteCookie(cookieName); - expect(YieldbotAdapter.getCookie(cookieName)).to.equal(null); - }); - - it('should set a user Id if cookie does not exist', function() { - const userId = YieldbotAdapter.userId; - expect(userId).to.match(/[0-9a-z]{18}/); - }); - - it('should return user Id if cookie exists', function() { - const expectedUserId = YieldbotAdapter.newId(); - YieldbotAdapter.setCookie(cookieName, expectedUserId, 2000, '/'); - const userId = YieldbotAdapter.userId; - expect(userId).to.equal(expectedUserId); - }); - }); - - describe('sessionId', function() { - const cookieName = '__ybotsi'; - beforeEach(function() { - YieldbotAdapter.deleteCookie(cookieName); - }); - - afterEach(function() { - YieldbotAdapter.deleteCookie(cookieName); - expect(YieldbotAdapter.getCookie(cookieName)).to.equal(null); - }); - - it('should set a session Id if cookie does not exist', function() { - const sessionId = YieldbotAdapter.sessionId; - expect(sessionId).to.match(/[0-9a-z]{18}/); - }); - - it('should return session Id if cookie exists', function() { - const expectedSessionId = YieldbotAdapter.newId(); - YieldbotAdapter.setCookie(cookieName, expectedSessionId, 2000, '/'); - const sessionId = YieldbotAdapter.sessionId; - expect(sessionId).to.equal(expectedSessionId); - }); - }); - - describe('lastPageviewId', function() { - const cookieName = '__ybotlpvi'; - - beforeEach(function() { - YieldbotAdapter.deleteCookie(cookieName); - }); - - afterEach(function() { - YieldbotAdapter.deleteCookie(cookieName); - expect(YieldbotAdapter.getCookie(cookieName)).to.equal(null); - }); - - it('should return empty string if cookie does not exist', function() { - const lastBidId = YieldbotAdapter.lastPageviewId; - expect(lastBidId).to.equal(''); - }); - - it('should set an id string', function() { - const id = YieldbotAdapter.newId(); - YieldbotAdapter.lastPageviewId = id; - const lastBidId = YieldbotAdapter.lastPageviewId; - expect(lastBidId).to.equal(id); - }); - }); - - describe('lastPageviewTime', function() { - const cookieName = '__ybotlpv'; - - beforeEach(function() { - YieldbotAdapter.deleteCookie(cookieName); - }); - - afterEach(function() { - YieldbotAdapter.deleteCookie(cookieName); - expect(YieldbotAdapter.getCookie(cookieName)).to.equal(null); - }); - - it('should return zero if cookie does not exist', function() { - const lastBidTime = YieldbotAdapter.lastPageviewTime; - expect(lastBidTime).to.equal(0); - }); - - it('should set a timestamp', function() { - const ts = Date.now(); - YieldbotAdapter.lastPageviewTime = ts; - const lastBidTime = YieldbotAdapter.lastPageviewTime; - expect(lastBidTime).to.equal(ts); - }); - }); - - describe('pageviewDepth', function() { - const cookieName = '__ybotpvd'; - - beforeEach(function() { - YieldbotAdapter.deleteCookie(cookieName); - }); - - afterEach(function() { - YieldbotAdapter.deleteCookie(cookieName); - expect(YieldbotAdapter.getCookie(cookieName)).to.equal(null); - }); - - it('should return one (1) if cookie does not exist', function() { - const pageviewDepth = YieldbotAdapter.pageviewDepth; - expect(pageviewDepth).to.equal(1); - }); - - it('should increment the integer string for depth', function() { - let pageviewDepth = YieldbotAdapter.pageviewDepth; - expect(pageviewDepth).to.equal(1); - - pageviewDepth = YieldbotAdapter.pageviewDepth; - expect(pageviewDepth).to.equal(2); - }); - }); - - describe('urlPrefix', function() { - const cookieName = '__ybotc'; - const protocol = document.location.protocol; - afterEach(function() { - YieldbotAdapter.deleteCookie(cookieName); - expect(YieldbotAdapter.getCookie(cookieName)).to.equal(null); - }); - - it('should set the default prefix if cookie does not exist', function(done) { - const urlPrefix = YieldbotAdapter.urlPrefix(); - expect(urlPrefix).to.equal('//i.yldbt.com/m/'); - done(); - }); - - it('should return prefix if cookie exists', function() { - YieldbotAdapter.setCookie(cookieName, protocol + '//closest.az.com/path/', 2000, '/'); - const urlPrefix = YieldbotAdapter.urlPrefix(); - expect(urlPrefix).to.equal(protocol + '//closest.az.com/path/'); - }); - - it('should reset prefix if default already set', function() { - const defaultUrlPrefix = YieldbotAdapter.urlPrefix(); - const url = protocol + '//close.az.com/path/'; - expect(defaultUrlPrefix).to.equal('//i.yldbt.com/m/'); - - let urlPrefix = YieldbotAdapter.urlPrefix(url); - expect(urlPrefix, 'reset prefix').to.equal(url); - - urlPrefix = YieldbotAdapter.urlPrefix(); - expect(urlPrefix, 'subsequent request').to.equal(url); - }); - - it('should set containing document protocol', function() { - let urlPrefix = YieldbotAdapter.urlPrefix('http://close.az.com/path/'); - expect(urlPrefix, 'http - use: ' + protocol).to.equal(protocol + '//close.az.com/path/'); - - urlPrefix = YieldbotAdapter.urlPrefix('https://close.az.com/path/'); - expect(urlPrefix, 'https - use: ' + protocol).to.equal(protocol + '//close.az.com/path/'); - }); - - it('should fallback to default for invalid argument', function() { - let urlPrefix = YieldbotAdapter.urlPrefix('//close.az.com/path/'); - expect(urlPrefix, 'Url w/o protocol').to.equal('//i.yldbt.com/m/'); - - urlPrefix = YieldbotAdapter.urlPrefix('mumble'); - expect(urlPrefix, 'Invalid Url').to.equal('//i.yldbt.com/m/'); - }); - }); - - describe('initBidRequestParams', function() { - it('should build common bid request state parameters', function() { - const params = YieldbotAdapter.initBidRequestParams( - [ - { - 'params': { - psn: '1234', - slot: 'medrec' - }, - sizes: [[300, 250], [300, 600]] - } - ] - ); - - const expectedParamKeys = [ - 'v', - 'vi', - 'si', - 'pvi', - 'pvd', - 'lpvi', - 'bt', - 'lo', - 'r', - 'sd', - 'to', - 'la', - 'np', - 'ua', - 'lpv', - 'cts_ns', - 'cts_js', - 'e' - ]; - - const missingKeys = []; - expectedParamKeys.forEach((item) => { - if (item in params === false) { - missingKeys.push(item); - } - }); - const extraKeys = []; - Object.keys(params).forEach((item) => { - if (!find(expectedParamKeys, param => param === item)) { - extraKeys.push(item); - } - }); - - expect( - missingKeys.length, - `\nExpected: ${expectedParamKeys}\nMissing keys: ${JSON.stringify(missingKeys)}`) - .to.equal(0); - expect( - extraKeys.length, - `\nExpected: ${expectedParamKeys}\nExtra keys: ${JSON.stringify(extraKeys)}`) - .to.equal(0); - }); - }); - - describe('buildRequests', function() { - it('should not return bid requests if optOut', function() { - YieldbotAdapter._optOut = true; - const requests = YieldbotAdapter.buildRequests(FIXTURE_BID_REQUESTS); - expect(requests.length).to.equal(0); - }); - - it('should not return bid requests if sessionBlocked', function() { - YieldbotAdapter.sessionBlocked = true; - const requests = YieldbotAdapter.buildRequests(FIXTURE_BID_REQUESTS); - expect(requests.length).to.equal(0); - YieldbotAdapter.sessionBlocked = false; - }); - - it('should re-enable requests when sessionBlocked expires', function() { - const cookieName = '__ybotn'; - YieldbotAdapter.setCookie( - cookieName, - 1, - 2000, - '/'); - let requests = YieldbotAdapter.buildRequests(FIXTURE_BID_REQUESTS); - expect(requests.length).to.equal(0); - YieldbotAdapter.deleteCookie(cookieName); - requests = YieldbotAdapter.buildRequests(FIXTURE_BID_REQUESTS); - expect(requests.length).to.equal(1); - }); - - it('should return a single BidRequest object', function() { - const requests = YieldbotAdapter.buildRequests(FIXTURE_BID_REQUESTS); - expect(requests.length).to.equal(1); - }); - - it('should have expected server options', function() { - const request = YieldbotAdapter.buildRequests(FIXTURE_BID_REQUESTS)[0]; - const expectedOptions = { - withCredentials: true, - customHeaders: { - Accept: 'application/json' - } - }; - expect(request.options).to.eql(expectedOptions); - }); - - it('should be a GET request', function() { - const request = YieldbotAdapter.buildRequests(FIXTURE_BID_REQUESTS)[0]; - expect(request.method).to.equal('GET'); - }); - - it('should have bid request specific params', function() { - const request = YieldbotAdapter.buildRequests(FIXTURE_BID_REQUESTS)[0]; - expect(request.data).to.not.equal(undefined); - - const expectedParamKeys = [ - 'v', - 'vi', - 'si', - 'pvi', - 'pvd', - 'lpvi', - 'bt', - 'lo', - 'r', - 'sd', - 'to', - 'la', - 'np', - 'ua', - 'sn', - 'ssz', - 'lpv', - 'cts_ns', - 'cts_js', - 'cts_ini', - 'e' - ]; - - const missingKeys = []; - expectedParamKeys.forEach((item) => { - if (item in request.data === false) { - missingKeys.push(item); - } - }); - const extraKeys = []; - Object.keys(request.data).forEach((item) => { - if (!find(expectedParamKeys, param => param === item)) { - extraKeys.push(item); - } - }); - - expect( - missingKeys.length, - `\nExpected: ${expectedParamKeys}\nMissing keys: ${JSON.stringify(missingKeys)}`) - .to.equal(0); - expect( - extraKeys.length, - `\nExpected: ${expectedParamKeys}\nExtra keys: ${JSON.stringify(extraKeys)}`) - .to.equal(0); - }); - - it('should have the correct bidUrl form', function() { - const request = YieldbotAdapter.buildRequests(FIXTURE_BID_REQUESTS)[0]; - const bidUrl = '//i.yldbt.com/m/1234/v1/init'; - expect(request.url).to.equal(bidUrl); - }); - - it('should set the bid request slot/bidId mapping', function() { - const request = YieldbotAdapter.buildRequests(FIXTURE_BID_REQUESTS)[0]; - expect(request.yieldbotSlotParams).to.not.equal(undefined); - expect(request.yieldbotSlotParams.bidIdMap).to.not.equal(undefined); - - const map = {}; - map[request.data.pvi + ':leaderboard:728x90'] = '2240b2af6064bb'; - map[request.data.pvi + ':medrec:300x250'] = '49d7fe5c3a15ed'; - map[request.data.pvi + ':medrec:300x600'] = '332067957eaa33'; - map[request.data.pvi + ':skyscraper:160x600'] = '49d7fe5c3a16ee'; - expect(request.yieldbotSlotParams.bidIdMap).to.eql(map); - }); - - it('should set the bid request publisher number', function() { - const request = YieldbotAdapter.buildRequests(FIXTURE_BID_REQUESTS)[0]; - expect(request.yieldbotSlotParams.psn).to.equal('1234'); - }); - - it('should have unique slot name parameter', function() { - const request = YieldbotAdapter.buildRequests(FIXTURE_BID_REQUESTS)[0]; - expect(request.yieldbotSlotParams.sn).to.equal('leaderboard|medrec|skyscraper'); - }); - - it('should have slot sizes parameter', function() { - const request = YieldbotAdapter.buildRequests(FIXTURE_BID_REQUESTS)[0]; - expect(request.yieldbotSlotParams.ssz).to.equal('728x90|300x600.300x250|160x600'); - }); - - it('should use edge server Url prefix if set', function() { - const cookieName = '__ybotc'; - YieldbotAdapter.setCookie( - cookieName, - 'http://close.edge.adserver.com/', - 2000, - '/'); - - const request = YieldbotAdapter.buildRequests(FIXTURE_BID_REQUESTS)[0]; - expect(request.url).to.match(/^http:\/\/close\.edge\.adserver\.com\//); - }); - - it('should be adapter loaded before navigation start time', function() { - const request = YieldbotAdapter.buildRequests(FIXTURE_BID_REQUESTS)[0]; - const timeDiff = request.data.cts_ns - request.data.cts_js; - expect(timeDiff >= 0, 'adapter loaded < nav').to.equal(true); - }); - - it('should be navigation start before bid request time', function() { - const request = YieldbotAdapter.buildRequests(FIXTURE_BID_REQUESTS)[0]; - const timeDiff = request.data.cts_ini - request.data.cts_ns; - expect(timeDiff >= 0, 'nav start < request').to.equal(true); - }); - }); - - describe('interpretResponse', function() { - it('should not return Bids if optOut', function() { - YieldbotAdapter._optOut = true; - const responses = YieldbotAdapter.interpretResponse(); - expect(responses.length).to.equal(0); - }); - - it('should not return Bids if no server response slot bids', function() { - FIXTURE_SERVER_RESPONSE.body.slots = []; - const responses = YieldbotAdapter.interpretResponse(FIXTURE_SERVER_RESPONSE, FIXTURE_BID_REQUEST); - expect(responses.length).to.equal(0); - }); - - it('should not include Bid if missing cpm', function() { - delete FIXTURE_SERVER_RESPONSE.body.slots[1].cpm; - const responses = YieldbotAdapter.interpretResponse( - FIXTURE_SERVER_RESPONSE, - FIXTURE_BID_REQUEST - ); - expect(responses.length).to.equal(3); - }); - - it('should not include Bid if missing size', function() { - delete FIXTURE_SERVER_RESPONSE.body.slots[2].size; - const responses = YieldbotAdapter.interpretResponse( - FIXTURE_SERVER_RESPONSE, - FIXTURE_BID_REQUEST - ); - expect(responses.length).to.equal(3); - }); - - it('should not include Bid if missing slot', function() { - delete FIXTURE_SERVER_RESPONSE.body.slots[3].slot; - const responses = YieldbotAdapter.interpretResponse( - FIXTURE_SERVER_RESPONSE, - FIXTURE_BID_REQUEST - ); - expect(responses.length).to.equal(3); - }); - - it('should have a valid creativeId', function() { - const responses = YieldbotAdapter.interpretResponse( - FIXTURE_SERVER_RESPONSE, - FIXTURE_BID_REQUEST - ); - expect(responses.length).to.equal(4); - responses.forEach((bid) => { - expect(bid.creativeId).to.match(/[0-9a-z]{18}/); - const containerDivId = 'ybot-' + bid.creativeId; - const re = new RegExp(containerDivId); - expect(re.test(bid.ad)).to.equal(true); - }); - }); - - it('should specify Net revenue type for bid', function() { - const responses = YieldbotAdapter.interpretResponse( - FIXTURE_SERVER_RESPONSE, - FIXTURE_BID_REQUEST - ); - expect(responses[0].netRevenue).to.equal(true); - }); - - it('should specify USD currency for bid', function() { - const responses = YieldbotAdapter.interpretResponse( - FIXTURE_SERVER_RESPONSE, - FIXTURE_BID_REQUEST - ); - expect(responses[1].currency).to.equal('USD'); - }); - - it('should set edge server Url prefix', function() { - FIXTURE_SERVER_RESPONSE.body.url_prefix = 'http://close.edge.adserver.com/'; - const responses = YieldbotAdapter.interpretResponse( - FIXTURE_SERVER_RESPONSE, - FIXTURE_BID_REQUEST - ); - const edgeServerUrlPrefix = YieldbotAdapter.getCookie('__ybotc'); - - const protocol = document.location.protocol; - const beginsRegex = new RegExp('^' + protocol + '\/\/close\.edge\.adserver\.com\/'); - const containsRegex = new RegExp(protocol + '\/\/close\.edge\.adserver\.com\/'); - expect(edgeServerUrlPrefix).to.match(beginsRegex); - expect(responses[0].ad).to.match(containsRegex); - }); - - it('should not use document.open() in ad markup', function() { - FIXTURE_SERVER_RESPONSE.body.url_prefix = 'http://close.edge.adserver.com/'; - const responses = YieldbotAdapter.interpretResponse( - FIXTURE_SERVER_RESPONSE, - FIXTURE_BID_REQUEST - ); - expect(responses[0].ad).to.not.match(/var innerFrameDoc=innerFrame\.contentWindow\.document;innerFrameDoc\.open\(\);innerFrameDoc\.write\(iframeHtml\);innerFrameDoc\.close\(\);/); - expect(responses[0].ad).to.match(/var innerFrameDoc=innerFrame\.contentWindow\.document;innerFrameDoc\.write\(iframeHtml\);innerFrameDoc\.close\(\);/); - }); - }); - - describe('getUserSyncs', function() { - let responses; - beforeEach(function () { - responses = [FIXTURE_SERVER_RESPONSE]; - }); - it('should return empty Array when server response property missing', function() { - delete responses[0].body.user_syncs; - const userSyncs = YieldbotAdapter.getUserSyncs({ pixelEnabled: true }, responses); - expect(userSyncs.length).to.equal(0); - }); - - it('should return empty Array when server response property is empty', function() { - responses[0].body.user_syncs = []; - const userSyncs = YieldbotAdapter.getUserSyncs({ pixelEnabled: true }, responses); - expect(userSyncs.length).to.equal(0); - }); - - it('should return empty Array pixel disabled', function() { - const userSyncs = YieldbotAdapter.getUserSyncs({ pixelEnabled: false }, responses); - expect(userSyncs.length).to.equal(0); - }); - - it('should return empty Array pixel option not provided', function() { - const userSyncs = YieldbotAdapter.getUserSyncs({ pixelNotHere: true }, responses); - expect(userSyncs.length).to.equal(0); - }); - - it('should return image type pixels', function() { - const userSyncs = YieldbotAdapter.getUserSyncs({ pixelEnabled: true }, responses); - expect(userSyncs).to.eql( - [ - { type: 'image', url: 'https://usersync.dd9693a32aa1.com/00000000.gif?p=a' }, - { type: 'image', url: 'https://usersync.3b19503b37d8.com/00000000.gif?p=b' }, - { type: 'image', url: 'https://usersync.5cb389d36d30.com/00000000.gif?p=c' } - ] - ); - }); - }); - - describe('Adapter Auction Behavior', function() { - AdapterManager.bidderRegistry['yieldbot'] = newBidder(spec); - let sandbox, server, auctionManager; - const bidUrlRegexp = /yldbt\.com\/m\/1234\/v1\/init/; - beforeEach(function() { - sandbox = sinon.sandbox.create({ useFakeServer: true }); - server = sandbox.server; - server.respondImmediately = true; - server.respondWith( - 'GET', - bidUrlRegexp, - [ - 200, - { 'Content-Type': 'application/json' }, - JSON.stringify(FIXTURE_SERVER_RESPONSE.body) - ] - ); - FIXTURE_SERVER_RESPONSE.user_syncs = []; - auctionManager = newAuctionManager(); - }); - - afterEach(function() { - auctionManager = null; - sandbox.restore(); - YieldbotAdapter._bidRequestCount = 0; - }); - - it('should provide auction bids', function(done) { - let bidCount = 0; - const firstAuction = auctionManager.createAuction( - { - adUnits: FIXTURE_AD_UNITS, - adUnitCodes: FIXTURE_AD_UNITS.map(unit => unit.code) - } - ); - const bidResponseHandler = (event) => { - bidCount++; - if (bidCount === 4) { - events.off('bidResponse', bidResponseHandler); - done(); - } - }; - events.on('bidResponse', bidResponseHandler); - firstAuction.callBids(); - }); - - it('should provide multiple auctions with correct bid cpms', function(done) { - let bidCount = 0; - let firstAuctionId = ''; - let secondAuctionId = ''; - /* - * 'bidResponse' event handler checks for respective adUnit auctions and bids - */ - const bidResponseHandler = (event) => { - try { - switch (true) { - case event.adUnitCode === '/00000000/leaderboard' && event.auctionId === firstAuctionId: - expect(event.cpm, 'leaderboard, first auction cpm').to.equal(8); - break; - case event.adUnitCode === '/00000000/medrec' && event.auctionId === firstAuctionId: - expect(event.cpm, 'medrec, first auction cpm').to.equal(3); - break; - case event.adUnitCode === '/00000000/multi-size' && event.auctionId === firstAuctionId: - expect(event.cpm, 'multi-size, first auction cpm').to.equal(8); - break; - case event.adUnitCode === '/00000000/skyscraper' && event.auctionId === firstAuctionId: - expect(event.cpm, 'skyscraper, first auction cpm').to.equal(3); - break; - case event.adUnitCode === '/00000000/medrec' && event.auctionId === secondAuctionId: - expect(event.cpm, 'medrec, second auction cpm').to.equal(1.11); - break; - case event.adUnitCode === '/00000000/multi-size' && event.auctionId === secondAuctionId: - expect(event.cpm, 'multi-size, second auction cpm').to.equal(2.22); - break; - case event.adUnitCode === '/00000000/skyscraper' && event.auctionId === secondAuctionId: - expect(event.cpm, 'skyscraper, second auction cpm').to.equal(3.33); - break; - default: - done(new Error(`Bid response to assert not found: ${event.adUnitCode}:${event.size}:${event.auctionId}, [${firstAuctionId}, ${secondAuctionId}]`)); - } - bidCount++; - if (bidCount === 7) { - events.off('bidResponse', bidResponseHandler); - done(); - } - } catch (err) { - done(err); - } - }; - events.on('bidResponse', bidResponseHandler); - - /* - * First auction - */ - const firstAdUnits = FIXTURE_AD_UNITS; - const firstAdUnitCodes = FIXTURE_AD_UNITS.map(unit => unit.code); - const firstAuction = auctionManager.createAuction( - { - adUnits: FIXTURE_AD_UNITS, - adUnitCodes: FIXTURE_AD_UNITS.map(unit => unit.code) - } - ); - firstAuctionId = firstAuction.getAuctionId(); - firstAuction.callBids(); - - /* - * Second auction with different bid values and fewer slots - */ - FIXTURE_AD_UNITS.shift(); - const FIXTURE_SERVER_RESPONSE_2 = utils.deepClone(FIXTURE_SERVER_RESPONSE); - FIXTURE_SERVER_RESPONSE_2.user_syncs = []; - FIXTURE_SERVER_RESPONSE_2.body.slots.shift(); - FIXTURE_SERVER_RESPONSE_2.body.slots.forEach((bid, idx) => { const num = idx + 1; bid.cpm = `${num}${num}${num}`; }); - const secondAuction = auctionManager.createAuction( - { - adUnits: FIXTURE_AD_UNITS, - adUnitCodes: FIXTURE_AD_UNITS.map(unit => unit.code) - } - ); - secondAuctionId = secondAuction.getAuctionId(); - server.respondWith( - 'GET', - bidUrlRegexp, - [ - 200, - { 'Content-Type': 'application/json' }, - JSON.stringify(FIXTURE_SERVER_RESPONSE_2.body) - ] - ); - secondAuction.callBids(); - }); - - it('should have refresh bid type after the first auction', function(done) { - const firstAuction = auctionManager.createAuction( - { - adUnits: FIXTURE_AD_UNITS, - adUnitCodes: FIXTURE_AD_UNITS.map(unit => unit.code) - } - ); - firstAuction.callBids(); - - const secondAuction = auctionManager.createAuction( - { - adUnits: FIXTURE_AD_UNITS, - adUnitCodes: FIXTURE_AD_UNITS.map(unit => unit.code) - } - ); - secondAuction.callBids(); - - const firstRequest = urlUtils.parse(server.firstRequest.url); - expect(firstRequest.search.bt, 'First request bid type').to.equal('init'); - - const secondRequest = urlUtils.parse(server.secondRequest.url); - expect(secondRequest.search.bt, 'Second request bid type').to.equal('refresh'); - - done(); - }); - - it('should use server response url_prefix property value after the first auction', function(done) { - const firstAuction = auctionManager.createAuction( - { - adUnits: FIXTURE_AD_UNITS, - adUnitCodes: FIXTURE_AD_UNITS.map(unit => unit.code) - } - ); - firstAuction.callBids(); - - const secondAuction = auctionManager.createAuction( - { - adUnits: FIXTURE_AD_UNITS, - adUnitCodes: FIXTURE_AD_UNITS.map(unit => unit.code) - } - ); - secondAuction.callBids(); - - expect(server.firstRequest.url, 'Default url prefix').to.match(/i\.yldbt\.com\/m\//); - expect(server.secondRequest.url, 'Locality url prefix').to.match(/ads-adseast-vpc\.yldbt\.com\/m\//); - - done(); - }); - - it('should increment the session page view depth only before the first auction', function(done) { - /* - * First visit: two bid requests - */ - for (let idx = 0; idx < 2; idx++) { - auctionManager.createAuction( - { - adUnits: FIXTURE_AD_UNITS, - adUnitCodes: FIXTURE_AD_UNITS.map(unit => unit.code) - } - ).callBids(); - } - - const firstRequest = urlUtils.parse(server.firstRequest.url); - expect(firstRequest.search.pvd, 'First pvd').to.equal('1'); - - const secondRequest = urlUtils.parse(server.secondRequest.url); - expect(secondRequest.search.pvd, 'Second pvd').to.equal('1'); - - /* - * Next visit: two bid requests - */ - YieldbotAdapter._isInitialized = false; - YieldbotAdapter.initialize(); - for (let idx = 0; idx < 2; idx++) { - auctionManager.createAuction( - { - adUnits: FIXTURE_AD_UNITS, - adUnitCodes: FIXTURE_AD_UNITS.map(unit => unit.code) - } - ).callBids(); - } - - const nextVisitFirstRequest = urlUtils.parse(server.thirdRequest.url); - expect(nextVisitFirstRequest.search.pvd, 'Second visit, first pvd').to.equal('2'); - - const nextVisitSecondRequest = urlUtils.parse(server.lastRequest.url); - expect(nextVisitSecondRequest.search.pvd, 'Second visit, second pvd').to.equal('2'); - - done(); - }); - }); - - describe('Adapter Request Timestamps', function() { - let sandbox; - beforeEach(function() { - sandbox = sinon.sandbox.create(); - sandbox.stub(Date, 'now').callsFake(() => { - return new Date(); - }); - }); - - afterEach(function() { - sandbox.restore(); - }); - - it('should have overridden Date.now() function', function() { - expect(Date.now().getTime()).to.match(/^[0-9]+/); - }); - - it('should be milliseconds past epoch query param values', function() { - const request = YieldbotAdapter.buildRequests(FIXTURE_BID_REQUESTS)[0]; - expect(request.data).to.not.equal(undefined); - - const timestampParams = [ - 'cts_ns', - 'cts_js', - 'cts_ini' - ]; - - timestampParams.forEach((item) => { - expect(!isNaN(request.data[item])).to.equal(true); - expect(request.data[item] > 0).to.equal(true); - expect(request.data[item]).to.match(/^[0-9]+/); - }); - }); - - it('should use (new Date()).getTime() for timestamps in ad markup', function() { - FIXTURE_SERVER_RESPONSE.body.url_prefix = 'http://close.edge.adserver.com/'; - const responses = YieldbotAdapter.interpretResponse( - FIXTURE_SERVER_RESPONSE, - FIXTURE_BID_REQUEST - ); - - expect(responses[0].ad).to.match(/cts_rend_.*='\+\(new Date\(\)\)\.getTime\(\)/); - expect(responses[0].ad).to.match(/cts_ad='\+\(new Date\(\)\)\.getTime\(\)/); - expect(responses[0].ad).to.match(/cts_imp='\+\(new Date\(\)\)\.getTime\(\)/); - }); - }); -}); diff --git a/test/spec/modules/yieldmoBidAdapter_spec.js b/test/spec/modules/yieldmoBidAdapter_spec.js deleted file mode 100644 index 60fe25db95e3..000000000000 --- a/test/spec/modules/yieldmoBidAdapter_spec.js +++ /dev/null @@ -1,220 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/yieldmoBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; -import * as utils from 'src/utils'; - -describe('YieldmoAdapter', function () { - const adapter = newBidder(spec); - const ENDPOINT = 'https://ads.yieldmo.com/exchange/prebid'; - - let tdid = '8d146286-91d4-4958-aff4-7e489dd1abd6'; - - let bid = { - bidder: 'yieldmo', - params: { - bidFloor: 0.1 - }, - adUnitCode: 'adunit-code', - sizes: [[300, 250], [300, 600]], - bidId: '30b31c1838de1e', - bidderRequestId: '22edbae2733bf6', - auctionId: '1d1a030790a475', - crumbs: { - pubcid: 'c604130c-0144-4b63-9bf2-c2bd8c8d86da' - }, - userId: { - tdid, - } - }; - let bidArray = [bid]; - - describe('isBidRequestValid', function () { - it('should return true when necessary information is found', function () { - expect(spec.isBidRequestValid(bid)).to.be.true; - }); - - it('should return false when necessary information is not found', function () { - // empty bid - expect(spec.isBidRequestValid({})).to.be.false; - - // empty bidId - bid.bidId = ''; - expect(spec.isBidRequestValid(bid)).to.be.false; - - // empty adUnitCode - bid.bidId = '30b31c1838de1e'; - bid.adUnitCode = ''; - expect(spec.isBidRequestValid(bid)).to.be.false; - - bid.adUnitCode = 'adunit-code'; - }); - }); - - describe('buildRequests', function () { - it('should attempt to send bid requests to the endpoint via GET', function () { - const request = spec.buildRequests(bidArray); - expect(request.method).to.equal('GET'); - expect(request.url).to.be.equal(ENDPOINT); - }); - - it('should not blow up if crumbs is undefined', function () { - let bidArray = [ - { ...bid, crumbs: undefined } - ] - expect(function () { spec.buildRequests(bidArray) }).not.to.throw() - }) - - it('should place bid information into the p parameter of data', function () { - let placementInfo = spec.buildRequests(bidArray).data.p; - expect(placementInfo).to.equal('[{"placement_id":"adunit-code","callback_id":"30b31c1838de1e","sizes":[[300,250],[300,600]],"bidFloor":0.1}]'); - - bidArray.push({ - bidder: 'yieldmo', - params: { - bidFloor: 0.2 - }, - adUnitCode: 'adunit-code-1', - sizes: [[300, 250], [300, 600]], - bidId: '123456789', - bidderRequestId: '987654321', - auctionId: '0246810', - crumbs: { - pubcid: 'c604130c-0144-4b63-9bf2-c2bd8c8d86da' - } - - }); - - // multiple placements - placementInfo = spec.buildRequests(bidArray).data.p; - expect(placementInfo).to.equal('[{"placement_id":"adunit-code","callback_id":"30b31c1838de1e","sizes":[[300,250],[300,600]],"bidFloor":0.1},{"placement_id":"adunit-code-1","callback_id":"123456789","sizes":[[300,250],[300,600]],"bidFloor":0.2}]'); - }); - - it('should add placement id if given', function () { - bidArray[0].params.placementId = 'ym_1293871298'; - let placementInfo = spec.buildRequests(bidArray).data.p; - expect(placementInfo).to.include('"ym_placement_id":"ym_1293871298"'); - expect(placementInfo).not.to.include('"ym_placement_id":"ym_0987654321"'); - - bidArray[1].params.placementId = 'ym_0987654321'; - placementInfo = spec.buildRequests(bidArray).data.p; - expect(placementInfo).to.include('"ym_placement_id":"ym_1293871298"'); - expect(placementInfo).to.include('"ym_placement_id":"ym_0987654321"'); - }); - - it('should add additional information to data parameter of request', function () { - const data = spec.buildRequests(bidArray).data; - expect(data.hasOwnProperty('page_url')).to.be.true; - expect(data.hasOwnProperty('bust')).to.be.true; - expect(data.hasOwnProperty('pr')).to.be.true; - expect(data.hasOwnProperty('scrd')).to.be.true; - expect(data.dnt).to.be.false; - expect(data.e).to.equal(90); - expect(data.hasOwnProperty('description')).to.be.true; - expect(data.hasOwnProperty('title')).to.be.true; - expect(data.hasOwnProperty('h')).to.be.true; - expect(data.hasOwnProperty('w')).to.be.true; - expect(data.hasOwnProperty('pubcid')).to.be.true; - }); - - it('should add pubcid as parameter of request', function () { - const pubcidBid = { - bidder: 'yieldmo', - params: {}, - adUnitCode: 'adunit-code', - sizes: [[300, 250], [300, 600]], - bidId: '30b31c1838de1e', - bidderRequestId: '22edbae2733bf6', - auctionId: '1d1a030790a475', - userId: { - pubcid: 'c604130c-0144-4b63-9bf2-c2bd8c8d86da2' - } - }; - const data = spec.buildRequests([pubcidBid]).data; - expect(data.pubcid).to.deep.equal('c604130c-0144-4b63-9bf2-c2bd8c8d86da2'); - }); - - it('should add unified id as parameter of request', function () { - const unifiedIdBid = { - bidder: 'yieldmo', - params: {}, - adUnitCode: 'adunit-code', - sizes: [[300, 250], [300, 600]], - bidId: '30b31c1838de1e', - bidderRequestId: '22edbae2733bf6', - auctionId: '1d1a030790a475', - userId: { - tdid, - } - }; - const data = spec.buildRequests([unifiedIdBid]).data; - expect(data.tdid).to.deep.equal(tdid); - }); - }); - - describe('interpretResponse', function () { - let serverResponse; - - beforeEach(function () { - serverResponse = { - body: [{ - callback_id: '21989fdbef550a', - cpm: 3.45455, - width: 300, - height: 250, - ad: '
', - creative_id: '9874652394875' - }], - header: 'header?' - }; - }) - - it('should correctly reorder the server response', function () { - const newResponse = spec.interpretResponse(serverResponse); - expect(newResponse.length).to.be.equal(1); - expect(newResponse[0]).to.deep.equal({ - requestId: '21989fdbef550a', - cpm: 3.45455, - width: 300, - height: 250, - creativeId: '9874652394875', - currency: 'USD', - netRevenue: true, - ttl: 300, - ad: '
' - }); - }); - - it('should not add responses if the cpm is 0 or null', function () { - serverResponse.body[0].cpm = 0; - let response = spec.interpretResponse(serverResponse); - expect(response).to.deep.equal([]); - - serverResponse.body[0].cpm = null; - response = spec.interpretResponse(serverResponse); - expect(response).to.deep.equal([]) - }); - }); - - describe('getUserSync', function () { - const SYNC_ENDPOINT = 'https://static.yieldmo.com/blank.min.html?orig='; - let options = { - iframeEnabled: true, - pixelEnabled: true - }; - - it('should return a tracker with type and url as parameters', function () { - if (/iPhone|iPad|iPod/i.test(window.navigator.userAgent)) { - expect(spec.getUserSync(options)).to.deep.equal([{ - type: 'iframe', - url: SYNC_ENDPOINT + utils.getOrigin() - }]); - - options.iframeEnabled = false; - expect(spec.getUserSync(options)).to.deep.equal([]); - } else { - // not ios, so tracker will fail - expect(spec.getUserSync(options)).to.deep.equal([]); - } - }); - }); -}); diff --git a/test/spec/modules/yieldnexusBidAdapter_spec.js b/test/spec/modules/yieldnexusBidAdapter_spec.js deleted file mode 100644 index 8f2e40d18101..000000000000 --- a/test/spec/modules/yieldnexusBidAdapter_spec.js +++ /dev/null @@ -1,418 +0,0 @@ -import {expect} from 'chai'; -import {spec} from 'modules/yieldnexusBidAdapter'; -import * as utils from 'src/utils'; - -const spid = '123'; - -describe('YieldNexusAdapter', () => { - describe('isBidRequestValid', () => { - it('should validate supply', () => { - expect(spec.isBidRequestValid({params: {}})).to.equal(false); - expect(spec.isBidRequestValid({params: {spid: 123}})).to.equal(false); - expect(spec.isBidRequestValid({params: {spid: '123'}})).to.equal(true); - }); - it('should validate bid floor', () => { - expect(spec.isBidRequestValid({params: {spid: '123'}})).to.equal(true); // bidfloor has a default - expect(spec.isBidRequestValid({params: {spid: '123', bidfloor: '123'}})).to.equal(false); - expect(spec.isBidRequestValid({params: {spid: '123', bidfloor: 0.1}})).to.equal(true); - }); - it('should validate adpos', () => { - expect(spec.isBidRequestValid({params: {spid: '123'}})).to.equal(true); // adpos has a default - expect(spec.isBidRequestValid({params: {spid: '123', adpos: '123'}})).to.equal(false); - expect(spec.isBidRequestValid({params: {spid: '123', adpos: 0.1}})).to.equal(true); - }); - it('should validate instl', () => { - expect(spec.isBidRequestValid({params: {spid: '123'}})).to.equal(true); // adpos has a default - expect(spec.isBidRequestValid({params: {spid: '123', instl: '123'}})).to.equal(false); - expect(spec.isBidRequestValid({params: {spid: '123', instl: -1}})).to.equal(false); - expect(spec.isBidRequestValid({params: {spid: '123', instl: 0}})).to.equal(true); - expect(spec.isBidRequestValid({params: {spid: '123', instl: 1}})).to.equal(true); - expect(spec.isBidRequestValid({params: {spid: '123', instl: 2}})).to.equal(false); - }); - }); - describe('buildRequests', () => { - const bidRequest = { - 'adUnitCode': 'adunit-code', - 'auctionId': 'fdkhjg3s7ahjja', - 'mediaTypes': { - banner: {} - }, - 'params': {spid}, - 'sizes': [[300, 250], [300, 600]] - }; - - it('returns an array', () => { - let response; - - response = spec.buildRequests([]); - expect(Array.isArray(response)).to.equal(true); - expect(response.length).to.equal(0); - - response = spec.buildRequests([bidRequest]); - expect(Array.isArray(response)).to.equal(true); - expect(response.length).to.equal(1); - - const adUnit1 = Object.assign({}, utils.deepClone(bidRequest), {auctionId: '1', adUnitCode: 'a'}); - const adUnit2 = Object.assign({}, utils.deepClone(bidRequest), {auctionId: '1', adUnitCode: 'b'}); - response = spec.buildRequests([adUnit1, adUnit2]); - expect(Array.isArray(response)).to.equal(true); - expect(response.length).to.equal(2); - }); - - it('uses yieldnexus dns', () => { - const response = spec.buildRequests([bidRequest])[0]; - expect(response.method).to.equal('POST'); - expect(response.url).to.match(new RegExp(`^https://ssp\\.ynxs\\.io/r/${spid}/bidr\\?bidder=prebid&rformat=open_rtb&reqformat=rtb_json$`, 'g')); - expect(response.data.id).to.equal(bidRequest.auctionId); - }); - - it('builds request correctly', () => { - let stub = sinon.stub(utils, 'getTopWindowUrl').returns('http://www.test.com/page.html'); - - let response; - response = spec.buildRequests([bidRequest])[0]; - expect(response.data.site.domain).to.equal('www.test.com'); - expect(response.data.site.page).to.equal('http://www.test.com/page.html'); - expect(response.data.site.ref).to.equal(''); - expect(response.data.imp.length).to.equal(1); - expect(response.data.imp[0].id).to.equal(bidRequest.transactionId); - expect(response.data.imp[0].instl).to.equal(0); - expect(response.data.imp[0].tagid).to.equal(bidRequest.adUnitCode); - expect(response.data.imp[0].bidfloor).to.equal(0); - expect(response.data.imp[0].bidfloorcur).to.equal('USD'); - - const bidRequestWithInstlEquals1 = utils.deepClone(bidRequest); - bidRequestWithInstlEquals1.params.instl = 1; - response = spec.buildRequests([bidRequestWithInstlEquals1])[0]; - expect(response.data.imp[0].instl).to.equal(bidRequestWithInstlEquals1.params.instl); - - const bidRequestWithInstlEquals0 = utils.deepClone(bidRequest); - bidRequestWithInstlEquals0.params.instl = 1; - response = spec.buildRequests([bidRequestWithInstlEquals0])[0]; - expect(response.data.imp[0].instl).to.equal(bidRequestWithInstlEquals0.params.instl); - - const bidRequestWithBidfloorEquals1 = utils.deepClone(bidRequest); - bidRequestWithBidfloorEquals1.params.bidfloor = 1; - response = spec.buildRequests([bidRequestWithBidfloorEquals1])[0]; - expect(response.data.imp[0].bidfloor).to.equal(bidRequestWithBidfloorEquals1.params.bidfloor); - - stub.restore(); - }); - - it('builds request banner object correctly', () => { - let response; - - const bidRequestWithBanner = utils.deepClone(bidRequest); - bidRequestWithBanner.mediaTypes = { - banner: { - sizes: [[300, 250], [120, 600]] - } - }; - - response = spec.buildRequests([bidRequestWithBanner])[0]; - expect(response.data.imp[0].banner.w).to.equal(bidRequestWithBanner.mediaTypes.banner.sizes[0][0]); - expect(response.data.imp[0].banner.h).to.equal(bidRequestWithBanner.mediaTypes.banner.sizes[0][1]); - expect(response.data.imp[0].banner.pos).to.equal(0); - expect(response.data.imp[0].banner.topframe).to.equal(0); - - const bidRequestWithPosEquals1 = utils.deepClone(bidRequestWithBanner); - bidRequestWithPosEquals1.params.pos = 1; - response = spec.buildRequests([bidRequestWithPosEquals1])[0]; - expect(response.data.imp[0].banner.pos).to.equal(bidRequestWithPosEquals1.params.pos); - }); - - it('builds request video object correctly', () => { - let response; - - const bidRequestWithVideo = utils.deepClone(bidRequest); - bidRequestWithVideo.mediaTypes = { - video: { - sizes: [[300, 250], [120, 600]] - } - }; - - response = spec.buildRequests([bidRequestWithVideo])[0]; - expect(response.data.imp[0].video.w).to.equal(bidRequestWithVideo.mediaTypes.video.sizes[0][0]); - expect(response.data.imp[0].video.h).to.equal(bidRequestWithVideo.mediaTypes.video.sizes[0][1]); - expect(response.data.imp[0].video.pos).to.equal(0); - expect(response.data.imp[0].video.topframe).to.equal(0); - - const bidRequestWithPosEquals1 = utils.deepClone(bidRequestWithVideo); - bidRequestWithPosEquals1.params.pos = 1; - response = spec.buildRequests([bidRequestWithPosEquals1])[0]; - expect(response.data.imp[0].video.pos).to.equal(bidRequestWithPosEquals1.params.pos); - }); - - it('builds request video object correctly with multi-dimensions size array', function () { - let bidRequestWithVideo = utils.deepClone(bidRequest); - bidRequestWithVideo.mediaTypes.video = { - playerSize: [[304, 254], [305, 255]], - context: 'instream' - }; - - let response = spec.buildRequests([bidRequestWithVideo], bidRequest)[0]; - expect(response.data.imp[0].video.w).to.equal(304); - expect(response.data.imp[0].video.h).to.equal(254); - - bidRequestWithVideo = utils.deepClone(bidRequest); - bidRequestWithVideo.mediaTypes.video = { - playerSize: [304, 254] - }; - - response = spec.buildRequests([bidRequestWithVideo], bidRequest)[0]; - expect(response.data.imp[0].video.w).to.equal(304); - expect(response.data.imp[0].video.h).to.equal(254); - }); - }); - describe('interpretResponse', () => { - const bannerBidRequest = { - 'adUnitCode': 'adunit-code', - 'auctionId': 'fdkhjg3s7ahjja', - 'mediaTypes': { - banner: {} - }, - 'params': { - 'spid': spid - }, - 'sizes': [[300, 250], [300, 600]], - 'bidId': '111' - }; - const videoBidRequest = { - 'adUnitCode': 'adunit-code', - 'auctionId': 'fdkhjg3s7ahjja', - 'mediaTypes': { - video: {} - }, - 'params': { - 'spid': spid - }, - 'sizes': [[300, 250], [300, 600]], - 'bidId': '111' - }; - const rtbResponse = { - 'id': 'imp_5b05b9fde4b09084267a556f', - 'bidid': 'imp_5b05b9fde4b09084267a556f', - 'cur': 'USD', - 'ext': { - 'utrk': [ - {'type': 'iframe', 'url': '//ssp.ynxs.io/user/sync/1'}, - {'type': 'image', 'url': '//ssp.ynxs.io/user/sync/2'} - ] - }, - 'seatbid': [ - { - 'seat': 'testSeatBidA', - 'bid': [ - { - 'id': '0', - 'impid': '1', - 'price': 2.016, - 'adm': '', - 'adomain': ['nike.com'], - 'h': 600, - 'w': 120, - 'ext': { - 'vast_url': 'http://vast.tag.com', - 'utrk': [ - {'type': 'iframe', 'url': '//pix.usersync.io/user-sync'} - ] - } - } - ] - }, - { - 'seat': 'testSeatBidB', - 'bid': [ - { - 'id': '1', - 'impid': '1', - 'price': 3, - 'adid': '542jlhdfd2112jnjf3x', - 'adm': '', - 'adomain': ['adidas.com'], - 'h': 250, - 'w': 300, - 'ext': { - 'utrk': [ - {'type': 'image', 'url': '//pix.usersync.io/user-sync'} - ] - } - } - ] - } - ] - }; - it('fails gracefully on empty response body', () => { - let response; - - response = spec.interpretResponse(undefined, {bidRequest: bannerBidRequest}); - expect(Array.isArray(response)).to.equal(true); - expect(response.length).to.equal(0); - - response = spec.interpretResponse({}, {bidRequest: bannerBidRequest}); - expect(Array.isArray(response)).to.equal(true); - expect(response.length).to.equal(0); - }); - it('collects banner bids', () => { - const response = spec.interpretResponse({body: rtbResponse}, {bidRequest: bannerBidRequest}); - expect(Array.isArray(response)).to.equal(true); - expect(response.length).to.equal(1); - - const ad0 = response[0]; - expect(ad0.requestId).to.equal(bannerBidRequest.bidId); - expect(ad0.cpm).to.equal(rtbResponse.seatbid[1].bid[0].price); - expect(ad0.width).to.equal(rtbResponse.seatbid[1].bid[0].w); - expect(ad0.height).to.equal(rtbResponse.seatbid[1].bid[0].h); - expect(ad0.ttl).to.equal(15 * 60); - expect(ad0.creativeId).to.equal(rtbResponse.seatbid[1].bid[0].crid); - expect(ad0.netRevenue).to.equal(true); - expect(ad0.currency).to.equal(rtbResponse.seatbid[1].bid[0].cur || rtbResponse.cur || 'USD'); - expect(ad0.ad).to.equal(rtbResponse.seatbid[1].bid[0].adm); - expect(ad0.vastXml).to.be.an('undefined'); - expect(ad0.vastUrl).to.be.an('undefined'); - }); - it('collects video bids', () => { - const response = spec.interpretResponse({body: rtbResponse}, {bidRequest: videoBidRequest}); - expect(Array.isArray(response)).to.equal(true); - expect(response.length).to.equal(1); - - const ad0 = response[0]; - expect(ad0.requestId).to.equal(videoBidRequest.bidId); - expect(ad0.cpm).to.equal(rtbResponse.seatbid[0].bid[0].price); - expect(ad0.width).to.equal(rtbResponse.seatbid[0].bid[0].w); - expect(ad0.height).to.equal(rtbResponse.seatbid[0].bid[0].h); - expect(ad0.ttl).to.equal(15 * 60); - expect(ad0.creativeId).to.equal(rtbResponse.seatbid[0].bid[0].crid); - expect(ad0.netRevenue).to.equal(true); - expect(ad0.currency).to.equal(rtbResponse.seatbid[0].bid[0].cur || rtbResponse.cur || 'USD'); - expect(ad0.ad).to.be.an('undefined'); - expect(ad0.vastXml).to.equal(rtbResponse.seatbid[0].bid[0].adm); - expect(ad0.vastUrl).to.equal(rtbResponse.seatbid[0].bid[0].ext.vast_url); - }); - - it('applies user-syncs', () => { - const response = spec.getUserSyncs({}, [{body: rtbResponse}]); - expect(Array.isArray(response)).to.equal(true); - expect(response.length).to.equal(4); - expect(response[0].type).to.equal(rtbResponse.ext.utrk[0].type); - expect(response[0].url).to.equal(rtbResponse.ext.utrk[0].url + '?gc=missing'); - expect(response[1].type).to.equal(rtbResponse.ext.utrk[1].type); - expect(response[1].url).to.equal(rtbResponse.ext.utrk[1].url + '?gc=missing'); - expect(response[2].type).to.equal(rtbResponse.seatbid[0].bid[0].ext.utrk[0].type); - expect(response[2].url).to.equal(rtbResponse.seatbid[0].bid[0].ext.utrk[0].url + '?gc=missing'); - expect(response[3].type).to.equal(rtbResponse.seatbid[1].bid[0].ext.utrk[0].type); - expect(response[3].url).to.equal(rtbResponse.seatbid[1].bid[0].ext.utrk[0].url + '?gc=missing'); - }); - - it('supports outstream renderers', function () { - const videoResponse = { - 'id': '64f32497-b2f7-48ec-9205-35fc39894d44', - 'bidid': 'imp_5c24924de4b0d106447af333', - 'cur': 'USD', - 'seatbid': [ - { - 'seat': '3668', - 'group': 0, - 'bid': [ - { - 'id': 'gb_1', - 'impid': 'afbb5852-7cea-4a81-aa9a-a41aab505c23', - 'price': 5.0, - 'adid': '1274', - 'nurl': 'https://rtb.gamoshi.io/pix/1275/win_notice/imp_5c24924de4b0d106447af333/im.gif?r=imp_5c24924de4b0d106447af333&i=afbb5852-7cea-4a81-aa9a-a41aab505c23&a=1274&b=gb_1&p=${AUCTION_PRICE}', - 'adomain': [], - 'adm': '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n', - 'cid': '3668', - 'crid': '1274', - 'cat': [], - 'attr': [], - 'h': 250, - 'w': 300, - 'ext': { - 'vast_url': 'https://rtb.gamoshi.io/pix/1275/vast_o/imp_5c24924de4b0d106447af333/im.xml?r=imp_5c24924de4b0d106447af333&i=afbb5852-7cea-4a81-aa9a-a41aab505c23&a=1274&b=gb_1&w=300&h=250&vatu=aHR0cHM6Ly9zdGF0aWMuZ2FtYmlkLmlvL2RlbW8vdmFzdC54bWw&vwarv', - 'imptrackers': [ - 'https://rtb.gamoshi.io/pix/1275/imp/imp_5c24924de4b0d106447af333/im.gif?r=imp_5c24924de4b0d106447af333&i=afbb5852-7cea-4a81-aa9a-a41aab505c23&a=1274&b=gb_1'] - } - } - ] - } - ], - 'ext': { - 'utrk': [{ - 'type': 'image', - 'url': 'https://rtb.gamoshi.io/pix/1275/scm?cb=1545900621675' - }] - } - }; - const videoRequest = utils.deepClone(videoBidRequest); - videoRequest.mediaTypes.video.context = 'outstream'; - const result = spec.interpretResponse({body: videoResponse}, {bidRequest: videoRequest}); - expect(result[0].renderer).to.not.equal(undefined); - }); - - it('supports gdpr consent', function () { - let videoResponse = { - 'id': '64f32497-b2f7-48ec-9205-35fc39894d44', - 'bidid': 'imp_5c24924de4b0d106447af333', - 'cur': 'USD', - 'seatbid': [ - { - 'seat': '3668', - 'group': 0, - 'bid': [ - { - 'id': 'gb_1', - 'impid': 'afbb5852-7cea-4a81-aa9a-a41aab505c23', - 'price': 5.0, - 'adid': '1274', - 'nurl': 'https://rtb.gamoshi.io/pix/1275/win_notice/imp_5c24924de4b0d106447af333/im.gif?r=imp_5c24924de4b0d106447af333&i=afbb5852-7cea-4a81-aa9a-a41aab505c23&a=1274&b=gb_1&p=${AUCTION_PRICE}', - 'adomain': [], - 'adm': '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n', - 'cid': '3668', - 'crid': '1274', - 'cat': [], - 'attr': [], - 'h': 250, - 'w': 300, - 'ext': { - 'vast_url': 'https://rtb.gamoshi.io/pix/1275/vast_o/imp_5c24924de4b0d106447af333/im.xml?r=imp_5c24924de4b0d106447af333&i=afbb5852-7cea-4a81-aa9a-a41aab505c23&a=1274&b=gb_1&w=300&h=250&vatu=aHR0cHM6Ly9zdGF0aWMuZ2FtYmlkLmlvL2RlbW8vdmFzdC54bWw&vwarv', - 'imptrackers': [ - 'https://rtb.gamoshi.io/pix/1275/imp/imp_5c24924de4b0d106447af333/im.gif?r=imp_5c24924de4b0d106447af333&i=afbb5852-7cea-4a81-aa9a-a41aab505c23&a=1274&b=gb_1'] - } - } - ] - } - ], - 'ext': { - 'utrk': [{ - 'type': 'image', - 'url': 'https://rtb.gamoshi.io/pix/1275/scm?cb=1545900621675' - }] - } - }; - let gdprConsent = { - gdprApplies: true, - consentString: 'consent string' - }; - let result = spec.getUserSyncs({}, [{body: videoResponse}], gdprConsent); - expect(result).to.be.an('array'); - expect(result.length).to.equal(1); - expect(result[0].type).to.equal('image'); - expect(result[0].url).to.equal('https://rtb.gamoshi.io/pix/1275/scm?cb=1545900621675&gc=consent%20string'); - - gdprConsent.gdprApplies = false; - result = spec.getUserSyncs({}, [{body: videoResponse}], gdprConsent); - expect(result).to.be.an('array'); - expect(result.length).to.equal(1); - expect(result[0].type).to.equal('image'); - expect(result[0].url).to.equal('https://rtb.gamoshi.io/pix/1275/scm?cb=1545900621675&gc=missing'); - - videoResponse.ext.utrk[0].url = 'https://rtb.gamoshi.io/pix/1275/scm'; - result = spec.getUserSyncs({}, [{body: videoResponse}], gdprConsent); - expect(result).to.be.an('array'); - expect(result.length).to.equal(1); - expect(result[0].type).to.equal('image'); - expect(result[0].url).to.equal('https://rtb.gamoshi.io/pix/1275/scm?gc=missing'); - }); - }); -}); diff --git a/test/spec/modules/yieldoneBidAdapter_spec.js b/test/spec/modules/yieldoneBidAdapter_spec.js deleted file mode 100644 index abc579514efb..000000000000 --- a/test/spec/modules/yieldoneBidAdapter_spec.js +++ /dev/null @@ -1,236 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/yieldoneBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; - -const ENDPOINT = 'https://y.one.impact-ad.jp/h_bid'; -const USER_SYNC_URL = 'https://y.one.impact-ad.jp/push_sync'; -const VIDEO_PLAYER_URL = 'https://img.ak.impact-ad.jp/ic/pone/ivt/firstview/js/dac-video-prebid.min.js'; - -describe('yieldoneBidAdapter', function() { - const adapter = newBidder(spec); - - describe('isBidRequestValid', function () { - let bid = { - 'bidder': 'yieldone', - 'params': { - placementId: '36891' - }, - 'adUnitCode': 'adunit-code', - 'sizes': [[300, 250], [336, 280]], - 'bidId': '23beaa6af6cdde', - 'bidderRequestId': '19c0c1efdf37e7', - 'auctionId': '61466567-d482-4a16-96f0-fe5f25ffbdf1', - }; - - it('should return true when required params found', function () { - expect(spec.isBidRequestValid(bid)).to.equal(true); - }); - - it('should return false when placementId not passed correctly', function () { - bid.params.placementId = ''; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - - it('should return false when require params are not passed', function () { - let bid = Object.assign({}, bid); - bid.params = {}; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - }); - - describe('buildRequests', function () { - let bidRequests = [ - { - 'bidder': 'yieldone', - 'params': { - placementId: '36891' - }, - 'adUnitCode': 'adunit-code1', - 'sizes': [[300, 250], [336, 280]], - 'bidId': '23beaa6af6cdde', - 'bidderRequestId': '19c0c1efdf37e7', - 'auctionId': '61466567-d482-4a16-96f0-fe5f25ffbdf1', - }, - { - 'bidder': 'yieldone', - 'params': { - placementId: '47919' - }, - 'adUnitCode': 'adunit-code2', - 'sizes': [[300, 250]], - 'bidId': '382091349b149f"', - 'bidderRequestId': '"1f9c98192de251"', - 'auctionId': '61466567-d482-4a16-96f0-fe5f25ffbdf1', - } - ]; - - const request = spec.buildRequests(bidRequests); - - it('sends bid request to our endpoint via GET', function () { - expect(request[0].method).to.equal('GET'); - expect(request[1].method).to.equal('GET'); - }); - - it('attaches source and version to endpoint URL as query params', function () { - expect(request[0].url).to.equal(ENDPOINT); - expect(request[1].url).to.equal(ENDPOINT); - }); - - it('parameter sz has more than one size on banner requests', function () { - expect(request[0].data.sz).to.equal('300x250,336x280'); - expect(request[1].data.sz).to.equal('300x250'); - }); - - it('width and height should be set as separate parameters on outstream requests', function () { - const bidRequest = Object.assign({}, bidRequests[0]); - bidRequest.mediaTypes = {}; - bidRequest.mediaTypes.video = {context: 'outstream'}; - const request = spec.buildRequests([bidRequest]); - expect(request[0].data.w).to.equal('300'); - expect(request[0].data.h).to.equal('250'); - }); - - it('adUnitCode should be sent as uc parameters on any requests', function () { - expect(request[0].data.uc).to.equal('adunit-code1'); - expect(request[1].data.uc).to.equal('adunit-code2'); - }); - }); - - describe('interpretResponse', function () { - let bidRequestBanner = [ - { - 'method': 'GET', - 'url': 'https://y.one.impact-ad.jp/h_bid', - 'data': { - 'v': 'hb1', - 'p': '36891', - 'sz': '300x250,336x280', - 'cb': 12892917383, - 'r': 'http%3A%2F%2Flocalhost%3A9876%2F%3Fid%3D74552836', - 'uid': '23beaa6af6cdde', - 't': 'i' - } - } - ]; - - let serverResponseBanner = { - body: { - 'adTag': '', - 'uid': '23beaa6af6cdde', - 'height': 250, - 'width': 300, - 'cpm': 0.0536616, - 'crid': '2494768', - 'currency': 'JPY', - 'statusMessage': 'Bid available', - 'dealId': 'P1-FIX-7800-DSP-MON' - } - }; - - it('should get the correct bid response for banner', function () { - let expectedResponse = [{ - 'requestId': '23beaa6af6cdde', - 'cpm': 53.6616, - 'width': 300, - 'height': 250, - 'creativeId': '2494768', - 'dealId': 'P1-FIX-7800-DSP-MON', - 'currency': 'JPY', - 'netRevenue': true, - 'ttl': 3000, - 'referrer': '', - 'mediaType': 'banner', - 'ad': '' - }]; - let result = spec.interpretResponse(serverResponseBanner, bidRequestBanner[0]); - expect(Object.keys(result[0])).to.deep.equal(Object.keys(expectedResponse[0])); - expect(result[0].mediaType).to.equal(expectedResponse[0].mediaType); - }); - - let serverResponseVideo = { - body: { - 'uid': '23beaa6af6cdde', - 'height': 360, - 'width': 640, - 'cpm': 0.0536616, - 'dealId': 'P1-FIX-766-DSP-MON', - 'crid': '2494768', - 'currency': 'JPY', - 'statusMessage': 'Bid available', - 'adm': '' - } - }; - - let bidRequestVideo = [ - { - 'method': 'GET', - 'url': 'https://y.one.impact-ad.jp/h_bid', - 'data': { - 'v': 'hb1', - 'p': '41993', - 'w': '640', - 'h': '360', - 'cb': 12892917383, - 'r': 'http%3A%2F%2Flocalhost%3A9876%2F%3Fid%3D74552836', - 'uid': '23beaa6af6cdde', - 't': 'i' - } - } - ]; - - it('should get the correct bid response for video', function () { - let expectedResponse = [{ - 'requestId': '23beaa6af6cdde', - 'cpm': 53.6616, - 'width': 640, - 'height': 360, - 'creativeId': '2494768', - 'dealId': 'P1-FIX-7800-DSP-MON', - 'currency': 'JPY', - 'netRevenue': true, - 'ttl': 3000, - 'referrer': '', - 'mediaType': 'video', - 'vastXml': '', - 'renderer': { - id: '23beaa6af6cdde', - url: VIDEO_PLAYER_URL - } - }]; - let result = spec.interpretResponse(serverResponseVideo, bidRequestVideo[0]); - expect(Object.keys(result[0])).to.deep.equal(Object.keys(expectedResponse[0])); - expect(result[0].mediaType).to.equal(expectedResponse[0].mediaType); - expect(result[0].renderer.id).to.equal(expectedResponse[0].renderer.id); - expect(result[0].renderer.url).to.equal(expectedResponse[0].renderer.url); - }); - - it('handles empty bid response', function () { - let response = { - body: { - 'uid': '2c0b634db95a01', - 'height': 0, - 'crid': '', - 'statusMessage': 'Bid returned empty or error response', - 'width': 0, - 'cpm': 0 - } - }; - let result = spec.interpretResponse(response, bidRequestBanner[0]); - expect(result.length).to.equal(0); - }); - }); - - describe('getUserSyncs', function () { - it('handles empty sync options', function () { - expect(spec.getUserSyncs({})).to.be.undefined; - }); - - it('should return a sync url if iframe syncs are enabled', function () { - expect(spec.getUserSyncs({ - 'iframeEnabled': true - })).to.deep.equal([{ - type: 'iframe', url: USER_SYNC_URL - }]); - }); - }); -}); diff --git a/test/spec/modules/yuktamediaAnalyticsAdaptor_spec.js b/test/spec/modules/yuktamediaAnalyticsAdaptor_spec.js deleted file mode 100644 index f6efa077f35b..000000000000 --- a/test/spec/modules/yuktamediaAnalyticsAdaptor_spec.js +++ /dev/null @@ -1,177 +0,0 @@ -import yuktamediaAnalyticsAdapter from 'modules/yuktamediaAnalyticsAdapter'; -import { expect } from 'chai'; -let adapterManager = require('src/adapterManager').default; -let events = require('src/events'); -let constants = require('src/constants.json'); - -describe('YuktaMedia analytics adapter', function () { - let xhr; - let requests; - - beforeEach(function () { - xhr = sinon.useFakeXMLHttpRequest(); - requests = []; - xhr.onCreate = request => requests.push(request); - sinon.stub(events, 'getEvents').returns([]); - }); - - afterEach(function () { - xhr.restore(); - events.getEvents.restore(); - }); - - describe('track', function () { - let initOptions = { - pubId: '1', - pubKey: 'ZXlKaGJHY2lPaUpJVXpJMU5pSjkuT==' - }; - - adapterManager.registerAnalyticsAdapter({ - code: 'yuktamedia', - adapter: yuktamediaAnalyticsAdapter - }); - - beforeEach(function () { - adapterManager.enableAnalytics({ - provider: 'yuktamedia', - options: initOptions - }); - }); - - afterEach(function () { - yuktamediaAnalyticsAdapter.disableAnalytics(); - }); - - it('builds and sends auction data', function () { - let auctionTimestamp = 1496510254313; - let bidRequest = { - 'bidderCode': 'appnexus', - 'auctionId': 'a5b849e5-87d7-4205-8300-d063084fcfb7', - 'bidderRequestId': '173209942f8bdd', - 'bids': [{ - 'bidder': 'appnexus', - 'params': { - 'placementId': '10433394' - }, - 'crumbs': { - 'pubcid': '9a2a4e71-f39b-405f-aecc-19efc22b618d' - }, - 'adUnitCode': 'div-gpt-ad-1438287399331-0', - 'transactionId': '2f481ff1-8d20-4c28-8e36-e384e9e3eec6', - 'sizes': [ - [300, 250], - [300, 600] - ], - 'bidId': '2eddfdc0c791dc', - 'bidderRequestId': '173209942f8bdd', - 'auctionId': 'a5b849e5-87d7-4205-8300-d063084fcfb7' - } - ], - 'auctionStart': 1522265863591, - 'timeout': 3000, - 'start': 1522265863600, - 'doneCbCallCount': 1 - }; - let bidResponse = { - 'height': 250, - 'statusMessage': 'Bid available', - 'adId': '2eddfdc0c791dc', - 'mediaType': 'banner', - 'source': 'client', - 'requestId': '2eddfdc0c791dc', - 'cpm': 0.5, - 'creativeId': 29681110, - 'currency': 'USD', - 'netRevenue': true, - 'ttl': 300, - 'auctionId': 'a5b849e5-87d7-4205-8300-d063084fcfb7', - 'responseTimestamp': 1522265866110, - 'requestTimestamp': 1522265863600, - 'bidder': 'appnexus', - 'adUnitCode': 'div-gpt-ad-1438287399331-0', - 'timeToRespond': 2510, - 'size': '300x250' - }; - let bidTimeoutArgsV1 = [ - { - bidId: '2baa51527bd015', - bidder: 'bidderOne', - adUnitCode: '/19968336/header-bid-tag-0', - auctionId: '66529d4c-8998-47c2-ab3e-5b953490b98f' - }, - { - bidId: '6fe3b4c2c23092', - bidder: 'bidderTwo', - adUnitCode: '/19968336/header-bid-tag-0', - auctionId: '66529d4c-8998-47c2-ab3e-5b953490b98f' - } - ]; - let bid = { - 'bidderCode': 'appnexus', - 'bidId': '2eddfdc0c791dc', - 'adUnitCode': 'div-gpt-ad-1438287399331-0', - 'requestId': '173209942f8bdd', - 'auctionId': 'a5b849e5-87d7-4205-8300-d063084fcfb7', - 'renderStatus': 2, - 'cpm': 0.5, - 'creativeId': 29681110, - 'currency': 'USD', - 'mediaType': 'banner', - 'netRevenue': true, - 'requestTimestamp': 1522265863600, - 'responseTimestamp': 1522265866110, - 'sizes': '300x250,300x600', - 'statusMessage': 'Bid available', - 'timeToRespond': 2510 - } - - // Step 1: Send auction init event - events.emit(constants.EVENTS.AUCTION_INIT, { - timestamp: auctionTimestamp - }); - - // Step 2: Send bid requested event - events.emit(constants.EVENTS.BID_REQUESTED, bidRequest); - - // Step 3: Send bid response event - events.emit(constants.EVENTS.BID_RESPONSE, bidResponse); - - // Step 4: Send bid time out event - events.emit(constants.EVENTS.BID_TIMEOUT, bidTimeoutArgsV1); - - // Step 5: Send auction end event - events.emit(constants.EVENTS.AUCTION_END, {}, 'auctionEnd'); - - expect(requests.length).to.equal(1); - - let auctionEventData = JSON.parse(requests[0].requestBody); - - expect(auctionEventData.bids.length).to.equal(1); - expect(auctionEventData.bids[0]).to.deep.equal(bid); - - expect(auctionEventData.initOptions).to.deep.equal(initOptions); - - // Step 6: Send auction bid won event - events.emit(constants.EVENTS.BID_WON, { - 'bidderCode': 'appnexus', - 'statusMessage': 'Bid available', - 'adId': '108abedd106b669', - 'auctionId': '6355d610-7cdc-4009-a866-f91997fd24bb', - 'responseTimestamp': 1522144433058, - 'requestTimestamp': 1522144432923, - 'bidder': 'appnexus', - 'adUnitCode': 'div-gpt-ad-1438287399331-0', - 'timeToRespond': 135, - 'size': '300x250', - 'status': 'rendered' - }, 'won'); - - expect(requests.length).to.equal(2); - - let winEventData = JSON.parse(requests[1].requestBody); - - expect(winEventData.bidWon.status).to.equal('rendered'); - expect(winEventData.initOptions).to.deep.equal(initOptions); - }); - }); -}); diff --git a/test/spec/modules/zedoBidAdapter_spec.js b/test/spec/modules/zedoBidAdapter_spec.js deleted file mode 100644 index f6702e6f4590..000000000000 --- a/test/spec/modules/zedoBidAdapter_spec.js +++ /dev/null @@ -1,354 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/zedoBidAdapter'; - -describe('The ZEDO bidding adapter', function () { - describe('isBidRequestValid', function () { - it('should return false when given an invalid bid', function () { - const bid = { - bidder: 'zedo', - }; - const isValid = spec.isBidRequestValid(bid); - expect(isValid).to.equal(false); - }); - - it('should return true when given a channelcode bid', function () { - const bid = { - bidder: 'zedo', - params: { - channelCode: 20000000, - dimId: 9 - }, - }; - const isValid = spec.isBidRequestValid(bid); - expect(isValid).to.equal(true); - }); - }); - - describe('buildRequests', function () { - const bidderRequest = { - timeout: 3000, - }; - - it('should properly build a channelCode request for dim Id with type not defined', function () { - const bidRequests = [ - { - bidder: 'zedo', - adUnitCode: 'p12345', - transactionId: '12345667', - sizes: [[300, 200]], - params: { - channelCode: 20000000, - dimId: 10, - pubId: 1 - }, - }, - ]; - const request = spec.buildRequests(bidRequests, bidderRequest); - expect(request.url).to.match(/^https:\/\/saxp.zedo.com\/asw\/fmh.json/); - expect(request.method).to.equal('GET'); - const zedoRequest = request.data; - expect(zedoRequest).to.equal('g={"placements":[{"network":20,"channel":0,"publisher":1,"width":300,"height":200,"dimension":10,"version":"$prebid.version$","keyword":"","transactionId":"12345667","renderers":[{"name":"display"}]}]}'); - }); - - it('should properly build a channelCode request for video with type defined', function () { - const bidRequests = [ - { - bidder: 'zedo', - adUnitCode: 'p12345', - transactionId: '12345667', - sizes: [640, 480], - mediaTypes: { - video: { - context: 'instream', - }, - }, - params: { - channelCode: 20000000, - dimId: 85 - }, - }, - ]; - const request = spec.buildRequests(bidRequests, bidderRequest); - expect(request.url).to.match(/^https:\/\/saxp.zedo.com\/asw\/fmh.json/); - expect(request.method).to.equal('GET'); - const zedoRequest = request.data; - expect(zedoRequest).to.equal('g={"placements":[{"network":20,"channel":0,"publisher":0,"width":640,"height":480,"dimension":85,"version":"$prebid.version$","keyword":"","transactionId":"12345667","renderers":[{"name":"Inarticle"}]}]}'); - }); - - describe('buildGDPRRequests', function () { - let consentString = 'BOJ8RZsOJ8RZsABAB8AAAAAZ+A=='; - const bidderRequest = { - timeout: 3000, - gdprConsent: { - 'consentString': consentString, - 'gdprApplies': true - } - }; - - it('should properly build request with gdpr consent', function () { - const bidRequests = [ - { - bidder: 'zedo', - adUnitCode: 'p12345', - transactionId: '12345667', - sizes: [[300, 200]], - params: { - channelCode: 20000000, - dimId: 10 - }, - }, - ]; - const request = spec.buildRequests(bidRequests, bidderRequest); - expect(request.method).to.equal('GET'); - const zedoRequest = request.data; - expect(zedoRequest).to.equal('g={"placements":[{"network":20,"channel":0,"publisher":0,"width":300,"height":200,"dimension":10,"version":"$prebid.version$","keyword":"","transactionId":"12345667","renderers":[{"name":"display"}]}],"gdpr":1,"gdpr_consent":"BOJ8RZsOJ8RZsABAB8AAAAAZ+A=="}'); - }); - }); - }); - describe('interpretResponse', function () { - it('should return an empty array when there is bid response', function () { - const response = {}; - const request = { bidRequests: [] }; - const bids = spec.interpretResponse(response, request); - expect(bids).to.have.lengthOf(0); - }); - - it('should properly parse a bid response with no valid creative', function () { - const response = { - body: { - ad: [ - { - 'slotId': 'ad1d762', - 'network': '2000', - 'creatives': [ - { - 'adId': '12345', - 'height': '600', - 'width': '160', - 'isFoc': true, - 'creativeDetails': { - 'type': 'StdBanner', - 'adContent': { - 'focImage': { - 'url': 'https://c13.zedo.com/OzoDB/0/0/0/blank.gif', - 'target': '_blank', - } - } - }, - 'cpm': '0' - } - ] - } - ] - } - }; - const request = { - bidRequests: [{ - bidder: 'zedo', - adUnitCode: 'p12345', - bidId: 'test-bidId', - params: { - channelCode: 2000000, - dimId: 9 - } - }] - }; - const bids = spec.interpretResponse(response, request); - expect(bids).to.have.lengthOf(0); - }); - - it('should properly parse a bid response with valid display creative', function () { - const response = { - body: { - ad: [ - { - 'slotId': 'ad1d762', - 'network': '2000', - 'creatives': [ - { - 'adId': '12345', - 'height': '600', - 'width': '160', - 'isFoc': true, - 'creativeDetails': { - 'type': 'StdBanner', - 'adContent': '' - }, - 'cpm': '1200000' - } - ] - } - ] - } - }; - const request = { - bidRequests: [{ - bidder: 'zedo', - adUnitCode: 'test-requestId', - bidId: 'test-bidId', - params: { - channelCode: 2000000, - dimId: 9 - }, - }] - }; - const bids = spec.interpretResponse(response, request); - expect(bids).to.have.lengthOf(1); - expect(bids[0].requestId).to.equal('ad1d762'); - expect(bids[0].cpm).to.equal(0.72); - expect(bids[0].width).to.equal('160'); - expect(bids[0].height).to.equal('600'); - }); - - it('should properly parse a bid response with valid video creative', function () { - const response = { - body: { - ad: [ - { - 'slotId': 'ad1d762', - 'network': '2000', - 'creatives': [ - { - 'adId': '12345', - 'height': '480', - 'width': '640', - 'isFoc': true, - 'creativeDetails': { - 'type': 'VAST', - 'adContent': '' - }, - 'cpm': '1200000' - } - ] - } - ] - } - }; - const request = { - bidRequests: [{ - bidder: 'zedo', - adUnitCode: 'test-requestId', - bidId: 'test-bidId', - params: { - channelCode: 2000000, - dimId: 85 - }, - }] - }; - - const bids = spec.interpretResponse(response, request); - expect(bids).to.have.lengthOf(1); - expect(bids[0].requestId).to.equal('ad1d762'); - expect(bids[0].cpm).to.equal(0.78); - expect(bids[0].width).to.equal('640'); - expect(bids[0].height).to.equal('480'); - expect(bids[0].adType).to.equal('VAST'); - expect(bids[0].vastXml).to.not.equal(''); - expect(bids[0].ad).to.be.an('undefined'); - expect(bids[0].renderer).not.to.be.an('undefined'); - }); - }); - - describe('user sync', function () { - it('should register the iframe sync url', function () { - let syncs = spec.getUserSyncs({ - iframeEnabled: true - }); - expect(syncs).to.not.be.an('undefined'); - expect(syncs).to.have.lengthOf(1); - expect(syncs[0].type).to.equal('iframe'); - }); - - it('should pass gdpr params', function () { - let syncs = spec.getUserSyncs({ iframeEnabled: true }, {}, { - gdprApplies: false, consentString: 'test' - }); - expect(syncs).to.not.be.an('undefined'); - expect(syncs).to.have.lengthOf(1); - expect(syncs[0].type).to.equal('iframe'); - expect(syncs[0].url).to.contains('gdpr=0'); - }); - }); - - describe('bid events', function () { - it('should trigger a win pixel', function () { - const bid = { - 'bidderCode': 'zedo', - 'width': '300', - 'height': '250', - 'statusMessage': 'Bid available', - 'adId': '148018fe5e', - 'cpm': 0.5, - 'ad': 'dummy data', - 'ad_id': '12345', - 'sizeId': '15', - 'adResponse': - { - 'creatives': [ - { - 'adId': '12345', - 'height': '480', - 'width': '640', - 'isFoc': true, - 'creativeDetails': { - 'type': 'VAST', - 'adContent': '' - }, - 'seeder': { - 'network': 1234, - 'servedChan': 1234567, - }, - 'cpm': '1200000', - 'servedChan': 1234, - }] - }, - 'params': [{ - 'channelCode': '123456', - 'dimId': '85' - }], - 'requestTimestamp': 1540401686, - 'responseTimestamp': 1540401687, - 'timeToRespond': 6253, - 'pbLg': '0.50', - 'pbMg': '0.50', - 'pbHg': '0.53', - 'adUnitCode': '/123456/header-bid-tag-0', - 'bidder': 'zedo', - 'size': '300x250', - 'adserverTargeting': { - 'hb_bidder': 'zedo', - 'hb_adid': '148018fe5e', - 'hb_pb': '10.00', - } - }; - spec.onBidWon(bid); - spec.onTimeout(bid); - }); - it('should trigger a timeout pixel', function () { - const bid = { - 'bidderCode': 'zedo', - 'width': '300', - 'height': '250', - 'statusMessage': 'Bid available', - 'adId': '148018fe5e', - 'cpm': 0.5, - 'ad': 'dummy data', - 'ad_id': '12345', - 'sizeId': '15', - 'params': [{ - 'channelCode': '123456', - 'dimId': '85' - }], - 'timeout': 1, - 'requestTimestamp': 1540401686, - 'responseTimestamp': 1540401687, - 'timeToRespond': 6253, - 'adUnitCode': '/123456/header-bid-tag-0', - 'bidder': 'zedo', - 'size': '300x250', - }; - spec.onBidWon(bid); - spec.onTimeout(bid); - }); - }); -}); diff --git a/test/spec/renderer_spec.js b/test/spec/renderer_spec.js index f9a670c13159..da10c67f2237 100644 --- a/test/spec/renderer_spec.js +++ b/test/spec/renderer_spec.js @@ -1,6 +1,7 @@ import { expect } from 'chai'; import { Renderer } from 'src/Renderer'; import * as utils from 'src/utils'; +import { loadExternalScript } from 'src/adloader'; describe('Renderer', function () { describe('Renderer: A renderer installed on a bid response', function () { @@ -127,5 +128,22 @@ describe('Renderer', function () { }); expect(utilsSpy.callCount).to.equal(1); }); + + it('should call loadExternalScript() for script not defined on adUnit', function() { + $$PREBID_GLOBAL$$.adUnits = [{ + code: 'video1', + renderer: { + url: 'http://cdn.adnxs.com/renderer/video/ANOutstreamVideo.js', + render: sinon.spy() + } + }]; + let testRenderer = Renderer.install({ + url: 'https://httpbin.org/post', + config: { test: 'config1' }, + id: 1, + adUnitCode: undefined + }); + expect(loadExternalScript.called).to.be.true; + }); }); }); diff --git a/test/spec/unit/pbjs_api_spec.js b/test/spec/unit/pbjs_api_spec.js index 485dd5cf0776..b59911153e54 100644 --- a/test/spec/unit/pbjs_api_spec.js +++ b/test/spec/unit/pbjs_api_spec.js @@ -406,10 +406,10 @@ describe('Unit: Prebid Module', function () { describe('getAdserverTargeting', function() { const customConfigObject = { 'buckets': [ - { 'precision': 2, 'min': 0, 'max': 5, 'increment': 0.01 }, - { 'precision': 2, 'min': 5, 'max': 8, 'increment': 0.05 }, - { 'precision': 2, 'min': 8, 'max': 20, 'increment': 0.5 }, - { 'precision': 2, 'min': 20, 'max': 25, 'increment': 1 } + { 'precision': 2, 'max': 5, 'increment': 0.01 }, + { 'precision': 2, 'max': 8, 'increment': 0.05 }, + { 'precision': 2, 'max': 20, 'increment': 0.5 }, + { 'precision': 2, 'max': 25, 'increment': 1 } ] }; let currentPriceBucket; @@ -700,18 +700,18 @@ describe('Unit: Prebid Module', function () { configObj.setConfig({ 'priceGranularity': { 'buckets': [ - { 'precision': 2, 'min': 0, 'max': 5, 'increment': 0.01 }, - { 'precision': 2, 'min': 5, 'max': 8, 'increment': 0.05 }, - { 'precision': 2, 'min': 8, 'max': 20, 'increment': 0.5 }, - { 'precision': 2, 'min': 20, 'max': 25, 'increment': 1 } + { 'precision': 2, 'max': 5, 'increment': 0.01 }, + { 'precision': 2, 'max': 8, 'increment': 0.05 }, + { 'precision': 2, 'max': 20, 'increment': 0.5 }, + { 'precision': 2, 'max': 25, 'increment': 1 } ] }, 'mediaTypePriceGranularity': { 'banner': { 'buckets': [ - { 'precision': 2, 'min': 0, 'max': 5, 'increment': 0.25 }, - { 'precision': 2, 'min': 6, 'max': 20, 'increment': 0.5 }, - { 'precision': 2, 'min': 21, 'max': 100, 'increment': 1 } + { 'precision': 2, 'max': 5, 'increment': 0.25 }, + { 'precision': 2, 'max': 20, 'increment': 0.5 }, + { 'precision': 2, 'max': 100, 'increment': 1 } ] }, 'video': 'low', @@ -1190,6 +1190,11 @@ describe('Unit: Prebid Module', function () { adUnits = [{ code: 'adUnit-code', + mediaTypes: { + banner: { + sizes: [[300, 250]] + } + }, bids: [ {bidder: BIDDER_CODE, params: {placementId: 'id'}}, ] @@ -1314,9 +1319,11 @@ describe('Unit: Prebid Module', function () { adUnits: [ { code: 'test1', + mediaTypes: { banner: { sizes: [] } }, bids: [], }, { code: 'test2', + mediaTypes: { banner: { sizes: [] } }, bids: [], } ], @@ -1396,9 +1403,11 @@ describe('Unit: Prebid Module', function () { { code: 'test1', transactionId: 'd0676a3c-ff32-45a5-af65-8175a8e7ddca', + mediaTypes: { banner: { sizes: [] } }, bids: [] }, { code: 'test2', + mediaTypes: { banner: { sizes: [] } }, bids: [] } ] @@ -1419,9 +1428,11 @@ describe('Unit: Prebid Module', function () { adUnits: [ { code: 'test1', + mediaTypes: { banner: { sizes: [] } }, bids: [] }, { code: 'test2', + mediaTypes: { banner: { sizes: [] } }, bids: [] } ] @@ -1562,7 +1573,6 @@ describe('Unit: Prebid Module', function () { expect(auctionArgs.adUnits[0].sizes).to.deep.equal([[640, 480]]); expect(auctionArgs.adUnits[0].mediaTypes.video.playerSize).to.deep.equal([[640, 480]]); expect(auctionArgs.adUnits[0].mediaTypes.video).to.exist; - assert.ok(logInfoSpy.calledWith('Transforming video.playerSize from [640,480] to [[640,480]] so it\'s in the proper format.'), 'expected message was logged'); }); it('should normalize adUnit.sizes and adUnit.mediaTypes.banner.sizes', function () { @@ -1601,7 +1611,7 @@ describe('Unit: Prebid Module', function () { }); expect(auctionArgs.adUnits[0].sizes).to.deep.equal([[300, 250], [300, 600]]); expect(auctionArgs.adUnits[0].mediaTypes.banner).to.be.undefined; - assert.ok(logErrorSpy.calledWith('Detected a mediaTypes.banner object did not include sizes. This is a required field for the mediaTypes.banner object. Removing invalid mediaTypes.banner object from request.')); + assert.ok(logErrorSpy.calledWith('Detected a mediaTypes.banner object without a proper sizes field. Please ensure the sizes are listed like: [[300, 250], ...]. Removing invalid mediaTypes.banner object from request.')); let badVideo1 = [{ code: 'testb2', @@ -1763,7 +1773,7 @@ describe('Unit: Prebid Module', function () { before(function () { adUnits = [{ code: 'adUnit-code', - sizes: [[300, 250], [300, 600]], + mediaTypes: { banner: { sizes: [[300, 250], [300, 600]] } }, bids: [ {bidder: 'appnexus', params: {placementId: '10433394'}} ] @@ -1771,13 +1781,13 @@ describe('Unit: Prebid Module', function () { let adUnitCodes = ['adUnit-code']; let auction = auctionModule.newAuction({adUnits, adUnitCodes, callback: function() {}, cbTimeout: timeout}); - adUnits[0]['mediaType'] = 'native'; + adUnits[0]['mediaTypes'] = { native: {} }; adUnitCodes = ['adUnit-code']; let auction1 = auctionModule.newAuction({adUnits, adUnitCodes, callback: function() {}, cbTimeout: timeout}); adUnits = [{ code: 'adUnit-code', - nativeParams: {type: 'image'}, + mediaTypes: { native: { type: 'image' } }, sizes: [[300, 250], [300, 600]], bids: [ {bidder: 'appnexus', params: {placementId: 'id'}} @@ -1811,7 +1821,7 @@ describe('Unit: Prebid Module', function () { it('should call callBids function on adapterManager', function () { let adUnits = [{ code: 'adUnit-code', - sizes: [[300, 250], [300, 600]], + mediaTypes: { banner: { sizes: [[300, 250], [300, 600]] } }, bids: [ {bidder: 'appnexus', params: {placementId: '10433394'}} ] @@ -1823,8 +1833,7 @@ describe('Unit: Prebid Module', function () { it('splits native type to individual native assets', function () { let adUnits = [{ code: 'adUnit-code', - nativeParams: {type: 'image'}, - sizes: [[300, 250], [300, 600]], + mediaTypes: { native: { type: 'image' } }, bids: [ {bidder: 'appnexus', params: {placementId: 'id'}} ] @@ -2033,17 +2042,6 @@ describe('Unit: Prebid Module', function () { }); }); - describe('loadScript', function () { - it('should call adloader.loadScript', function () { - const tagSrc = ''; - const callback = Function; - const useCache = false; - - $$PREBID_GLOBAL$$.loadScript(tagSrc, callback, useCache); - assert.ok(adloader.loadScriptStub.calledWith(tagSrc, callback, useCache), 'called adloader.loadScript'); - }); - }); - describe('aliasBidder', function () { it('should call adapterManager.aliasBidder', function () { const aliasBidAdapterSpy = sinon.spy(adapterManager, 'aliasBidAdapter'); @@ -2080,14 +2078,12 @@ describe('Unit: Prebid Module', function () { const error = 'Invalid custom price value passed to `setPriceGranularity()`'; const badConfig = { 'buckets': [{ - 'min': 0, 'max': 3, 'increment': 0.01, }, { - // missing min prop 'max': 18, - 'increment': 0.05, + // missing increment prop 'cap': true } ] @@ -2102,7 +2098,6 @@ describe('Unit: Prebid Module', function () { let customPriceBucket = configObj.getConfig('customPriceBucket'); const goodConfig = { 'buckets': [{ - 'min': 0, 'max': 3, 'increment': 0.01, 'cap': true @@ -2270,13 +2265,9 @@ describe('Unit: Prebid Module', function () { }); describe('getHighestCpm', () => { - // it('returns an array of winning bid objects for each adUnit', () => { - // const highestCpmBids = $$PREBID_GLOBAL$$.getHighestCpmBids(); - // expect(highestCpmBids.length).to.equal(2); - // expect(highestCpmBids[0]).to.deep.equal(auctionManager.getBidsReceived()[1]); - // expect(highestCpmBids[1]).to.deep.equal(auctionManager.getBidsReceived()[2]); - // }); - + after(() => { + resetAuction(); + }); it('returns an array containing the highest bid object for the given adUnitCode', function () { const highestCpmBids = $$PREBID_GLOBAL$$.getHighestCpmBids('/19968336/header-bid-tag-0'); expect(highestCpmBids.length).to.equal(1); @@ -2295,7 +2286,23 @@ describe('Unit: Prebid Module', function () { const highestCpmBids = $$PREBID_GLOBAL$$.getHighestCpmBids('/19968336/header-bid-tag-0'); expect(highestCpmBids.length).to.equal(0); - resetAuction(); + }); + + it('should not return rendered bid', function() { + let _bidsReceived = getBidResponses().slice(0, 3); + _bidsReceived[0].cpm = 12; + _bidsReceived[0].status = 'rendered'; + _bidsReceived[1].cpm = 9; + _bidsReceived[2].cpm = 11; + + _bidsReceived.forEach((bid) => { + bid.adUnitCode = '/19968336/header-bid-tag-0'; + }); + + auction.getBidsReceived = function() { return _bidsReceived }; + + const highestCpmBids = $$PREBID_GLOBAL$$.getHighestCpmBids('/19968336/header-bid-tag-0'); + expect(highestCpmBids[0]).to.deep.equal(auctionManager.getBidsReceived()[2]); }); }); diff --git a/test/spec/userSync_spec.js b/test/spec/userSync_spec.js index f55fe13c5282..806e86e998bd 100644 --- a/test/spec/userSync_spec.js +++ b/test/spec/userSync_spec.js @@ -85,21 +85,31 @@ describe('user sync', function () { }); it('should not register pixel URL since it is not supported', function () { - const userSync = newTestUserSync({pixelEnabled: false}); + const userSync = newTestUserSync({filterSettings: { + image: { + bidders: '*', + filter: 'exclude' + } + }}); userSync.registerSync('image', 'testBidder', 'http://example.com'); userSync.syncUsers(); expect(triggerPixelStub.getCall(0)).to.be.null; }); it('should register and load an iframe', function () { - const userSync = newTestUserSync({iframeEnabled: true}); + const userSync = newTestUserSync({filterSettings: { + iframe: { + bidders: '*', + filter: 'include' + } + }}); userSync.registerSync('iframe', 'testBidder', 'http://example.com/iframe'); userSync.syncUsers(); expect(insertUserSyncIframeStub.getCall(0).args[0]).to.equal('http://example.com/iframe'); }); it('should only trigger syncs once per page per bidder', function () { - const userSync = newTestUserSync({pixelEnabled: true}); + const userSync = newTestUserSync({ pixelEnabled: true }); userSync.registerSync('image', 'testBidder', 'http://example.com/1'); userSync.syncUsers(); userSync.registerSync('image', 'testBidder', 'http://example.com/2'); @@ -113,7 +123,7 @@ describe('user sync', function () { }); it('should not fire syncs if cookies are not supported', function () { - const userSync = newTestUserSync({pixelEnabled: true}, true); + const userSync = newTestUserSync({ pixelEnabled: true }, true); userSync.registerSync('image', 'testBidder', 'http://example.com'); userSync.syncUsers(); expect(triggerPixelStub.getCall(0)).to.be.null; @@ -132,14 +142,14 @@ describe('user sync', function () { userSync.triggerUserSyncs(); expect(syncUsersSpy.notCalled).to.be.true; // triggerUserSyncs should trigger syncUsers if enableOverride is on - userSync = newTestUserSync({enableOverride: true}); + userSync = newTestUserSync({ enableOverride: true }); syncUsersSpy = sinon.spy(userSync, 'syncUsers'); userSync.triggerUserSyncs(); expect(syncUsersSpy.called).to.be.true; }); it('should limit the number of syncs per bidder', function () { - const userSync = newTestUserSync({syncsPerBidder: 2}); + const userSync = newTestUserSync({ syncsPerBidder: 2 }); userSync.registerSync('image', 'testBidder', 'http://example.com/1'); userSync.registerSync('image', 'testBidder', 'http://example.com/2'); userSync.registerSync('image', 'testBidder', 'http://example.com/3'); @@ -151,8 +161,8 @@ describe('user sync', function () { expect(triggerPixelStub.getCall(2)).to.be.null; }); - it('should not limit the number of syncs per bidder when set to 0', function() { - const userSync = newTestUserSync({syncsPerBidder: 0}); + it('should not limit the number of syncs per bidder when set to 0', function () { + const userSync = newTestUserSync({ syncsPerBidder: 0 }); userSync.registerSync('image', 'testBidder', 'http://example.com/1'); userSync.registerSync('image', 'testBidder', 'http://example.com/2'); userSync.registerSync('image', 'testBidder', 'http://example.com/3'); @@ -182,7 +192,7 @@ describe('user sync', function () { }); it('should disable user sync', function () { - const userSync = newTestUserSync({syncEnabled: false}); + const userSync = newTestUserSync({ syncEnabled: false }); userSync.registerSync('pixel', 'testBidder', 'http://example.com'); expect(logWarnStub.getCall(0).args[0]).to.exist; userSync.syncUsers(); @@ -190,7 +200,12 @@ describe('user sync', function () { }); it('should only sync enabled bidders', function () { - const userSync = newTestUserSync({enabledBidders: ['testBidderA']}); + const userSync = newTestUserSync({filterSettings: { + image: { + bidders: ['testBidderA'], + filter: 'include' + } + }}); userSync.registerSync('image', 'testBidderA', 'http://example.com/1'); userSync.registerSync('image', 'testBidderB', 'http://example.com/2'); userSync.syncUsers(); @@ -201,9 +216,9 @@ describe('user sync', function () { it('should register config set after instantiation', function () { // start with userSync off - const userSync = newTestUserSync({syncEnabled: false}); + const userSync = newTestUserSync({ syncEnabled: false }); // turn it on with setConfig() - config.setConfig({userSync: {syncEnabled: true}}); + config.setConfig({ userSync: { syncEnabled: true } }); userSync.registerSync('image', 'testBidder', 'http://example.com'); userSync.syncUsers(); expect(triggerPixelStub.getCall(0)).to.not.be.null; @@ -360,8 +375,8 @@ describe('user sync', function () { }); describe('publicAPI', function () { - describe('canBidderRegisterSync', function() { - describe('with filterSettings', function() { + describe('canBidderRegisterSync', function () { + describe('with filterSettings', function () { it('should return false if filter settings does not allow it', function () { const userSync = newUserSync({ config: { @@ -397,14 +412,17 @@ describe('user sync', function () { expect(userSync.canBidderRegisterSync('iframe', 'testBidder')).to.equal(true); }); }); - describe('almost deprecated - without filterSettings', function() { - describe('enabledBidders contains testBidder', function() { + describe('almost deprecated - without filterSettings', function () { + describe('enabledBidders contains testBidder', function () { it('should return false if type is iframe and iframeEnabled is false', function () { const userSync = newUserSync({ config: { - pixelEnabled: true, - iframeEnabled: false, - enabledBidders: ['testBidder'], + filterSettings: { + iframe: { + bidders: ['testBidder'], + filter: 'exclude' + } + } } }); expect(userSync.canBidderRegisterSync('iframe', 'testBidder')).to.equal(false); @@ -424,9 +442,12 @@ describe('user sync', function () { it('should return false if type is image and pixelEnabled is false', function () { const userSync = newUserSync({ config: { - pixelEnabled: false, - iframeEnabled: true, - enabledBidders: ['testBidder'], + filterSettings: { + image: { + bidders: ['testBidder'], + filter: 'exclude' + } + } } }); expect(userSync.canBidderRegisterSync('image', 'testBidder')).to.equal(false); @@ -444,13 +465,20 @@ describe('user sync', function () { }); }); - describe('enabledBidders does not container testBidder', function() { - it('should return false since testBidder is not in enabledBidders', function() { + describe('enabledBidders does not container testBidder', function () { + it('should return false since testBidder is not in enabledBidders', function () { const userSync = newUserSync({ config: { - pixelEnabled: true, - iframeEnabled: true, - enabledBidders: ['otherTestBidder'], + filterSettings: { + image: { + bidders: ['otherTestBidder'], + filter: 'include' + }, + iframe: { + bidders: ['otherTestBidder'], + filter: 'include' + } + } } }); expect(userSync.canBidderRegisterSync('iframe', 'testBidder')).to.equal(false); diff --git a/test/spec/utils_spec.js b/test/spec/utils_spec.js index 5bee79d39c28..012dfacd92f7 100755 --- a/test/spec/utils_spec.js +++ b/test/spec/utils_spec.js @@ -793,93 +793,6 @@ describe('Utils', function () { }); }); - describe('getTopWindowLocation', function () { - let sandbox; - - beforeEach(function () { - sandbox = sinon.sandbox.create(); - }); - - afterEach(function () { - sandbox.restore(); - }); - - it('returns window.location if not in iFrame', function () { - sandbox.stub(utils.internal, 'getWindowLocation').returns({ - href: 'https://www.google.com/', - ancestorOrigins: {}, - origin: 'https://www.google.com', - protocol: 'https', - host: 'www.google.com', - hostname: 'www.google.com', - port: '', - pathname: '/', - search: '', - hash: '' - }); - let windowSelfAndTopObject = { self: 'is same as top' }; - sandbox.stub(utils.internal, 'getWindowSelf').returns( - windowSelfAndTopObject - ); - sandbox.stub(utils.internal, 'getWindowTop').returns( - windowSelfAndTopObject - ); - var topWindowLocation = utils.getTopWindowLocation(); - expect(topWindowLocation).to.be.a('object'); - expect(topWindowLocation.href).to.equal('https://www.google.com/'); - expect(topWindowLocation.protocol).to.equal('https'); - expect(topWindowLocation.hostname).to.equal('www.google.com'); - expect(topWindowLocation.port).to.equal(''); - expect(topWindowLocation.pathname).to.equal('/'); - expect(topWindowLocation.hash).to.equal(''); - expect(topWindowLocation.search).to.equal(''); - expect(topWindowLocation.host).to.equal('www.google.com'); - }); - - it('returns parsed dom string from ancestorOrigins if in iFrame & ancestorOrigins is populated', function () { - sandbox.stub(utils.internal, 'getWindowSelf').returns( - { self: 'is not same as top' } - ); - sandbox.stub(utils.internal, 'getWindowTop').returns( - { top: 'is not same as self' } - ); - sandbox.stub(utils.internal, 'getAncestorOrigins').returns('https://www.google.com/a/umich.edu/acs'); - var topWindowLocation = utils.getTopWindowLocation(); - expect(topWindowLocation).to.be.a('object'); - expect(topWindowLocation.pathname).to.equal('/a/umich.edu/acs'); - expect(topWindowLocation.href).to.equal('https://www.google.com/a/umich.edu/acs'); - expect(topWindowLocation.protocol).to.equal('https'); - expect(topWindowLocation.hostname).to.equal('www.google.com'); - expect(topWindowLocation.hash).to.equal(''); - expect(topWindowLocation.search).to.equal(''); - // note IE11 returns the default secure port, so we look for this alternate value as well in these tests - expect(topWindowLocation.port).to.be.oneOf([0, 443]); - expect(topWindowLocation.host).to.be.oneOf(['www.google.com', 'www.google.com:443']); - }); - - it('returns parsed referrer string if in iFrame but no ancestorOrigins', function () { - sandbox.stub(utils.internal, 'getWindowSelf').returns( - { self: 'is not same as top' } - ); - sandbox.stub(utils.internal, 'getWindowTop').returns( - { top: 'is not same as self' } - ); - sandbox.stub(utils.internal, 'getAncestorOrigins').returns(null); - sandbox.stub(utils.internal, 'getTopFrameReferrer').returns('https://www.example.com/'); - var topWindowLocation = utils.getTopWindowLocation(); - expect(topWindowLocation).to.be.a('object'); - expect(topWindowLocation.href).to.equal('https://www.example.com/'); - expect(topWindowLocation.protocol).to.equal('https'); - expect(topWindowLocation.hostname).to.equal('www.example.com'); - expect(topWindowLocation.pathname).to.equal('/'); - expect(topWindowLocation.hash).to.equal(''); - expect(topWindowLocation.search).to.equal(''); - // note IE11 returns the default secure port, so we look for this alternate value as well in these tests - expect(topWindowLocation.port).to.be.oneOf([0, 443]); - expect(topWindowLocation.host).to.be.oneOf(['www.example.com', 'www.example.com:443']); - }); - }); - describe('convertCamelToUnderscore', function () { it('returns converted string value using underscore syntax instead of camelCase', function () { let var1 = 'placementIdTest'; From ef6366197bf091220b7c5f19b0cc37628ce8cee6 Mon Sep 17 00:00:00 2001 From: Jason Snellbaker Date: Wed, 11 Dec 2019 15:16:45 -0500 Subject: [PATCH 39/41] Prebid 3.0.0 Release --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index c6880628aeee..2e19b0b5b8d8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "prebid.js", - "version": "3.0.0-pre", + "version": "3.0.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 5a94991c308c..e4de01777af5 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "prebid.js", - "version": "3.0.0-pre", + "version": "3.0.0", "description": "Header Bidding Management Library", "main": "src/prebid.js", "scripts": { From 8019d8240dbddd65b33c69b41734aaa7564bacc9 Mon Sep 17 00:00:00 2001 From: Jason Snellbaker Date: Wed, 11 Dec 2019 15:29:53 -0500 Subject: [PATCH 40/41] increment pre version --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 2e19b0b5b8d8..54e22ed8fe6e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "prebid.js", - "version": "3.0.0", + "version": "3.1.0-pre", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index e4de01777af5..56b0251cbc4c 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "prebid.js", - "version": "3.0.0", + "version": "3.1.0-pre", "description": "Header Bidding Management Library", "main": "src/prebid.js", "scripts": { From aabb91f47b611535efe4d635770d890f2f035c2a Mon Sep 17 00:00:00 2001 From: JonGoSonobi Date: Thu, 12 Dec 2019 02:01:54 -0500 Subject: [PATCH 41/41] added new param to sonobi adapter: keywords (#4549) --- modules/sonobiBidAdapter.js | 6 ++++++ test/spec/modules/sonobiBidAdapter_spec.js | 8 +++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/modules/sonobiBidAdapter.js b/modules/sonobiBidAdapter.js index 3fb9a83d2597..eea25d98d90f 100644 --- a/modules/sonobiBidAdapter.js +++ b/modules/sonobiBidAdapter.js @@ -136,6 +136,12 @@ export const spec = { payload.userid = JSON.stringify(validBidRequests[0].userId); } + let keywords = validBidRequests[0].params.keywords; // a CSV of keywords + + if (keywords) { + payload.kw = keywords; + } + // If there is no key_maker data, then don't make the request. if (isEmpty(data)) { return null; diff --git a/test/spec/modules/sonobiBidAdapter_spec.js b/test/spec/modules/sonobiBidAdapter_spec.js index aac7d8396afb..52d755a1fafa 100644 --- a/test/spec/modules/sonobiBidAdapter_spec.js +++ b/test/spec/modules/sonobiBidAdapter_spec.js @@ -262,6 +262,7 @@ describe('SonobiBidAdapter', function () { }, 'bidder': 'sonobi', 'params': { + 'keywords': 'sports,news,some_other_keyword', 'placement_id': '1a2b3c4d5e6f1a2b3c4d', 'sizes': [[300, 250], [300, 600]], 'floor': '1.25', @@ -341,7 +342,7 @@ describe('SonobiBidAdapter', function () { expect(bidRequests.data.digkeyv).to.be.undefined; sandbox.restore(); delete window.DigiTrust; - }) + }); it('should return a properly formatted request', function () { const bidRequests = spec.buildRequests(bidRequest, bidderRequests) @@ -539,6 +540,11 @@ describe('SonobiBidAdapter', function () { expect(bidRequests.data.s).not.to.be.empty; expect(bidRequests.data.userid).to.equal(undefined); }); + + it('should return a properly formatted request with keywrods included as a csv of strings', function() { + const bidRequests = spec.buildRequests(bidRequest, bidderRequests); + expect(bidRequests.data.kw).to.equal('sports,news,some_other_keyword'); + }); }) describe('.interpretResponse', function () {