From fdaa696dd1dd07209c7d7cbcdc4d95ad2b542cf9 Mon Sep 17 00:00:00 2001 From: Chris Huie Date: Wed, 25 Aug 2021 04:19:58 -0700 Subject: [PATCH] Revert "Sublime Bid Adapter : refactoring notifyId, bid request validation, & device detection fix (#7327)" (#7346) This reverts commit ca5c28c5a72406f85e4018001a728d193194aae4. --- modules/sublimeBidAdapter.js | 71 +---- test/spec/modules/sublimeBidAdapter_spec.js | 284 ++------------------ 2 files changed, 33 insertions(+), 322 deletions(-) diff --git a/modules/sublimeBidAdapter.js b/modules/sublimeBidAdapter.js index 480ab2bfed7..462665202a5 100644 --- a/modules/sublimeBidAdapter.js +++ b/modules/sublimeBidAdapter.js @@ -9,16 +9,16 @@ const DEFAULT_CURRENCY = 'EUR'; const DEFAULT_PROTOCOL = 'https'; const DEFAULT_TTL = 600; const SUBLIME_ANTENNA = 'antenna.ayads.co'; -const SUBLIME_VERSION = '0.8.0'; +const SUBLIME_VERSION = '0.7.3'; /** * Identify the current device type * @returns {string} */ function detectDevice() { - const isMobile = /(?:phone|windows\s+phone|ipod|blackberry|Galaxy Nexus|SM-G892A|(?:android|bbd+|meego|silk|googlebot) .+?mobile|palm|windows\s+ce|opera mini|avantgo|docomo)/i; + const isMobile = /(?:phone|windowss+phone|ipod|blackberry|Galaxy Nexus|SM-G892A|(?:android|bbd+|meego|silk|googlebot) .+?mobile|palm|windowss+ce|opera mini|avantgo|docomo)/i; - const isTablet = /(?:ipad|playbook|Tablet|(?:android|bb\d+|meego|silk)(?! .+? mobile))/i; + const isTablet = /(?:ipad|playbook|Tablet|(?:android|bb\\d+|meego|silk)(?! .+? mobile))/i; return ( (isMobile.test(navigator.userAgent) && 'm') || // mobile @@ -27,16 +27,6 @@ function detectDevice() { ); } -const UUID_V4_RE = /^[0-9A-F]{8}-[0-9A-F]{4}-[4][0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i; -/** - * Checks whether a notifyId is well-formed - * @param {*} value - * @returns {boolean} - */ -function isValidNotifyId(value) { - return UUID_V4_RE.test(value); -} - /** * Debug log message * @param {String} msg @@ -63,26 +53,6 @@ export function setState(value) { log('State has been updated :', state); } -/** - * Get a notifyId from bid params or from sublime global - * @param {Object} params - The bid params - * @return {string} - */ -function getNotifyId(params) { - const sublime = window.sublime = window.sublime || {}; - - let notifyId = params.notifyId || sublime.notifyId; - if (!notifyId) { - notifyId = utils.generateUUID(); - log('generating a notifyId', notifyId); - } - if (!sublime.notifyId) { - sublime.notifyId = notifyId; - } - - return notifyId; -} - /** * Send pixel to our debug endpoint * @param {string} eventName - Event name that will be send in the e= query string @@ -121,16 +91,6 @@ export function sendEvent(eventName, sspName) { * @return {Boolean} True if this is a valid bid, and false otherwise. */ function isBidRequestValid(bid) { - const notifyId = getNotifyId(bid.params); - if (!isValidNotifyId(notifyId)) { - log(`invalid notifyId format, got "${notifyId}"`); - return false; - } - if (notifyId !== window.sublime.notifyId) { - log(`notifyId mismatch: params [${bid.params.notifyId}] / sublime [${window.sublime.notifyId}]`); - return false; - } - return !!Number(bid.params.zoneId); } @@ -167,11 +127,9 @@ function buildRequests(validBidRequests, bidderRequest) { const bidHost = bid.params.bidHost || DEFAULT_BID_HOST; const protocol = bid.params.protocol || DEFAULT_PROTOCOL; - const notifyId = getNotifyId(bid.params); - setState({ transactionId: bid.transactionId, - notifyId, + notifyId: bid.params.notifyId, zoneId: bid.params.zoneId, debug: bid.params.debug || false, }); @@ -188,7 +146,7 @@ function buildRequests(validBidRequests, bidderRequest) { h: size[1], })), transactionId: bid.transactionId, - notifyId, + notifyId: bid.params.notifyId, zoneId: bid.params.zoneId, }; @@ -292,18 +250,15 @@ export const spec = { code: BIDDER_CODE, gvlid: BIDDER_GVLID, aliases: [], - isBidRequestValid, - buildRequests, - interpretResponse, - onBidWon, - onTimeout, + isBidRequestValid: isBidRequestValid, + buildRequests: buildRequests, + interpretResponse: interpretResponse, + onBidWon: onBidWon, + onTimeout: onTimeout, // Exposed for test purpose - sendEvent, - setState, - state, - detectDevice, - getNotifyId, - isValidNotifyId, + sendEvent: sendEvent, + setState: setState, + state: state, }; registerBidder(spec); diff --git a/test/spec/modules/sublimeBidAdapter_spec.js b/test/spec/modules/sublimeBidAdapter_spec.js index 4b577beb3f4..5c72c6c4dc5 100644 --- a/test/spec/modules/sublimeBidAdapter_spec.js +++ b/test/spec/modules/sublimeBidAdapter_spec.js @@ -1,176 +1,11 @@ import { expect } from 'chai'; import { spec } from 'modules/sublimeBidAdapter.js'; import { newBidder } from 'src/adapters/bidderFactory.js'; -const sinon = require('sinon'); - -const utils = require('src/utils'); - -const USER_AGENT = { - // UNKOWN - 'Opera/9.80 (S60; SymbOS; Opera Mobi/1209; U; sk) Presto/2.5.28 Version/10.1': { - type: 'desktop', os: { name: '', version: 0 }, browser: { name: '', version: 0 }, - }, - 'Opera/12.02 (Android 4.1; Linux; Opera Mobi/ADR-1111101157; U; en-US) Presto/2.9.201 Version/12.02': { - type: 'tablet', os: { name: 'android', version: 4.1 }, browser: { name: '', version: 0 }, - }, - - // MOBILES - // Android Mobile User Agents - 'Mozilla/5.0 (compatible; MSIE 9.0; Windows Phone OS 7.5; Trident/5.0; IEMobile/9.0)': { - type: 'mobile', os: { name: 'windowsPhone', version: 7.5 }, browser: { name: 'Internet Explorer', version: 9 }, - }, - 'Mozilla/5.0 (Linux; U; Android 2.3.5; en-us; HTC Vision Build/GRI40) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1': { - type: 'mobile', os: { name: 'android', version: 2.3 }, browser: { name: 'Safari', version: 4 }, - }, - 'Mozilla/5.0 (Linux; U; Android 4.0.3; ko-kr; LG-L160L Build/IML74K) AppleWebkit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30': { - type: 'mobile', os: { name: 'android', version: 4 }, browser: { name: 'Safari', version: 4 }, - }, - 'Mozilla/5.0 (Linux; U; Android 4.4.3; ko-kr; LG-L160L Build/IML74K) AppleWebkit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30': { - type: 'mobile', os: { name: 'android', version: 4.4 }, browser: { name: 'Safari', version: 4 }, - }, - 'Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Mobile Safari/537.36': { - type: 'mobile', os: { name: 'android', version: 6 }, browser: { name: 'Chrome', version: 55 }, - }, - 'Mozilla/5.0 (Linux; Android 7.0; SM-G892A Build/NRD90M; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/60.0.3112.107 Mobile Safari/537.36': { - type: 'mobile', os: { name: 'android', version: 7 }, browser: { name: 'Chrome', version: 60 }, - }, - 'Mozilla/5.0 (Linux; Android 7.0; SM-G930VC Build/NRD90M; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/58.0.3029.83 Mobile Safari/537.36': { - type: 'mobile', os: { name: 'android', version: 7 }, browser: { name: 'Chrome', version: 58 }, - }, - 'Mozilla/5.0 (Linux; Android 6.0.1; SM-G935S Build/MMB29K; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/55.0.2883.91 Mobile Safari/537.36': { - type: 'mobile', os: { name: 'android', version: 6 }, browser: { name: 'Chrome', version: 55 }, - }, - 'Mozilla/5.0 (Linux; Android 6.0.1; SM-G920V Build/MMB29K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.98 Mobile Safari/537.36': { - type: 'mobile', os: { name: 'android', version: 6 }, browser: { name: 'Chrome', version: 52 }, - }, - 'Mozilla/5.0 (Linux; Android 5.1.1; SM-G928X Build/LMY47X) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.83 Mobile Safari/537.36': { - type: 'mobile', os: { name: 'android', version: 5.1 }, browser: { name: 'Chrome', version: 47 }, - }, - 'Mozilla/5.0 (Linux; Android 6.0.1; Nexus 6P Build/MMB29P) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.83 Mobile Safari/537.36': { - type: 'mobile', os: { name: 'android', version: 6 }, browser: { name: 'Chrome', version: 47 }, - }, - 'Mozilla/5.0 (Linux; Android 7.1.1; G8231 Build/41.2.A.0.219; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/59.0.3071.125 Mobile Safari/537.36': { - type: 'mobile', os: { name: 'android', version: 7.1 }, browser: { name: 'Chrome', version: 59 }, - }, - 'Mozilla/5.0 (Linux; Android 6.0.1; E6653 Build/32.2.A.0.253) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.98 Mobile Safari/537.36': { - type: 'mobile', os: { name: 'android', version: 6 }, browser: { name: 'Chrome', version: 52 }, - }, - 'Mozilla/5.0 (Linux; Android 6.0; HTC One X10 Build/MRA58K; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/61.0.3163.98 Mobile Safari/537.36': { - type: 'mobile', os: { name: 'android', version: 6 }, browser: { name: 'Chrome', version: 61 }, - }, - 'Mozilla/5.0 (Linux; Android 6.0; HTC One M9 Build/MRA58K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.98 Mobile Safari/537.3': { - type: 'mobile', os: { name: 'android', version: 6 }, browser: { name: 'Chrome', version: 52 }, - }, - 'Mozilla/5.0 (Linux; U; 4.0.2; en-us; Galaxy Nexus Build/ICL53F) AppleWebKit/534.30 (KHTML like Gecko) Version/4.0 Mobile Safari/534.30': { - type: 'mobile', os: { name: '', version: 0 }, browser: { name: 'Safari', version: 4 }, - }, - // iPhone User Agents - 'Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1': { - type: 'mobile', os: { name: 'iOS', version: 11 }, browser: { name: 'Safari', version: 11 }, - }, - 'Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.34 (KHTML, like Gecko) Version/11.0 Mobile/15A5341f Safari/604.1': { - type: 'mobile', os: { name: 'iOS', version: 11 }, browser: { name: 'Safari', version: 11 }, - }, - 'Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A5370a Safari/604.1': { - type: 'mobile', os: { name: 'iOS', version: 11 }, browser: { name: 'Safari', version: 11 }, - }, - 'Mozilla/5.0 (iPhone9,3; U; CPU iPhone OS 10_0_1 like Mac OS X) AppleWebKit/602.1.50 (KHTML, like Gecko) Version/10.0 Mobile/14A403 Safari/602.1': { - type: 'mobile', os: { name: 'iOS', version: 10 }, browser: { name: 'Safari', version: 10 }, - }, - 'Mozilla/5.0 (iPhone9,4; U; CPU iPhone OS 10_0_1 like Mac OS X) AppleWebKit/602.1.50 (KHTML, like Gecko) Version/10.0 Mobile/14A403 Safari/602.1': { - type: 'mobile', os: { name: 'iOS', version: 10 }, browser: { name: 'Safari', version: 10 }, - }, - 'Mozilla/5.0 (Apple-iPhone7C2/1202.466; U; CPU like Mac OS X; en) AppleWebKit/420+ (KHTML, like Gecko) Version/3.0 Mobile/1A543 Safari/419.3': { - type: 'mobile', os: { name: '', version: 0 }, browser: { name: 'Safari', version: 3 }, - }, - 'Mozilla/5.0 (Windows Phone 10.0; Android 6.0.1; Microsoft; RM-1152) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Mobile Safari/537.36 Edge/15.15254': { - type: 'mobile', os: { name: 'windowsPhone', version: 10 }, browser: { name: 'Edge', version: 15.15254 }, - }, - 'Mozilla/5.0 (Windows Phone 10.0; Android 4.2.1; Microsoft; RM-1127_16056) AppleWebKit/537.36(KHTML, like Gecko) Chrome/42.0.2311.135 Mobile Safari/537.36 Edge/12.10536': { - type: 'mobile', os: { name: 'windowsPhone', version: 10 }, browser: { name: 'Edge', version: 12.10536 }, - }, - 'Mozilla/5.0 (Windows Phone 10.0; Android 4.2.1; Microsoft; Lumia 950) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2486.0 Mobile Safari/537.36 Edge/13.1058': { - type: 'mobile', os: { name: 'windowsPhone', version: 10 }, browser: { name: 'Edge', version: 13.1058 }, - }, - 'Mozilla/5.0 (Linux; 7.0; SM-G892A Build/NRD90M; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/60.0.3112.107 Mobile Safari/537.36': { - type: 'mobile', os: { name: '', version: 0 }, browser: { name: 'Chrome', version: 60 }, - }, - 'Mozilla/5.0 (iPhone; CPU iPhone OS 11_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/11.0 Mobile/15E148 Safari/604.1': { - type: 'mobile', os: { name: 'iOS', version: 11.3 }, browser: { name: 'Safari', version: 11 }, - }, - 'Mozilla/5.0 (Linux; Android 6.0.1; SM-G903F Build/MMB29K; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/44.0.2403.119 Mobile Safari/537.36 ACHEETAHI/1': { - type: 'mobile', os: { name: 'android', version: 6 }, browser: { name: 'Chrome', version: 44 }, - }, - - // TABLETS - 'Mozilla/5.0 (Linux; Android 5.0.2; SAMSUNG SM-T550 Build/LRX22G) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/3.3 Chrome/38.0.2125.102 Safari/537.36': { - type: 'tablet', os: { name: 'android', version: 5 }, browser: { name: 'Chrome', version: 38 }, - }, - 'Mozilla/5.0 (Linux; Android 5.1.1; SHIELD Tablet Build/LMY48C) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.98 Safari/537.36': { - type: 'tablet', os: { name: 'android', version: 5.1 }, browser: { name: 'Chrome', version: 52 }, - }, - 'Mozilla/5.0 (Linux; Android 7.0; Pixel C Build/NRD90M; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/52.0.2743.98 Safari/537.36': { - type: 'tablet', os: { name: 'android', version: 7 }, browser: { name: 'Chrome', version: 52 }, - }, - 'Mozilla/5.0 (Linux; Android 6.0.1; SGP771 Build/32.2.A.0.253; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/52.0.2743.98 Safari/537.36': { - type: 'tablet', os: { name: 'android', version: 6 }, browser: { name: 'Chrome', version: 52 }, - }, - 'Mozilla/5.0 (Linux; Android 6.0.1; SHIELD Tablet K1 Build/MRA58K; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/55.0.2883.91 Safari/537.36': { - type: 'tablet', os: { name: 'android', version: 6 }, browser: { name: 'Chrome', version: 55 }, - }, - 'Mozilla/5.0 (Linux; Android 7.0; SM-T827R4 Build/NRD90M) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.116 Safari/537.36': { - type: 'tablet', os: { name: 'android', version: 7 }, browser: { name: 'Chrome', version: 60 }, - }, - 'Mozilla/5.0 (Linux; Android 4.4.3; KFTHWI Build/KTU84M) AppleWebKit/537.36 (KHTML, like Gecko) Silk/47.1.79 like Chrome/47.0.2526.80 Safari/537.36': { - type: 'tablet', os: { name: 'android', version: 4.4 }, browser: { name: 'Chrome', version: 47 }, - }, - 'Mozilla/5.0 (Linux; Android 5.0.2; LG-V410/V41020c Build/LRX22G) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/34.0.1847.118 Safari/537.36': { - type: 'tablet', os: { name: 'android', version: 5 }, browser: { name: 'Chrome', version: 34 }, - }, - 'Mozilla/5.0 (iPad; CPU OS 9_3_2 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13F69 Safari/601.1': { - type: 'tablet', os: { name: 'iOS', version: 9.3 }, browser: { name: 'Safari', version: 9 }, - }, - 'Mozilla/5.0 (iPad; CPU OS 11_0_2 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A421 Safari/604.1': { - type: 'tablet', os: { name: 'iOS', version: 11 }, browser: { name: 'Safari', version: 11 }, - }, - 'Mozilla/5.0 (Android 7.0; Tablet; rv:62.0) Gecko/62.0 Firefox/62.0': { - type: 'tablet', os: { name: 'android', version: 7 }, browser: { name: 'Firefox', version: 62 }, - }, - - // DESKTOP - 'Mozilla/ 5.0(Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari / 537.36': { - type: 'desktop', os: { name: 'Windows', version: 6.1 }, browser: { name: 'Chrome', version: 41 }, - }, - 'Mozilla/5.0 (hone; CPU one OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1': { - type: 'desktop', os: { name: '', version: 0 }, browser: { name: 'Safari', version: 11 }, - }, - 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.246': { - type: 'desktop', os: { name: 'Windows', version: 10 }, browser: { name: 'Edge', version: 12.246 }, - }, - 'Mozilla/5.0 (X11; CrOS x86_64 8172.45.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.64 Safari/537.36': { - type: 'desktop', os: { name: '', version: 0 }, browser: { name: 'Chrome', version: 51 }, - }, - 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_2) AppleWebKit/601.3.9 (KHTML, like Gecko) Version/9.0.2 Safari/601.3.9': { - type: 'desktop', os: { name: 'Mac', version: 10.11 }, browser: { name: 'Safari', version: 9 }, - }, - 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.111 Safari/537.36': { - type: 'desktop', os: { name: 'Windows', version: 6.1 }, browser: { name: 'Chrome', version: 47 }, - }, -}; -describe('Sublime Adapter', function () { - describe('detectDevice', function () { - it('should correctly detect device', function () { - const uaStub = sinon.stub(window.navigator, 'userAgent'); - - Object.entries(USER_AGENT).forEach(([userAgent, value]) => { - uaStub.value(userAgent); - expect(spec.detectDevice()).to.equal(value.type.charAt(0)); - }); +let utils = require('src/utils'); - uaStub.restore(); - }) - }); +describe('Sublime Adapter', function () { + const adapter = newBidder(spec); describe('sendEvent', function () { let sandbox; @@ -207,98 +42,28 @@ describe('Sublime Adapter', function () { describe('inherited functions', function () { it('exists and is a function', function () { - const adapter = newBidder(spec); expect(adapter.callBids).to.exist.and.to.be.a('function'); }); }); describe('isBidRequestValid', function () { - let bid; - beforeEach(function () { - bid = { - bidder: 'sublime', - params: { - zoneId: 24549, - endpoint: '', - }, - }; - }) - - afterEach(function () { - delete window.sublime; - }) + const bid = { + bidder: 'sublime', + params: { + zoneId: 24549, + endpoint: '', + }, + }; it('should return true when required params found', function () { expect(spec.isBidRequestValid(bid)).to.equal(true); }); - it('should return true when a valid notifyId is provided', function () { - bid.params.notifyId = 'f1514724-0922-4b45-a297-27531aeb829a'; - expect(spec.isBidRequestValid(bid)).to.equal(true); - }); - - it('should return false when an invalid notifyId is provided', function () { - bid.params.notifyId = 'some_invalid_notify_id'; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - it('should return false when required params are not passed', function () { + const bid = Object.assign({}, bid); bid.params = {}; expect(spec.isBidRequestValid(bid)).to.equal(false); }); - - it('should return false when the notifyId does not match sublime one', function () { - bid.params.notifyId = 'f1514724-0922-4b45-a297-27531aeb829a'; - window.sublime = { notifyId: '5c444a48-7713-4333-a895-44b1ae793417' }; - expect(spec.isBidRequestValid(bid)).to.equal(false); // FIX THIS - delete window.sublime; - }); - }); - - describe('getNotifyId', function () { - afterEach(function () { - delete window.sublime; - }); - - it('generates a notifyId (not in params, not in sublime)', function () { - const params = Object.freeze({}); - window.sublime = {}; - const notifyId = spec.getNotifyId(params); - expect(spec.isValidNotifyId(notifyId)).to.be.true; - expect(window.sublime.notifyId).to.equal(notifyId); - }); - - it('uses sublime notifyId (not in params, present in sublime)', function () { - const params = Object.freeze({}); - window.sublime = { notifyId: '5c444a48-7713-4333-a895-44b1ae793417' }; - const notifyId = spec.getNotifyId(params); - expect(notifyId).to.equal('5c444a48-7713-4333-a895-44b1ae793417'); - expect(window.sublime.notifyId).to.equal('5c444a48-7713-4333-a895-44b1ae793417'); - }); - - it('assigns notifyId from params to sublime (present in params, not in sublime)', function () { - const params = Object.freeze({ notifyId: 'f1514724-0922-4b45-a297-27531aeb829a' }); - window.sublime = {}; - const notifyId = spec.getNotifyId(params); - expect(notifyId).to.equal('f1514724-0922-4b45-a297-27531aeb829a'); - expect(window.sublime.notifyId).to.equal('f1514724-0922-4b45-a297-27531aeb829a'); - }); - - it('returns notifyId from params (same in params & in sublime)', function () { - const params = Object.freeze({ notifyId: 'f1514724-0922-4b45-a297-27531aeb829a' }); - window.sublime = { notifyId: 'f1514724-0922-4b45-a297-27531aeb829a' }; - const notifyId = spec.getNotifyId(params); - expect(notifyId).to.equal('f1514724-0922-4b45-a297-27531aeb829a'); - expect(window.sublime.notifyId).to.equal('f1514724-0922-4b45-a297-27531aeb829a'); - }); - - it('returns notifyId from params (present in params & in sublime, with mismatch)', function () { - const params = Object.freeze({ notifyId: 'f1514724-0922-4b45-a297-27531aeb829a' }); - window.sublime = { notifyId: '5c444a48-7713-4333-a895-44b1ae793417' }; - const notifyId = spec.getNotifyId(params); - expect(notifyId).to.equal('f1514724-0922-4b45-a297-27531aeb829a'); - expect(window.sublime.notifyId).to.equal('5c444a48-7713-4333-a895-44b1ae793417'); // did not change - }); }); describe('buildRequests', function () { @@ -311,8 +76,7 @@ describe('Sublime Adapter', function () { requestId: 'xyz654', params: { zoneId: 123, - callbackName: 'false', - notifyId: 'ea252d4f-93d9-4c2f-8cca-88cec3a0a347' + callbackName: 'false' } }, { bidder: 'sublime', @@ -337,32 +101,23 @@ describe('Sublime Adapter', function () { } }; + const request = spec.buildRequests(bidRequests, bidderRequest); + it('should have a post method', function () { - const request = spec.buildRequests(bidRequests, bidderRequest); expect(request[0].method).to.equal('POST'); expect(request[1].method).to.equal('POST'); }); it('should contains a request id equals to the bid id', function () { - const request = spec.buildRequests(bidRequests, bidderRequest); for (let i = 0; i < request.length; i = i + 1) { expect(JSON.parse(request[i].data).requestId).to.equal(bidRequests[i].bidId); } }); it('should have an url that contains bid keyword', function () { - const request = spec.buildRequests(bidRequests, bidderRequest); expect(request[0].url).to.match(/bid/); expect(request[1].url).to.match(/bid/); }); - - it('should contains a request notifyId', function () { - const request = spec.buildRequests(bidRequests, bidderRequest); - for (let i = 0; i < request.length; i = i + 1) { - const { notifyId } = JSON.parse(request[i].data); - expect(spec.isValidNotifyId(notifyId)).to.be.true; - } - }); }); describe('buildRequests: default arguments', function () { @@ -377,8 +132,9 @@ describe('Sublime Adapter', function () { } }]; + const request = spec.buildRequests(bidRequests); + it('should have an url that match the default endpoint', function () { - const request = spec.buildRequests(bidRequests); expect(request[0].url).to.equal('https://pbjs.sskzlabs.com/bid'); }); }); @@ -411,7 +167,7 @@ describe('Sublime Adapter', function () { sspname: 'foo', netRevenue: true, ttl: 600, - pbav: '0.8.0', + pbav: '0.7.3', ad: '', }, ]; @@ -454,7 +210,7 @@ describe('Sublime Adapter', function () { netRevenue: true, ttl: 600, ad: '', - pbav: '0.8.0', + pbav: '0.7.3', sspname: 'sublime' }; @@ -507,7 +263,7 @@ describe('Sublime Adapter', function () { netRevenue: true, ttl: 600, ad: '', - pbav: '0.8.0', + pbav: '0.7.3', }; expect(result[0]).to.deep.equal(expectedResponse); @@ -603,7 +359,7 @@ describe('Sublime Adapter', function () { it('should set timeout value in state', function () { spec.onTimeout(timeoutData); - expect(spec.state).to.deep.include({ timeout: 1234 }); + expect(spec.state).to.deep.equal({ timeout: 1234, debug: false, notifyId: undefined, transactionId: undefined, zoneId: 123 }); }); afterEach(function () {