diff --git a/.eslintrc.js b/.eslintrc.js index 56e4808f985..c64ab379c52 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -15,7 +15,8 @@ module.exports = { }, "extends": "standard", "plugins": [ - "prebid" + "prebid", + "import" ], "globals": { "$$PREBID_GLOBAL$$": false @@ -27,6 +28,7 @@ module.exports = { "comma-dangle": "off", "semi": "off", "space-before-function-paren": "off", + "import/extensions": ["error", "ignorePackages"], // Exceptions below this line are temporary, so that eslint can be added into the CI process. // Violations of these styles should be fixed, and the exceptions removed over time. @@ -35,8 +37,9 @@ module.exports = { "eqeqeq": "off", "no-return-assign": "off", "no-throw-literal": "off", - "no-undef": "off", + "no-undef": 2, "no-useless-escape": "off", + "no-console": "error" }, "overrides": Object.keys(allowedModules).map((key) => ({ "files": key + "/**/*.js", diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9c00a2bf51a..016f4055216 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -48,8 +48,10 @@ When you are adding code to Prebid.js, or modifying code that isn't covered by a - _Assert_: check that the expected results have occurred - e.g., use Chai assertions to check that the expected output is equal to the actual output - Test the public interface, not the internal implementation -- If you need to check `adloader.loadScript` in a test, use a `stub` rather than a `spy`. `spy`s trigger a network call which can result in a `script error` and cause unrelated unit tests to fail. `stub`s will let you gather information about the `adloader.loadScript` call without affecting external resources +- If you need to check `adloader.loadExternalScript` in a test, use a `stub` rather than a `spy`. `spy`s trigger a network call which can result in a `script error` and cause unrelated unit tests to fail. `stub`s will let you gather information about the `adloader.loadExternalScript` call without affecting external resources +- If your test makes ajax requests, use the global xhr stub in `test/mocks/xhr`. Do not use your own `sinon.useFakeXMLHttpRequest()` or `sinon.createFakeServer()`. - When writing tests you may use ES2015 syntax if desired +- If your test relies on `Window` or `global` object, do not mutate that object directly. Instead, create a separate copy of that object and perform operations on that new copy. ### Test Examples Prebid.js already has many tests. Read them to see how Prebid.js is tested, and for inspiration: diff --git a/PR_REVIEW.md b/PR_REVIEW.md index 4ad8b8ec372..64635b7fc03 100644 --- a/PR_REVIEW.md +++ b/PR_REVIEW.md @@ -16,9 +16,11 @@ For modules and core platform updates, the initial reviewer should request an ad - If the change results in needing updates to docs (such as public API change, module interface etc), add a label for "needs docs" and inform the submitter they must submit a docs PR to update the appropriate area of Prebid.org **before the PR can merge**. Help them with finding where the docs are located on prebid.org if needed. - Below are some examples of bidder specific updates that should require docs update (in their dev-docs/bidders/bidder.md file): - Add support for GDPR consentManagement module > add `gdpr_supported: true` + - Add support for US Privacy consentManagement module > add `usp_supported: true` - Add support for userId module > add `userId: pubCommon, digitrust, newProviderHere` - Add support for video and/or native mediaTypes > add `media_types: video, native` - Add support for COPPA > add `coppa_supported: true` + - Add support for SChain > add `schain_supported: true` - If all above is good, add a `LGTM` comment and request 1 additional core member to review. - Once there is 2 `LGTM` on the PR, merge to master - Ask the submitter to add a PR for documentation if applicable. @@ -29,7 +31,7 @@ For modules and core platform updates, the initial reviewer should request an ad - Follow steps above for general review process. In addition, please verify the following: - Verify that bidder has submitted valid bid params and that bids are being received. - Verify that bidder is not manipulating the prebid.js auction in any way or doing things that go against the principles of the project. If unsure check with the Tech Lead. -- Verify that the bidder is being as efficient as possible, ideally not loading an external library, however if they do load a library it should be cached. +- Verify that the bidder is being as efficient as possible, ideally not loading an external library, however if they do load a library it should be cached. - Verify that code re-use is being done properly and that changes introduced by a bidder don't impact other bidders. - If the adapter being submitted is an alias type, check with the bidder contact that is being aliased to make sure it's allowed. - If the adapter is triggering any user syncs make sure they are using the user sync module in the Prebid.js core. diff --git a/README.md b/README.md index be07a27ddc1..0e07521ac3b 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,7 @@ module.exports = { // override the regular exclusion from above (for being inside node_modules). { test: /.js$/, - include: new RegExp(`\\${path.sep}prebid\.js`), + include: new RegExp(`\\${path.sep}prebid\\.js`), use: { loader: 'babel-loader', // presets and plugins for Prebid.js must be manually specified separate from your other babel rule. diff --git a/allowedModules.js b/allowedModules.js index e66b8e24098..4f8b8039d97 100644 --- a/allowedModules.js +++ b/allowedModules.js @@ -1,24 +1,27 @@ const sharedWhiteList = [ - "core-js/library/fn/array/find", // no ie11 - "core-js/library/fn/array/includes", // no ie11 - "core-js/library/fn/set", // ie11 supports Set but not Set#values - "core-js/library/fn/string/includes", // no ie11 - "core-js/library/fn/number/is-integer", // no ie11, - "core-js/library/fn/array/from" // no ie11 + 'core-js/library/fn/array/find', // no ie11 + 'core-js/library/fn/array/includes', // no ie11 + 'core-js/library/fn/set', // ie11 supports Set but not Set#values + 'core-js/library/fn/string/includes', // no ie11 + 'core-js/library/fn/number/is-integer', // no ie11, + 'core-js/library/fn/array/from' // no ie11 ]; module.exports = { 'modules': [ ...sharedWhiteList, + 'criteo-direct-rsa-validate', 'jsencrypt', - 'crypto-js' + 'crypto-js', + 'live-connect' // Maintained by LiveIntent : https://github.com/liveintent-berlin/live-connect/ ], 'src': [ ...sharedWhiteList, 'fun-hooks/no-eval', 'just-clone', 'dlv', - 'dset' + 'dset', + 'deep-equal' ] }; diff --git a/browsers.json b/browsers.json index 9042d7d0627..91e0548d78a 100644 --- a/browsers.json +++ b/browsers.json @@ -7,11 +7,11 @@ "device": null, "os": "Windows" }, - "bs_edge_16_windows_10": { + "bs_edge_18_windows_10": { "base": "BrowserStack", "os_version": "10", "browser": "edge", - "browser_version": "16.0", + "browser_version": "18.0", "device": null, "os": "Windows" }, @@ -23,43 +23,43 @@ "device": null, "os": "Windows" }, - "bs_chrome_74_windows_10": { + "bs_chrome_80_windows_10": { "base": "BrowserStack", "os_version": "10", "browser": "chrome", - "browser_version": "74.0", + "browser_version": "80.0", "device": null, "os": "Windows" }, - "bs_chrome_75_windows_10": { + "bs_chrome_79_windows_10": { "base": "BrowserStack", "os_version": "10", "browser": "chrome", - "browser_version": "75.0", + "browser_version": "79.0", "device": null, "os": "Windows" }, - "bs_firefox_66_windows_10": { + "bs_firefox_73_windows_10": { "base": "BrowserStack", "os_version": "10", "browser": "firefox", - "browser_version": "66.0", + "browser_version": "73.0", "device": null, "os": "Windows" }, - "bs_firefox_67_windows_10": { + "bs_firefox_72_windows_10": { "base": "BrowserStack", "os_version": "10", "browser": "firefox", - "browser_version": "67.0", + "browser_version": "72.0", "device": null, "os": "Windows" }, - "bs_safari_11_mac_high_sierra": { + "bs_safari_11_mac_catalina": { "base": "BrowserStack", - "os_version": "High Sierra", + "os_version": "Catalina", "browser": "safari", - "browser_version": "11.1", + "browser_version": "13.0", "device": null, "os": "OS X" }, diff --git a/gulpHelpers.js b/gulpHelpers.js index 84f01b4e966..aabd28ced02 100644 --- a/gulpHelpers.js +++ b/gulpHelpers.js @@ -59,6 +59,7 @@ module.exports = { }); } + // we need to forcefuly include the parentModule if the subModule is present in modules list and parentModule is not present in modules list Object.keys(submodules).forEach(parentModule => { if ( !modules.includes(parentModule) && diff --git a/gulpfile.js b/gulpfile.js index 9df980523e0..45b82d4c716 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -73,11 +73,11 @@ function lint(done) { if (argv.nolint) { return done(); } - const isFixed = function(file) { + const isFixed = function (file) { return file.eslint != null && file.eslint.fixed; } - return gulp.src(['src/**/*.js', 'modules/**/*.js', 'test/**/*.js'], {base: './'}) - .pipe(gulpif(argv.nolintfix, eslint(), eslint({fix: true}))) + return gulp.src(['src/**/*.js', 'modules/**/*.js', 'test/**/*.js'], { base: './' }) + .pipe(gulpif(argv.nolintfix, eslint(), eslint({ fix: true }))) .pipe(eslint.format('stylish')) .pipe(eslint.failAfterError()) .pipe(gulpif(isFixed, gulp.dest('./'))); @@ -93,7 +93,7 @@ function viewCoverage(done) { connect.server({ port: coveragePort, - root: 'build/coverage/karma_html', + root: 'build/coverage/lcov-report', livereload: false }); opens('http://' + mylocalhost + ':' + coveragePort); @@ -189,7 +189,7 @@ function nodeBundle(modules) { .on('error', (err) => { reject(err); }) - .pipe(through.obj(function(file, enc, done) { + .pipe(through.obj(function (file, enc, done) { resolve(file.contents.toString(enc)); done(); })); @@ -237,7 +237,7 @@ function bundle(dev, moduleArr) { return gulp.src( entries ) - .pipe(gulpif(dev, sourcemaps.init({loadMaps: true}))) + .pipe(gulpif(dev, sourcemaps.init({ loadMaps: true }))) .pipe(concat(outputFileName)) .pipe(gulpif(!argv.manualEnable, footer('\n<%= global %>.processQueue();', { global: prebid.globalVarName @@ -281,7 +281,7 @@ function test(done) { } //run mock-server - const mockServer = spawn('node', ['./test/mock-server/index.js', '--port='+mockServerPort]); + const mockServer = spawn('node', ['./test/mock-server/index.js', '--port=' + mockServerPort]); mockServer.stdout.on('data', (data) => { console.log(`stdout: ${data}`); }); @@ -291,13 +291,13 @@ function test(done) { execa(wdioCmd, wdioOpts, { stdio: 'inherit' }) .then(stdout => { - //kill mock server + // kill mock server mockServer.kill('SIGINT'); done(); process.exit(0); }) .catch(err => { - //kill mock server + // kill mock server mockServer.kill('SIGINT'); done(new Error(`Tests failed with error: ${err}`)); process.exit(1); @@ -315,7 +315,7 @@ function test(done) { } function newKarmaCallback(done) { - return function(exitCode) { + return function (exitCode) { if (exitCode) { done(new Error('Karma tests failed with exit code ' + exitCode)); if (argv.browserstack) { @@ -343,7 +343,7 @@ function coveralls() { // 2nd arg is a dependency: 'test' must be finished // first send results of istanbul's test coverage to coveralls.io. return gulp.src('gulpfile.js', { read: false }) // You have to give it a file, but you don't - // have to read it. + // have to read it. .pipe(shell('cat build/coverage/lcov.info | node_modules/coveralls/bin/coveralls.js')); } @@ -377,10 +377,10 @@ function setupE2e(done) { done(); } -gulp.task('updatepath', function(){ +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')); + .pipe(replace('https://ib.adnxs.com/ut/v3/prebid', 'http://' + host + ':' + mockServerPort + '/')) + .pipe(gulp.dest('build/dist')); }); // support tasks diff --git a/integrationExamples/gpt/audigentSegments_example.html b/integrationExamples/gpt/audigentSegments_example.html new file mode 100644 index 00000000000..9b72da76d23 --- /dev/null +++ b/integrationExamples/gpt/audigentSegments_example.html @@ -0,0 +1,262 @@ + + + + + + + + + + + + + + + +

Audigent Segments Prebid

+ +
+ +
+TDID: +
+
+ +Audigent Segments: +
+
+ + diff --git a/integrationExamples/gpt/cmp_files/purposes.json b/integrationExamples/gpt/cmp_files/purposes.json new file mode 100644 index 00000000000..04219e92ce4 --- /dev/null +++ b/integrationExamples/gpt/cmp_files/purposes.json @@ -0,0 +1,25 @@ +{ + "version": 1, + "purposes": [ + { + "id": 25, + "name": "Custom Purpose 1", + "description": "Here's a description of the first purpose" + }, + { + "id": 26, + "name": "Custom Purpose 2", + "description": "Here's a description of the second purpose" + }, + { + "id": 27, + "name": "Custom Purpose 3", + "description": "Here's a description of the third purpose" + }, + { + "id": 28, + "name": "Custom Purpose 4", + "description": "Here's a description of the fourth purpose" + } + ] +} diff --git a/integrationExamples/gpt/digitrust_Full.html b/integrationExamples/gpt/digitrust_Full.html index 7ec268a619a..fc7704776f4 100644 --- a/integrationExamples/gpt/digitrust_Full.html +++ b/integrationExamples/gpt/digitrust_Full.html @@ -70,7 +70,7 @@ }()); var t = document.createElement('script'); t.async = false; - t.src = 'http://acdn.adnxs.com/cmp/cmp.bundle.js'; + t.src = 'https://acdn.adnxs.com/cmp/cmp.bundle.js'; var tag = document.getElementsByTagName('head')[0]; tag.appendChild(t); } diff --git a/integrationExamples/gpt/digitrust_Simple.html b/integrationExamples/gpt/digitrust_Simple.html index c9a8c1d2ad6..2581c6ce7cc 100644 --- a/integrationExamples/gpt/digitrust_Simple.html +++ b/integrationExamples/gpt/digitrust_Simple.html @@ -71,7 +71,7 @@ }()); var t = document.createElement('script'); t.async = false; - t.src = 'http://acdn.adnxs.com/cmp/cmp.bundle.js'; + t.src = 'https://acdn.adnxs.com/cmp/cmp.bundle.js'; var tag = document.getElementsByTagName('head')[0]; tag.appendChild(t); } @@ -86,6 +86,7 @@ { code: 'test-div', sizes: [[300, 250], [300, 600], [728, 90]], + mediaTypes: { banner: { sizes: [400, 600], name: 'testAdUnit'}}, bids: [ { bidder: 'rubicon', @@ -147,6 +148,9 @@ } else { console.error('Digitrust init failed'); + if(digiTrustResult.err){ + console.error(digiTrustResult.err); + } } } }, @@ -156,6 +160,12 @@ expires: 60 } }] + }, + userIdTargeting: { + "GAM": true, + "GAM_KEYS": { + "tdid": "TTD_ID" // send tdid as TTD_ID + } } }); pbjs.addAdUnits(adUnits); diff --git a/integrationExamples/gpt/digitrust_cmp_test.html b/integrationExamples/gpt/digitrust_cmp_test.html new file mode 100644 index 00000000000..6f0a70188f3 --- /dev/null +++ b/integrationExamples/gpt/digitrust_cmp_test.html @@ -0,0 +1,192 @@ + + + CMP Simple DigiTrust Prebid - No Framework + + + + + + + + + + + + + +

DigiTrust Prebid Sample - No Framework

+ +

+ This sample tests cmp behavior with simple integration path for using DigiTrust ID with Prebid. + You can use DigiTrust ID without integrating the entire DigiTrust suite. +

+
+ +
+ +
+ + + diff --git a/integrationExamples/gpt/hello_world.html b/integrationExamples/gpt/hello_world.html old mode 100644 new mode 100755 index d68e65011be..47ba5b8f18a --- a/integrationExamples/gpt/hello_world.html +++ b/integrationExamples/gpt/hello_world.html @@ -88,4 +88,4 @@
Div-1
- + \ No newline at end of file diff --git a/integrationExamples/gpt/prebidServer_example.html b/integrationExamples/gpt/prebidServer_example.html index db61a6a46d6..7761178efa8 100644 --- a/integrationExamples/gpt/prebidServer_example.html +++ b/integrationExamples/gpt/prebidServer_example.html @@ -36,7 +36,11 @@ pbjs.que.push(function() { var adUnits = [{ code: 'div-gpt-ad-1460505748561-0', - sizes: [[300, 250]], + mediaTypes: { + banner: { + sizes: [[300, 250]] + } + }, bids: [ { bidder: 'appnexus', diff --git a/integrationExamples/gpt/responsiveAds_sizeMappingV2.html b/integrationExamples/gpt/responsiveAds_sizeMappingV2.html new file mode 100644 index 00000000000..d262af5199a --- /dev/null +++ b/integrationExamples/gpt/responsiveAds_sizeMappingV2.html @@ -0,0 +1,121 @@ + + + + + + + + + + + + + + +

Prebid.js Test

+
Div-1
+
+ +
+ + + diff --git a/integrationExamples/gpt/revcontent_example.html b/integrationExamples/gpt/revcontent_example.html new file mode 100644 index 00000000000..ad0933885f3 --- /dev/null +++ b/integrationExamples/gpt/revcontent_example.html @@ -0,0 +1,109 @@ + + + + + + + + + + + +

Basic Prebid.js Example

+
Div-1
+
+ +
+ + + \ No newline at end of file diff --git a/karma.conf.maker.js b/karma.conf.maker.js index 9aa416375b5..290d31aa2a5 100644 --- a/karma.conf.maker.js +++ b/karma.conf.maker.js @@ -4,7 +4,6 @@ var _ = require('lodash'); var webpackConf = require('./webpack.conf'); -var path = require('path') var karmaConstants = require('karma').constants; function newWebpackConfig(codeCoverage) { @@ -33,7 +32,7 @@ function newWebpackConfig(codeCoverage) { function newPluginsArray(browserstack) { var plugins = [ 'karma-chrome-launcher', - 'karma-coverage-istanbul-reporter', + 'karma-coverage', 'karma-es5-shim', 'karma-mocha', 'karma-chai', @@ -66,18 +65,15 @@ function setReporters(karmaConf, codeCoverage, browserstack) { suppressPassed: true }; } + if (codeCoverage) { - karmaConf.reporters.push('coverage-istanbul'); - karmaConf.coverageIstanbulReporter = { - reports: ['html', 'lcovonly', 'text-summary'], - dir: path.join(__dirname, 'build', 'coverage'), - 'report-config': { - html: { - subdir: 'karma_html', - urlFriendlyName: true, // simply replaces spaces with _ for files/dirs - } - } - } + karmaConf.reporters.push('coverage'); + karmaConf.coverageReporter = { + dir: 'build/coverage', + reporters: [ + { type: 'lcov', subdir: '.' } + ] + }; } } @@ -92,7 +88,7 @@ function setBrowsers(karmaConf, browserstack) { karmaConf.browserStack.startTunnel = false; karmaConf.browserStack.tunnelIdentifier = process.env.BROWSERSTACK_LOCAL_IDENTIFIER; } - karmaConf.customLaunchers = require('./browsers.json') + karmaConf.customLaunchers = require('./browsers.json'); karmaConf.browsers = Object.keys(karmaConf.customLaunchers); } else { var isDocker = require('is-docker')(); @@ -157,6 +153,7 @@ module.exports = function(codeCoverage, browserstack, watchMode, file) { autoWatch: true, reporters: ['mocha'], + mochaReporter: { showDiff: true, output: 'minimal' @@ -165,10 +162,11 @@ module.exports = function(codeCoverage, browserstack, watchMode, file) { // Continuous Integration mode // if true, Karma captures browsers, runs the tests and exits singleRun: !watchMode, - browserDisconnectTimeout: 10000, // default 2000 - browserDisconnectTolerance: 1, // default 0 - browserNoActivityTimeout: 4 * 60 * 1000, // default 10000 - captureTimeout: 4 * 60 * 1000, // default 60000 + browserDisconnectTimeout: 3e5, // default 2000 + browserNoActivityTimeout: 3e5, // default 10000 + captureTimeout: 3e5, // default 60000, + browserDisconnectTolerance: 3, + concurrency: 5, plugins: plugins } diff --git a/modules/.submodules.json b/modules/.submodules.json index 0b3f8ffd68d..71d99c0a985 100644 --- a/modules/.submodules.json +++ b/modules/.submodules.json @@ -1,13 +1,16 @@ { "userId": [ + "unifiedIdSystem", + "pubCommonIdSystem", "digiTrustIdSystem", "id5IdSystem", "criteortusIdSystem", - "customIdSystem", "parrableIdSystem", "britepoolIdSystem", "liveIntentIdSystem", - "criteoIdSystem" + "criteoIdSystem", + "netIdSystem", + "identityLinkIdSystem" ], "adpod": [ "freeWheelAdserverVideo", diff --git a/modules/1ad4goodBidAdapter.js b/modules/1ad4goodBidAdapter.js index 26057b5e2b2..560808b368f 100644 --- a/modules/1ad4goodBidAdapter.js +++ b/modules/1ad4goodBidAdapter.js @@ -1,8 +1,8 @@ -import * as utils from '../src/utils'; -import { registerBidder } from '../src/adapters/bidderFactory'; -import { BANNER, VIDEO } from '../src/mediaTypes'; -import find from 'core-js/library/fn/array/find'; -import includes from 'core-js/library/fn/array/includes'; +import * as utils from '../src/utils.js'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { BANNER, VIDEO } from '../src/mediaTypes.js'; +import find from 'core-js/library/fn/array/find.js'; +import includes from 'core-js/library/fn/array/includes.js'; const BIDDER_CODE = '1ad4good'; const URL = 'https://hb.1ad4good.org/prebid'; diff --git a/modules/33acrossBidAdapter.js b/modules/33acrossBidAdapter.js index 87754bcba03..95524190e74 100644 --- a/modules/33acrossBidAdapter.js +++ b/modules/33acrossBidAdapter.js @@ -1,6 +1,6 @@ -import { registerBidder } from '../src/adapters/bidderFactory'; -import { config } from '../src/config'; -import * as utils from '../src/utils'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { config } from '../src/config.js'; +import * as utils from '../src/utils.js'; const BIDDER_CODE = '33across'; const END_POINT = 'https://ssc.33across.com/api/v1/hb'; @@ -38,6 +38,7 @@ function _getViewability(element, topWin, { w, h } = {}) { function _mapAdUnitPathToElementId(adUnitCode) { if (utils.isGptPubadsDefined()) { + // eslint-disable-next-line no-undef const adSlots = googletag.pubads().getSlots(); const isMatchingAdSlot = utils.isSlotMatchingAdUnitCode(adUnitCode); @@ -64,7 +65,7 @@ function _getAdSlotHTMLElement(adUnitCode) { // Infer the necessary data from valid bid for a minimal ttxRequest and create HTTP request // NOTE: At this point, TTX only accepts request for a single impression -function _createServerRequest(bidRequest, gdprConsent = {}) { +function _createServerRequest(bidRequest, gdprConsent = {}, pageUrl) { const ttxRequest = {}; const params = bidRequest.params; const element = _getAdSlotHTMLElement(bidRequest.adUnitCode); @@ -93,6 +94,9 @@ function _createServerRequest(bidRequest, gdprConsent = {}) { }; ttxRequest.site = { id: params.siteId }; + if (pageUrl) { + ttxRequest.site.page = pageUrl; + } // Go ahead send the bidId in request to 33exchange so it's kept track of in the bid response and // therefore in ad targetting process ttxRequest.id = bidRequest.bidId; @@ -297,9 +301,11 @@ function buildRequests(bidRequests, bidderRequest) { gdprApplies: false }, bidderRequest && bidderRequest.gdprConsent); + const pageUrl = (bidderRequest && bidderRequest.refererInfo) ? (bidderRequest.refererInfo.referer) : (undefined); + adapterState.uniqueSiteIds = bidRequests.map(req => req.params.siteId).filter(utils.uniques); - return bidRequests.map(req => _createServerRequest(req, gdprConsent)); + return bidRequests.map(req => _createServerRequest(req, gdprConsent, pageUrl)); } // NOTE: At this point, the response from 33exchange will only ever contain one bid i.e. the highest bid diff --git a/modules/7xbidBidAdapter.js b/modules/7xbidBidAdapter.js index 5464f87ee99..b925912a399 100644 --- a/modules/7xbidBidAdapter.js +++ b/modules/7xbidBidAdapter.js @@ -1,5 +1,5 @@ -import * as utils from '../src/utils'; -import { registerBidder } from '../src/adapters/bidderFactory'; +import * as utils from '../src/utils.js'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; const BIDDER_CODE = '7xbid'; const BIDDER_ALIAS = '7xb'; @@ -11,6 +11,10 @@ const SUPPORTED_CURRENCIES = ['USD', 'JPY']; const DEFAULT_CURRENCY = 'JPY'; const NET_REVENUE = true; +/** + * updated to support prebid 3.0 - remove utils.getTopWindowUrl() + */ + const _encodeURIComponent = function(a) { let b = window.encodeURIComponent(a); b = b.replace(/'/g, '%27'); @@ -63,7 +67,7 @@ export const spec = { 'placementid': bid.params.placementId, 'cur': bid.params.hasOwnProperty('currency') ? bid.params.currency : DEFAULT_CURRENCY, 'ua': navigator.userAgent, - 'loc': utils.getTopWindowUrl(), + 'loc': utils.deepAccess(bidderRequest, 'refererInfo.referer'), 'topframe': (window.parent === window.self) ? 1 : 0, 'sw': screen && screen.width, 'sh': screen && screen.height, diff --git a/modules/7xbidBidAdapter.md b/modules/7xbidBidAdapter.md index 13a448da992..692428332f0 100644 --- a/modules/7xbidBidAdapter.md +++ b/modules/7xbidBidAdapter.md @@ -24,7 +24,6 @@ Module that connects to 7xbid's demand sources params: { placementId: 1425292, currency: 'USD' - } } ] diff --git a/modules/a4gBidAdapter.js b/modules/a4gBidAdapter.js deleted file mode 100644 index d66630ce4db..00000000000 --- a/modules/a4gBidAdapter.js +++ /dev/null @@ -1,89 +0,0 @@ -import {registerBidder} from '../src/adapters/bidderFactory'; -import * as utils from '../src/utils'; - -const A4G_BIDDER_CODE = 'a4g'; -const A4G_CURRENCY = 'USD'; -const A4G_DEFAULT_BID_URL = '//ads.ad4game.com/v1/bid'; -const A4G_TTL = 120; - -const LOCATION_PARAM_NAME = 'siteurl'; -const ID_PARAM_NAME = 'id'; -const IFRAME_PARAM_NAME = 'if'; -const ZONE_ID_PARAM_NAME = 'zoneId'; -const SIZE_PARAM_NAME = 'size'; - -const ARRAY_PARAM_SEPARATOR = ';'; -const ARRAY_SIZE_SEPARATOR = ','; -const SIZE_SEPARATOR = 'x'; - -export const spec = { - code: A4G_BIDDER_CODE, - isBidRequestValid: function(bid) { - return bid.params && !!bid.params.zoneId; - }, - - buildRequests: function(validBidRequests, bidderRequest) { - let deliveryUrl = ''; - const idParams = []; - const sizeParams = []; - const zoneIds = []; - - utils._each(validBidRequests, function(bid) { - if (!deliveryUrl && typeof bid.params.deliveryUrl === 'string') { - deliveryUrl = bid.params.deliveryUrl; - } - idParams.push(bid.bidId); - sizeParams.push(bid.sizes.map(size => size.join(SIZE_SEPARATOR)).join(ARRAY_SIZE_SEPARATOR)); - zoneIds.push(bid.params.zoneId); - }); - - if (!deliveryUrl) { - deliveryUrl = A4G_DEFAULT_BID_URL; - } - - let data = { - [IFRAME_PARAM_NAME]: 0, - [LOCATION_PARAM_NAME]: utils.getTopWindowUrl(), - [SIZE_PARAM_NAME]: sizeParams.join(ARRAY_PARAM_SEPARATOR), - [ID_PARAM_NAME]: idParams.join(ARRAY_PARAM_SEPARATOR), - [ZONE_ID_PARAM_NAME]: zoneIds.join(ARRAY_PARAM_SEPARATOR) - }; - - if (bidderRequest && bidderRequest.gdprConsent) { - data.gdpr = { - applies: bidderRequest.gdprConsent.gdprApplies, - consent: bidderRequest.gdprConsent.consentString - }; - } - - return { - method: 'GET', - url: deliveryUrl, - data: data - }; - }, - - interpretResponse: function(serverResponses, request) { - const bidResponses = []; - utils._each(serverResponses.body, function(response) { - if (response.cpm > 0) { - const bidResponse = { - requestId: response.id, - creativeId: response.id, - adId: response.id, - cpm: response.cpm, - width: response.width, - height: response.height, - currency: A4G_CURRENCY, - netRevenue: true, - ttl: A4G_TTL, - ad: response.ad - }; - bidResponses.push(bidResponse); - } - }); - return bidResponses; - } -}; - -registerBidder(spec); diff --git a/modules/aardvarkBidAdapter.js b/modules/aardvarkBidAdapter.js index 9caaaaa747c..0b864286868 100644 --- a/modules/aardvarkBidAdapter.js +++ b/modules/aardvarkBidAdapter.js @@ -1,5 +1,5 @@ -import * as utils from '../src/utils'; -import {registerBidder} from '../src/adapters/bidderFactory'; +import * as utils from '../src/utils.js'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; const BIDDER_CODE = 'aardvark'; const DEFAULT_ENDPOINT = 'bidder.rtk.io'; @@ -15,11 +15,12 @@ export function resetUserSync() { export const spec = { code: BIDDER_CODE, + gvlid: 52, aliases: ['adsparc', 'safereach'], isBidRequestValid: function(bid) { return ((typeof bid.params.ai === 'string') && !!bid.params.ai.length && - (typeof bid.params.sc === 'string') && !!bid.params.sc.length); + (typeof bid.params.sc === 'string') && !!bid.params.sc.length); }, buildRequests: function(validBidRequests, bidderRequest) { @@ -31,6 +32,7 @@ export const spec = { var tdId = ''; var width = window.innerWidth; var height = window.innerHeight; + var schain = ''; // This reference to window.top can cause issues when loaded in an iframe if not protected with a try/catch. try { @@ -46,6 +48,8 @@ export const spec = { tdId = validBidRequests[0].userId.tdid; } + schain = spec.serializeSupplyChain(utils.deepAccess(validBidRequests, '0.schain')); + utils._each(validBidRequests, function(b) { var rMap = requestsMap[b.params.ai]; if (!rMap) { @@ -64,6 +68,9 @@ export const spec = { if (tdId) { rMap.payload.tdid = tdId; } + if (schain) { + rMap.payload.schain = schain; + } if (pageCategories && pageCategories.length) { rMap.payload.categories = pageCategories.slice(0); @@ -76,7 +83,7 @@ export const spec = { }); } - if (bidderRequest && bidderRequest.gdprConsent) { + if (bidderRequest.gdprConsent) { rMap.payload.gdpr = false; if (typeof bidderRequest.gdprConsent.gdprApplies === 'boolean') { rMap.payload.gdpr = bidderRequest.gdprConsent.gdprApplies; @@ -90,11 +97,15 @@ export const spec = { auctionCodes.push(b.params.ai); } + if (bidderRequest.uspConsent) { + rMap.payload.us_privacy = bidderRequest.uspConsent + } + rMap.shortCodes.push(b.params.sc); rMap.payload[b.params.sc] = b.bidId; if ((typeof b.params.host === 'string') && b.params.host.length && - (b.params.host !== rMap.endpoint)) { + (b.params.host !== rMap.endpoint)) { rMap.endpoint = b.params.host; } }); @@ -103,7 +114,7 @@ export const spec = { var req = requestsMap[auctionId]; requests.push({ method: 'GET', - url: `//${req.endpoint}/${auctionId}/${req.shortCodes.join('_')}/aardvark`, + url: `https://${req.endpoint}/${auctionId}/${req.shortCodes.join('_')}/aardvark`, data: req.payload, bidderRequest }); @@ -160,30 +171,92 @@ export const spec = { return bidResponses; }, - getUserSyncs: function(syncOptions, serverResponses, gdprConsent) { + getUserSyncs: function(syncOptions, serverResponses, gdprConsent, uspConsent) { const syncs = []; - var url = '//' + SYNC_ENDPOINT + '/cs'; + const params = []; var gdprApplies = false; if (gdprConsent && (typeof gdprConsent.gdprApplies === 'boolean')) { gdprApplies = gdprConsent.gdprApplies; } - if (syncOptions.iframeEnabled) { - if (!hasSynced) { - hasSynced = true; - if (gdprApplies) { - url = url + '?g=1&c=' + encodeURIComponent(gdprConsent.consentString); - } - syncs.push({ - type: 'iframe', - url: url - }); - } - } else { + if (!syncOptions.iframeEnabled) { utils.logWarn('Aardvark: Please enable iframe based user sync.'); + return syncs; + } + + if (hasSynced) { + return syncs; } + + hasSynced = true; + if (gdprApplies) { + params.push(['g', '1']); + params.push(['c', gdprConsent.consentString]); + } + + if (uspConsent) { + params.push(['us_privacy', uspConsent]); + } + + var queryStr = ''; + if (params.length) { + queryStr = '?' + params.map(p => p[0] + '=' + encodeURIComponent(p[1])).join('&') + } + + syncs.push({ + type: 'iframe', + url: `https://${SYNC_ENDPOINT}/cs${queryStr}` + }); return syncs; - } + }, + + /** + * Serializes schain params according to OpenRTB requirements + * @param {Object} supplyChain + * @returns {String} + */ + serializeSupplyChain: function (supplyChain) { + if (!hasValidSupplyChainParams(supplyChain)) { + return ''; + } + + return `${supplyChain.ver},${supplyChain.complete}!${spec.serializeSupplyChainNodes(supplyChain.nodes)}`; + }, + + /** + * Properly sorts schain object params + * @param {Array} nodes + * @returns {String} + */ + serializeSupplyChainNodes: function (nodes) { + const nodePropOrder = ['asi', 'sid', 'hp', 'rid', 'name', 'domain']; + return nodes.map(node => { + return nodePropOrder.map(prop => encodeURIComponent(node[prop] || '')).join(','); + }).join('!'); + }, }; +/** + * Make sure the required params are present + * @param {Object} schain + * @param {Bool} + */ +export function hasValidSupplyChainParams(schain) { + if (!schain || !schain.nodes) { + return false; + } + const requiredFields = ['asi', 'sid', 'hp']; + + let isValid = schain.nodes.reduce((status, node) => { + if (!status) { + return status; + } + return requiredFields.every(field => node[field]); + }, true); + if (!isValid) { + utils.logError('Aardvark: required schain params missing'); + } + return isValid; +} + registerBidder(spec); diff --git a/modules/ablidaBidAdapter.js b/modules/ablidaBidAdapter.js index 33642a1ac9e..ad507c18b24 100644 --- a/modules/ablidaBidAdapter.js +++ b/modules/ablidaBidAdapter.js @@ -1,6 +1,6 @@ -import * as utils from '../src/utils'; -import {config} from '../src/config'; -import {registerBidder} from '../src/adapters/bidderFactory'; +import * as utils from '../src/utils.js'; +import {config} from '../src/config.js'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; const BIDDER_CODE = 'ablida'; const ENDPOINT_URL = 'https://bidder.ablida.net/prebid'; diff --git a/modules/adagioAnalyticsAdapter.js b/modules/adagioAnalyticsAdapter.js index 32b9f0d1b0c..fd7a742d9e7 100644 --- a/modules/adagioAnalyticsAdapter.js +++ b/modules/adagioAnalyticsAdapter.js @@ -2,10 +2,10 @@ * Analytics Adapter for Adagio */ -import adapter from '../src/AnalyticsAdapter'; -import adapterManager from '../src/adapterManager'; +import adapter from '../src/AnalyticsAdapter.js'; +import adapterManager from '../src/adapterManager.js'; import CONSTANTS from '../src/constants.json'; -import * as utils from '../src/utils'; +import * as utils from '../src/utils.js'; const emptyUrl = ''; const analyticsType = 'endpoint'; diff --git a/modules/adagioBidAdapter.js b/modules/adagioBidAdapter.js index 76614e52bc5..a21915e00a9 100644 --- a/modules/adagioBidAdapter.js +++ b/modules/adagioBidAdapter.js @@ -1,17 +1,20 @@ -import find from 'core-js/library/fn/array/find'; -import * as utils from '../src/utils'; -import {registerBidder} from '../src/adapters/bidderFactory'; -import { loadExternalScript } from '../src/adloader' -import JSEncrypt from 'jsencrypt/bin/jsencrypt'; -import sha256 from 'crypto-js/sha256'; +import find from 'core-js/library/fn/array/find.js'; +import * as utils from '../src/utils.js'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; +import { loadExternalScript } from '../src/adloader.js' +import JSEncrypt from 'jsencrypt/bin/jsencrypt.js'; +import sha256 from 'crypto-js/sha256.js'; +import { getStorageManager } from '../src/storageManager.js'; const BIDDER_CODE = 'adagio'; -const VERSION = '2.0.0'; +const VERSION = '2.2.1'; const FEATURES_VERSION = '1'; const ENDPOINT = 'https://mp.4dex.io/prebid'; const SUPPORTED_MEDIA_TYPES = ['banner']; -const ADAGIO_TAG_URL = '//script.4dex.io/localstore.js'; +const ADAGIO_TAG_URL = 'https://script.4dex.io/localstore.js'; const ADAGIO_LOCALSTORAGE_KEY = 'adagioScript'; +const GVLID = 617; +const storage = getStorageManager(GVLID, 'adagio'); export const ADAGIO_PUBKEY = `-----BEGIN PUBLIC KEY----- MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC9el0+OEn6fvEh1RdVHQu4cnT0 @@ -20,11 +23,8 @@ t0b0lsHN+W4n9kitS/DZ/xnxWK/9vxhv0ZtL1LL/rwR5Mup7rmJbNtDoNBw4TIGj pV6EP3MTLosuUEpLaQIDAQAB -----END PUBLIC KEY-----`; -export function getAdagioScript() { +export function adagioScriptFromLocalStorageCb(ls) { try { - const w = utils.getWindowTop(); - const ls = w.localStorage.getItem(ADAGIO_LOCALSTORAGE_KEY); - if (!ls) { utils.logWarn('Adagio Script not found'); return; @@ -34,7 +34,7 @@ export function getAdagioScript() { if (!hashRgx.test(ls)) { utils.logWarn('No hash found in Adagio script'); - w.localStorage.removeItem(ADAGIO_LOCALSTORAGE_KEY); + storage.removeDataFromLocalStorage(ADAGIO_LOCALSTORAGE_KEY); } else { const r = ls.match(hashRgx); const hash = r[2]; @@ -48,7 +48,7 @@ export function getAdagioScript() { Function(ls)(); // eslint-disable-line no-new-func } else { utils.logWarn('Invalid Adagio script found'); - w.localStorage.removeItem(ADAGIO_LOCALSTORAGE_KEY); + storage.removeDataFromLocalStorage(ADAGIO_LOCALSTORAGE_KEY); } } } catch (err) { @@ -56,6 +56,12 @@ export function getAdagioScript() { } } +export function getAdagioScript() { + storage.getDataFromLocalStorage(ADAGIO_LOCALSTORAGE_KEY, (ls) => { + adagioScriptFromLocalStorageCb(ls) + }); +} + function canAccessTopWindow() { try { if (utils.getWindowTop().location.href) { @@ -84,22 +90,25 @@ if (canAccessTopWindow()) { } const _features = { - getPrintNumber: function(adUnitCode) { + getPrintNumber: function (adUnitCode) { const adagioAdUnit = _getOrAddAdagioAdUnit(adUnitCode); return adagioAdUnit.printNumber || 1; }, - getPageDimensions: function() { + getPageDimensions: function () { const viewportDims = _features.getViewPortDimensions().split('x'); const w = utils.getWindowTop(); const body = w.document.body; + if (!body) { + return '' + } const html = w.document.documentElement; const pageHeight = Math.max(body.scrollHeight, body.offsetHeight, html.clientHeight, html.scrollHeight, html.offsetHeight); return viewportDims[0] + 'x' + pageHeight; }, - getViewPortDimensions: function() { + getViewPortDimensions: function () { let viewPortWidth; let viewPortHeight; const w = utils.getWindowTop(); @@ -116,7 +125,7 @@ const _features = { return viewPortWidth + 'x' + viewPortHeight; }, - isDomLoading: function() { + isDomLoading: function () { const w = utils.getWindowTop(); let performance = w.performance || w.msPerformance || w.webkitPerformance || w.mozPerformance; let domLoading = -1; @@ -128,7 +137,9 @@ const _features = { return domLoading; }, - getSlotPosition: function(element) { + getSlotPosition: function (element) { + if (!element) return ''; + const w = utils.getWindowTop(); const d = w.document; const el = element; @@ -160,11 +171,11 @@ const _features = { return position.x + 'x' + position.y; }, - getTimestamp: function() { + getTimestamp: function () { return Math.floor(new Date().getTime() / 1000) - new Date().getTimezoneOffset() * 60; }, - getDevice: function() { + getDevice: function () { if (!canAccessTopWindow()) return false; const w = utils.getWindowTop(); const ua = w.navigator.userAgent; @@ -178,14 +189,14 @@ const _features = { return 2; // personal computers }, - getBrowser: function() { + getBrowser: function () { const w = utils.getWindowTop(); const ua = w.navigator.userAgent; const uaLowerCase = ua.toLowerCase(); return /Edge\/\d./i.test(ua) ? 'edge' : uaLowerCase.indexOf('chrome') > 0 ? 'chrome' : uaLowerCase.indexOf('firefox') > 0 ? 'firefox' : uaLowerCase.indexOf('safari') > 0 ? 'safari' : uaLowerCase.indexOf('opera') > 0 ? 'opera' : uaLowerCase.indexOf('msie') > 0 || w.MSStream ? 'ie' : 'unknow'; }, - getOS: function() { + getOS: function () { const w = window.top; const ua = w.navigator.userAgent; const uaLowerCase = ua.toLowerCase(); @@ -194,9 +205,11 @@ const _features = { } function _pushInAdagioQueue(ob) { - if (!canAccessTopWindow()) return; - const w = utils.getWindowTop(); - w.ADAGIO.queue.push(ob); + try { + if (!canAccessTopWindow()) return; + const w = utils.getWindowTop(); + w.ADAGIO.queue.push(ob); + } catch (e) {} }; function _getOrAddAdagioAdUnit(adUnitCode) { @@ -288,22 +301,19 @@ function _getFeatures(bidRequest) { element = w.document.getElementById(adUnitElementId); } - let features = {}; - if (element) { - features = Object.assign({}, { - print_number: _features.getPrintNumber(bidRequest.adUnitCode).toString(), - page_dimensions: _features.getPageDimensions().toString(), - viewport_dimensions: _features.getViewPortDimensions().toString(), - dom_loading: _features.isDomLoading().toString(), - // layout: features.getLayout().toString(), - adunit_position: _features.getSlotPosition(element).toString(), - user_timestamp: _features.getTimestamp().toString(), - device: _features.getDevice().toString(), - url: w.location.origin + w.location.pathname, - browser: _features.getBrowser(), - os: _features.getOS() - }) - } + const features = { + print_number: _features.getPrintNumber(bidRequest.adUnitCode).toString(), + page_dimensions: _features.getPageDimensions().toString(), + viewport_dimensions: _features.getViewPortDimensions().toString(), + dom_loading: _features.isDomLoading().toString(), + // layout: features.getLayout().toString(), + adunit_position: _features.getSlotPosition(element).toString(), + user_timestamp: _features.getTimestamp().toString(), + device: _features.getDevice().toString(), + url: w.location.origin + w.location.pathname, + browser: _features.getBrowser(), + os: _features.getOS() + }; const adUnitFeature = {}; adUnitFeature[adUnitElementId] = { @@ -332,51 +342,63 @@ function _getGdprConsent(bidderRequest) { if (bidderRequest.gdprConsent.allowAuctionWithoutConsent !== undefined) { consent.allowAuctionWithoutConsent = bidderRequest.gdprConsent.allowAuctionWithoutConsent ? 1 : 0; } + if (bidderRequest.gdprConsent.apiVersion !== undefined) { + consent.apiVersion = bidderRequest.gdprConsent.apiVersion; + } } return consent; } +function _getSchain(bidRequest) { + if (utils.deepAccess(bidRequest, 'schain')) { + return bidRequest.schain; + } +} + export const spec = { code: BIDDER_CODE, - + gvlid: GVLID, supportedMediaType: SUPPORTED_MEDIA_TYPES, - isBidRequestValid: function(bid) { + isBidRequestValid: function (bid) { const { adUnitCode, auctionId, sizes, bidder, params, mediaTypes } = bid; const { organizationId, site, placement, adUnitElementId } = bid.params; let isValid = false; - if (canAccessTopWindow()) { - const w = utils.getWindowTop(); - w.ADAGIO = w.ADAGIO || {}; - w.ADAGIO.adUnits = w.ADAGIO.adUnits || {}; - w.ADAGIO.pbjsAdUnits = w.ADAGIO.pbjsAdUnits || []; - isValid = !!(organizationId && site && placement && adUnitElementId && document.getElementById(adUnitElementId) !== null); - const tempAdUnits = w.ADAGIO.pbjsAdUnits.filter((adUnit) => adUnit.code !== adUnitCode); - tempAdUnits.push({ - code: adUnitCode, - sizes: (mediaTypes && mediaTypes.banner && Array.isArray(mediaTypes.banner.sizes)) ? mediaTypes.banner.sizes : sizes, - bids: [{ - bidder, - params - }] - }); - w.ADAGIO.pbjsAdUnits = tempAdUnits; - - if (isValid === true) { - let printNumber = _computePrintNumber(adUnitCode); - w.ADAGIO.adUnits[adUnitCode] = { - auctionId: auctionId, - pageviewId: _getPageviewId(), - printNumber - }; + try { + if (canAccessTopWindow()) { + const w = utils.getWindowTop(); + w.ADAGIO = w.ADAGIO || {}; + w.ADAGIO.adUnits = w.ADAGIO.adUnits || {}; + w.ADAGIO.pbjsAdUnits = w.ADAGIO.pbjsAdUnits || []; + isValid = !!(organizationId && site && placement && adUnitElementId); + const tempAdUnits = w.ADAGIO.pbjsAdUnits.filter((adUnit) => adUnit.code !== adUnitCode); + tempAdUnits.push({ + code: adUnitCode, + sizes: (mediaTypes && mediaTypes.banner && Array.isArray(mediaTypes.banner.sizes)) ? mediaTypes.banner.sizes : sizes, + bids: [{ + bidder, + params + }] + }); + w.ADAGIO.pbjsAdUnits = tempAdUnits; + + if (isValid === true) { + let printNumber = _computePrintNumber(adUnitCode); + w.ADAGIO.adUnits[adUnitCode] = { + auctionId: auctionId, + pageviewId: _getPageviewId(), + printNumber + }; + } } + } catch (e) { + return isValid; } - return isValid; }, - buildRequests: function(validBidRequests, bidderRequest) { + buildRequests: function (validBidRequests, bidderRequest) { // AdagioBidAdapter works when window.top can be reached only if (!bidderRequest.refererInfo.reachedTop) return []; @@ -385,6 +407,7 @@ export const spec = { const site = _getSite(); const pageviewId = _getPageviewId(); const gdprConsent = _getGdprConsent(bidderRequest); + const schain = _getSchain(validBidRequests[0]); const adUnits = utils._map(validBidRequests, (bidRequest) => { bidRequest.features = _getFeatures(bidRequest); return bidRequest; @@ -392,6 +415,9 @@ export const spec = { // Regroug ad units by siteId const groupedAdUnits = adUnits.reduce((groupedAdUnits, adUnit) => { + if (adUnit.params && adUnit.params.organizationId) { + adUnit.params.organizationId = adUnit.params.organizationId.toString(); + } (groupedAdUnits[adUnit.params.organizationId] = groupedAdUnits[adUnit.params.organizationId] || []).push(adUnit); return groupedAdUnits; }, {}); @@ -410,12 +436,13 @@ export const spec = { pageviewId: pageviewId, adUnits: groupedAdUnits[organizationId], gdpr: gdprConsent, + schain: schain, prebidVersion: '$prebid.version$', adapterVersion: VERSION, featuresVersion: FEATURES_VERSION }, options: { - contentType: 'application/json' + contentType: 'text/plain' } } }); @@ -423,7 +450,7 @@ export const spec = { return requests; }, - interpretResponse: function(serverResponse, bidRequest) { + interpretResponse: function (serverResponse, bidRequest) { let bidResponses = []; try { const response = serverResponse.body; @@ -456,7 +483,7 @@ export const spec = { return bidResponses; }, - getUserSyncs: function(syncOptions, serverResponses) { + getUserSyncs: function (syncOptions, serverResponses) { if (!serverResponses.length || serverResponses[0].body === '' || !serverResponses[0].body.userSyncs) { return false; } diff --git a/modules/adbutlerBidAdapter.js b/modules/adbutlerBidAdapter.js index 88aa4f158b7..47162aa2445 100644 --- a/modules/adbutlerBidAdapter.js +++ b/modules/adbutlerBidAdapter.js @@ -1,8 +1,8 @@ 'use strict'; -import * as utils from '../src/utils'; -import {config} from '../src/config'; -import {registerBidder} from '../src/adapters/bidderFactory'; +import * as utils from '../src/utils.js'; +import {config} from '../src/config.js'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; const BIDDER_CODE = 'adbutler'; @@ -16,15 +16,15 @@ export const spec = { }, buildRequests: function (validBidRequests) { - var i; - var zoneID; - var bidRequest; - var accountID; - var keyword; - var domain; - var requestURI; - var serverRequests = []; - var zoneCounters = {}; + let i; + let zoneID; + let bidRequest; + let accountID; + let keyword; + let domain; + let requestURI; + let serverRequests = []; + let zoneCounters = {}; for (i = 0; i < validBidRequests.length; i++) { bidRequest = validBidRequests[i]; @@ -41,7 +41,7 @@ export const spec = { domain = 'servedbyadbutler.com'; } - requestURI = location.protocol + '//' + domain + '/adserve/;type=hbr;'; + requestURI = 'https://' + domain + '/adserve/;type=hbr;'; requestURI += 'ID=' + encodeURIComponent(accountID) + ';'; requestURI += 'setID=' + encodeURIComponent(zoneID) + ';'; requestURI += 'pid=' + encodeURIComponent(spec.pageID) + ';'; @@ -64,16 +64,16 @@ export const spec = { }, interpretResponse: function (serverResponse, bidRequest) { - var bidObj = bidRequest.bidRequest; - var bidResponses = []; - var bidResponse = {}; - var isCorrectSize = false; - var isCorrectCPM = true; - var CPM; - var minCPM; - var maxCPM; - var width; - var height; + const bidObj = bidRequest.bidRequest; + let bidResponses = []; + let 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) { @@ -92,7 +92,7 @@ export const spec = { } // Ensure that response ad matches one of the placement sizes. - utils._each(bidObj.sizes, function (size) { + utils._each(utils.deepAccess(bidObj, 'mediaTypes.banner.sizes', []), function (size) { if (width === size[0] && height === size[1]) { isCorrectSize = true; } @@ -109,7 +109,7 @@ export const spec = { bidResponse.currency = 'USD'; bidResponse.netRevenue = true; bidResponse.ttl = config.getConfig('_bidderTimeout'); - bidResponse.referrer = utils.getTopWindowUrl(); + bidResponse.referrer = utils.deepAccess(bidObj, 'refererInfo.referer'); bidResponses.push(bidResponse); } } @@ -117,9 +117,9 @@ export const spec = { }, addTrackingPixels: function (trackingPixels) { - var trackingPixelMarkup = ''; + let trackingPixelMarkup = ''; utils._each(trackingPixels, function (pixelURL) { - var trackingPixel = ''; diff --git a/modules/weboramaBidAdapter.js b/modules/adfinityBidAdapter.js similarity index 57% rename from modules/weboramaBidAdapter.js rename to modules/adfinityBidAdapter.js index f1eb0b7fdaf..ebf1198fba2 100644 --- a/modules/weboramaBidAdapter.js +++ b/modules/adfinityBidAdapter.js @@ -1,22 +1,24 @@ -import { registerBidder } from '../src/adapters/bidderFactory'; -import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes'; -import * as utils from '../src/utils'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js'; +import * as utils from '../src/utils.js'; -const BIDDER_CODE = 'weborama'; -const URL = '//supply.nl.weborama.fr/?c=o&m=multi'; -const URL_SYNC = '//supply.nl.weborama.fr/?c=o&m=cookie'; +const BIDDER_CODE = 'adfinity'; +const AD_URL = 'https://stat.adfinity.pro/?c=o&m=multi'; +const SYNC_URL = 'https://stat.adfinity.pro/?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); + const n = bid.native + return Boolean(n) && Boolean(n.title) && Boolean(n.body) && Boolean(n.image) && Boolean(n.impression_trackers); default: return false; } @@ -25,7 +27,6 @@ function isBidResponseValid(bid) { export const spec = { code: BIDDER_CODE, supportedMediaTypes: [BANNER, VIDEO, NATIVE], - /** * Determines whether or not the given bid request is valid. * @@ -33,11 +34,7 @@ export const spec = { * @return boolean True if this is a valid bid, and false otherwise. */ isBidRequestValid: (bid) => { - return Boolean(bid.bidId && - bid.params && - !isNaN(bid.params.placementId) && - spec.supportedMediaTypes.indexOf(bid.params.traffic) !== -1 - ); + return Boolean(bid.bidId && bid.params && !isNaN(bid.params.placement_id)); }, /** @@ -46,40 +43,51 @@ export const spec = { * @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; + buildRequests: (validBidRequests, bidderRequest) => { + let winTop = window; + let location; try { - winTop = utils.getWindowTop(); - winTop.location.toString(); + location = new URL(bidderRequest.refererInfo.referer) + winTop = window.top; } catch (e) { + location = winTop.location; utils.logMessage(e); - winTop = window; }; - - const location = utils.getTopWindowLocation(); - const placements = []; - const request = { - 'secure': (location.protocol === 'https:') ? 1 : 0, + let placements = []; + let request = { 'deviceWidth': winTop.screen.width, 'deviceHeight': winTop.screen.height, + 'language': (navigator && navigator.language) ? navigator.language : '', + 'secure': 1, 'host': location.host, 'page': location.pathname, 'placements': placements }; + if (bidderRequest) { + if (bidderRequest.gdprConsent) { + request.gdpr_consent = bidderRequest.gdprConsent.consentString || 'ALL' + request.gdpr_require = bidderRequest.gdprConsent.gdprApplies ? 1 : 0 + } + } + for (let i = 0; i < validBidRequests.length; i++) { - const bid = validBidRequests[i]; - const params = bid.params; - placements.push({ - placementId: params.placementId, + let bid = validBidRequests[i]; + let traff = bid.params.traffic || BANNER + let placement = { + placementId: bid.params.placement_id, bidId: bid.bidId, - sizes: bid.sizes, - traffic: params.traffic - }); + sizes: bid.mediaTypes[traff].sizes, + traffic: traff + }; + if (bid.schain) { + placement.schain = bid.schain; + } + placements.push(placement); } return { method: 'POST', - url: URL, + url: AD_URL, data: request }; }, @@ -109,7 +117,7 @@ export const spec = { getUserSyncs: () => { return [{ type: 'image', - url: URL_SYNC + url: SYNC_URL }]; } }; diff --git a/modules/adfinityBidAdapter.md b/modules/adfinityBidAdapter.md new file mode 100644 index 00000000000..f67d4fddfe7 --- /dev/null +++ b/modules/adfinityBidAdapter.md @@ -0,0 +1,67 @@ +# Overview + +``` +Module Name: Adfinity Bidder Adapter +Module Type: Bidder Adapter +Maintainer: adfinity_prebid@i.ua +``` + +# Description + +Module that connects to Adfinity demand sources + +# Test Parameters +``` + var adUnits = [ + { + code: 'placementid_0', + mediaTypes: { + banner: { + sizes: [[300, 250], [300,600]] + } + }, + bids: [{ + bidder: 'adfinity', + params: { + placement_id: 0, + traffic: 'banner' + } + } + ] + }, + { + code: 'placementid_0', + mediaTypes: { + native: { + + } + }, + bids: [ + { + bidder: 'adfinity', + params: { + placement_id: 0, + traffic: 'native' + } + } + ] + }, + { + code: 'placementid_0', + mediaTypes: { + video: { + sizes: [[300, 250], [300,600]] + } + }, + bids: [ + { + bidder: 'adfinity', + params: { + placement_id: 0, + traffic: 'video' + } + } + ] + } + ]; +``` \ No newline at end of file diff --git a/modules/adformBidAdapter.js b/modules/adformBidAdapter.js index 8d37f97be07..946ed2bc3fd 100644 --- a/modules/adformBidAdapter.js +++ b/modules/adformBidAdapter.js @@ -1,10 +1,10 @@ 'use strict'; -import { registerBidder } from '../src/adapters/bidderFactory'; -import { config } from '../src/config'; -import { BANNER, VIDEO } from '../src/mediaTypes'; -import { Renderer } from '../src/Renderer'; -import * as utils from '../src/utils'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { config } from '../src/config.js'; +import { BANNER, VIDEO } from '../src/mediaTypes.js'; +import { Renderer } from '../src/Renderer.js'; +import * as utils from '../src/utils.js'; const OUTSTREAM_RENDERER_URL = 'https://s2.adform.net/banners/scripts/video/outstream/render.js'; @@ -43,7 +43,7 @@ export const spec = { request.push(formRequestUrl(reqParams)); } - request.unshift('//' + globalParams[0][1] + '/adx/?rp=4'); + request.unshift('https://' + globalParams[0][1] + '/adx/?rp=4'); netRevenue = netRevenue || 'gross'; request.push('pt=' + netRevenue); request.push('stid=' + validBidRequests[0].auctionId); diff --git a/modules/adformOpenRTBBidAdapter.js b/modules/adformOpenRTBBidAdapter.js index 98e6de8036a..9e3325fad0a 100644 --- a/modules/adformOpenRTBBidAdapter.js +++ b/modules/adformOpenRTBBidAdapter.js @@ -3,12 +3,12 @@ import { registerBidder -} from '../src/adapters/bidderFactory'; +} from '../src/adapters/bidderFactory.js'; import { NATIVE -} from '../src/mediaTypes'; -import * as utils from '../src/utils'; -import { config } from '../src/config'; +} from '../src/mediaTypes.js'; +import * as utils from '../src/utils.js'; +import { config } from '../src/config.js'; const BIDDER_CODE = 'adformOpenRTB'; const NATIVE_ASSET_IDS = { 0: 'title', 2: 'icon', 3: 'image', 5: 'sponsoredBy', 4: 'body', 1: 'cta' }; @@ -129,7 +129,7 @@ export const spec = { return { method: 'POST', - url: '//' + adxDomain + '/adx/openrtb', + url: 'https://' + adxDomain + '/adx/openrtb', data: JSON.stringify(request), options: { contentType: 'application/json' diff --git a/modules/adgenerationBidAdapter.js b/modules/adgenerationBidAdapter.js index 77b6acbf0e0..d30650929f0 100644 --- a/modules/adgenerationBidAdapter.js +++ b/modules/adgenerationBidAdapter.js @@ -1,12 +1,12 @@ -import * as utils from '../src/utils'; -import {registerBidder} from '../src/adapters/bidderFactory'; -import {BANNER, NATIVE} from '../src/mediaTypes'; -import {config} from '../src/config'; +import * as utils from '../src/utils.js'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; +import {BANNER, NATIVE} from '../src/mediaTypes.js'; +import {config} from '../src/config.js'; const ADG_BIDDER_CODE = 'adgeneration'; export const spec = { code: ADG_BIDDER_CODE, - aliases: ['adg'], // short code + aliases: ['adg','adg2'], // short code supportedMediaTypes: [BANNER, NATIVE], /** * Determines whether or not the given bid request is valid. @@ -28,7 +28,7 @@ export const spec = { let serverRequests = []; for (let i = 0, len = validBidRequests.length; i < len; i++) { const validReq = validBidRequests[i]; - const DEBUG_URL = 'http://api-test.scaleout.jp/adsv/v1'; + const DEBUG_URL = 'https://api-test.scaleout.jp/adsv/v1'; const URL = 'https://d.socdm.com/adsv/v1'; const url = validReq.params.debug ? DEBUG_URL : URL; let data = ``; diff --git a/modules/adgenerationBidAdapter.md b/modules/adgenerationBidAdapter.md index 7dfc301e657..7f66732ff38 100644 --- a/modules/adgenerationBidAdapter.md +++ b/modules/adgenerationBidAdapter.md @@ -15,57 +15,61 @@ AdGeneration bid adapter supports Banner and Native. # Test Parameters ``` var adUnits = [ - // Banner adUnit - { - code: 'banner-div', // banner - sizes: [[300, 250]], - bids: [ - { - bidder: 'adg', - params: { - id: '58278', // banner - } - }, - ] - }, - // Native adUnit - { - code: 'native-div', - sizes: [[1,1]], - mediaTypes: { - native: { - image: { + // Banner adUnit + { + code: 'banner-div', // banner + mediaTypes: { + banner: { + sizes: [[300, 250]], + } + }, + bids: [ + { + bidder: 'adg', + params: { + id: '58278', // banner + } + }, + ] + }, + // Native adUnit + { + code: 'native-div', + sizes: [[1,1]], + mediaTypes: { + native: { + image: { required: true - }, - title: { + }, + title: { required: true, len: 80 - }, - sponsoredBy: { + }, + sponsoredBy: { required: true - }, - clickUrl: { + }, + clickUrl: { required: true - }, - body: { + }, + body: { required: true - }, - icon: { + }, + icon: { required: true - }, - privacyLink: { + }, + privacyLink: { required: true - }, }, - }, - bids: [ - { - bidder: 'adg', - params: { + }, + }, + bids: [ + { + bidder: 'adg', + params: { id: '58279', //native - } - }, - ] + } + }, + ] }, ]; ``` diff --git a/modules/adglareBidAdapter.js b/modules/adglareBidAdapter.js new file mode 100644 index 00000000000..d66a38482ec --- /dev/null +++ b/modules/adglareBidAdapter.js @@ -0,0 +1,90 @@ +'use strict'; + +import {registerBidder} from '../src/adapters/bidderFactory.js'; + +const BIDDER_CODE = 'adglare'; + +export const spec = { + code: BIDDER_CODE, + isBidRequestValid: function (bid) { + let p = bid.params; + if (typeof p.domain === 'string' && !!p.domain.length && p.zID && !isNaN(p.zID) && p.type == 'banner') return true; + return false; + }, + buildRequests: function (validBidRequests, bidderRequest) { + let i; + let j; + let bidRequest; + let zID; + let domain; + let keywords; + let url; + let type; + let availscreen = window.innerWidth + 'x' + window.innerHeight; + let pixelRatio = window.devicePixelRatio || 1; + let screen = (pixelRatio * window.screen.width) + 'x' + (pixelRatio * window.screen.height); + let sizes = []; + let serverRequests = []; + let timeout = bidderRequest.timeout || 0; + let referer = bidderRequest.refererInfo.referer || ''; + let reachedtop = bidderRequest.refererInfo.reachedTop || ''; + for (i = 0; i < validBidRequests.length; i++) { + bidRequest = validBidRequests[i]; + zID = bidRequest.params.zID; + domain = bidRequest.params.domain; + keywords = bidRequest.params.keywords || ''; + type = bidRequest.params.type; + + // Build ad unit sizes + if (bidRequest.mediaTypes && bidRequest.mediaTypes[type]) { + for (j in bidRequest.mediaTypes[type].sizes) { + sizes.push(bidRequest.mediaTypes[type].sizes[j].join('x')); + } + } + + // Build URL + url = 'https://' + domain + '/?' + encodeURIComponent(zID) + '&pbjs&pbjs_version=1'; + url += '&pbjs_type=' + encodeURIComponent(type); + url += '&pbjs_timeout=' + encodeURIComponent(timeout); + url += '&pbjs_reachedtop=' + encodeURIComponent(reachedtop); + url += '&sizes=' + encodeURIComponent(sizes.join(',')); + url += '&screen=' + encodeURIComponent(screen); + url += '&availscreen=' + encodeURIComponent(availscreen); + url += '&referer=' + encodeURIComponent(referer); + if (keywords !== '') { + url += '&keywords=' + encodeURIComponent(keywords); + } + + // Push server request + serverRequests.push({ + method: 'GET', + url: url, + data: {}, + bidRequest: bidRequest + }); + } + return serverRequests; + }, + interpretResponse: function (serverResponse, request) { + const bidObj = request.bidRequest; + let bidResponses = []; + let bidResponse = {}; + serverResponse = serverResponse.body; + + if (serverResponse && serverResponse.status == 'OK' && bidObj) { + bidResponse.requestId = bidObj.bidId; + bidResponse.bidderCode = bidObj.bidder; + bidResponse.cpm = serverResponse.cpm; + bidResponse.width = serverResponse.width; + bidResponse.height = serverResponse.height; + bidResponse.ad = serverResponse.adhtml; + bidResponse.ttl = serverResponse.ttl; + bidResponse.creativeId = serverResponse.crID; + bidResponse.netRevenue = true; + bidResponse.currency = serverResponse.currency; + bidResponses.push(bidResponse); + } + return bidResponses; + }, +}; +registerBidder(spec); diff --git a/modules/adglareBidAdapter.md b/modules/adglareBidAdapter.md new file mode 100644 index 00000000000..845564473c7 --- /dev/null +++ b/modules/adglareBidAdapter.md @@ -0,0 +1,36 @@ +# Overview + +``` +Module Name: AdGlare Ad Server Adapter +Module Type: Bidder Adapter +Maintainer: prebid@adglare.com +``` + +# Description + +Adapter that connects to your AdGlare Ad Server. +Including support for your white label ad serving domain. + +# Test Parameters +``` + var adUnits = [ + { + code: 'your-div-id', + mediaTypes: { + banner: { + sizes: [[300,250], [728,90]], + } + }, + bids: [ + { + bidder: 'adglare', + params: { + domain: 'try.engine.adglare.net', + zID: '475579334', + type: 'banner' + } + } + ] + } + ]; +``` diff --git a/modules/adheseBidAdapter.js b/modules/adheseBidAdapter.js index 445c9956410..96a2b52fb9c 100644 --- a/modules/adheseBidAdapter.js +++ b/modules/adheseBidAdapter.js @@ -1,7 +1,7 @@ 'use strict'; -import { registerBidder } from '../src/adapters/bidderFactory'; -import { BANNER, VIDEO } from '../src/mediaTypes'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { BANNER, VIDEO } from '../src/mediaTypes.js'; const BIDDER_CODE = 'adhese'; const USER_SYNC_BASE_URL = 'https://user-sync.adhese.com/iframe/user_sync.html'; @@ -170,11 +170,15 @@ function getAdDetails(ad) { if (isAdheseAd(ad)) { creativeId = ad.id; dealId = ad.orderId; - originData = { priority: ad.priority, orderProperty: ad.orderProperty, adFormat: ad.adFormat, adType: ad.adType, libId: ad.libId, adspaceId: ad.adspaceId, viewableImpressionCounter: ad.viewableImpressionCounter }; + originData = { priority: ad.priority, orderProperty: ad.orderProperty, adFormat: ad.adFormat, adType: ad.adType, libId: ad.libId, adspaceId: ad.adspaceId, viewableImpressionCounter: ad.viewableImpressionCounter, slotId: ad.slotID, slotName: ad.slotName, advertiserId: ad.advertiserId, adId: ad.id }; } else { creativeId = ad.origin + (ad.originInstance ? '-' + ad.originInstance : ''); if (ad.originData) { originData = ad.originData; + originData.slotId = ad.slotID; + originData.slotName = ad.slotName; + originData.adType = ad.adType; + if (ad.adFormat) originData.adFormat = ad.adFormat; if (ad.originData.seatbid && ad.originData.seatbid.length) { const seatbid = ad.originData.seatbid[0]; if (seatbid.bid && seatbid.bid.length) { diff --git a/modules/adkernelAdnAnalyticsAdapter.js b/modules/adkernelAdnAnalyticsAdapter.js index b72fc268ea3..b6db6fc22de 100644 --- a/modules/adkernelAdnAnalyticsAdapter.js +++ b/modules/adkernelAdnAnalyticsAdapter.js @@ -1,13 +1,14 @@ -import adapter from '../src/AnalyticsAdapter'; +import adapter from '../src/AnalyticsAdapter.js'; import CONSTANTS from '../src/constants.json'; -import adapterManager from '../src/adapterManager'; -import {parse} from '../src/url'; -import * as utils from '../src/utils'; -import {ajax} from '../src/ajax'; +import adapterManager from '../src/adapterManager.js'; +import * as utils from '../src/utils.js'; +import {ajax} from '../src/ajax.js'; +import { getStorageManager } from '../src/storageManager.js'; -const ANALYTICS_VERSION = '1.0.0'; +const ANALYTICS_VERSION = '1.0.1'; const DEFAULT_QUEUE_TIMEOUT = 4000; const DEFAULT_HOST = 'tag.adkernel.com'; +const storageObj = getStorageManager(); const ADK_HB_EVENTS = { AUCTION_INIT: 'auctionInit', @@ -19,14 +20,12 @@ const ADK_HB_EVENTS = { }; function buildRequestTemplate(pubId) { - const url = utils.getTopWindowUrl(); - const ref = utils.getTopWindowReferrer(); - const topLocation = utils.getTopWindowLocation(); + const {loc, ref} = getNavigationInfo(); return { ver: ANALYTICS_VERSION, - domain: topLocation.hostname, - path: topLocation.pathname, + domain: loc.hostname, + path: loc.pathname, accId: pubId, env: { screen: { @@ -35,13 +34,13 @@ function buildRequestTemplate(pubId) { }, lang: navigator.language }, - src: getUmtSource(url, ref) + src: getUmtSource(loc.href, ref) } } let analyticsAdapter = Object.assign(adapter({analyticsType: 'endpoint'}), { - track({ eventType, args }) { + track({eventType, args}) { if (!analyticsAdapter.context) { return; } @@ -115,7 +114,7 @@ function sendAll() { } analyticsAdapter.ajaxCall = function ajaxCall(data) { - ajax(`//${analyticsAdapter.context.host}/hb-analytics`, () => { + ajax(`https://${analyticsAdapter.context.host}/hb-analytics`, () => { }, data); }; @@ -152,7 +151,7 @@ function trackBidTimeout(args) { } function createHbEvent(adapter, event, tagid = undefined, value = 0, time = 0) { - let ev = { event: event }; + let ev = {event: event}; if (adapter) { ev.adapter = adapter } @@ -177,10 +176,10 @@ const ORGANIC = '(organic)'; export let storage = { getItem: (name) => { - return localStorage.getItem(name); + return storageObj.getDataFromLocalStorage(name); }, setItem: (name, value) => { - localStorage.setItem(name, value); + storageObj.setDataInLocalStorage(name, value); } }; @@ -211,7 +210,7 @@ export function getUmtSource(pageUrl, referrer) { if (se) { return asUtm(se, ORGANIC, ORGANIC); } - let parsedUrl = parse(pageUrl); + let parsedUrl = utils.parseUrl(pageUrl); let [refHost, refPath] = getReferrer(referrer); if (refHost && refHost !== parsedUrl.hostname) { return asUtm(refHost, REFERRAL, REFERRAL, '', refPath); @@ -238,12 +237,12 @@ export function getUmtSource(pageUrl, referrer) { } function getReferrer(referrer) { - let ref = parse(referrer); + let ref = utils.parseUrl(referrer); return [ref.hostname, ref.pathname]; } function getUTM(pageUrl) { - let urlParameters = parse(pageUrl).search; + let urlParameters = utils.parseUrl(pageUrl).search; if (!urlParameters['utm_campaign'] || !urlParameters['utm_source']) { return; } @@ -297,7 +296,7 @@ export function getUmtSource(pageUrl, referrer) { function chooseActualUtm(prev, curr) { if (ord(prev) < ord(curr)) { return [true, curr]; - } if (ord(prev) > ord(curr)) { + } else if (ord(prev) > ord(curr)) { return [false, prev]; } else { if (prev.campaign === REFERRAL && prev.content !== curr.content) { @@ -330,7 +329,7 @@ export function getUmtSource(pageUrl, referrer) { } /** - * Expiring queue implementation. Fires callback on elapsed timeout since last last update or creation. + * Expiring queue implementation. Fires callback on elapsed timeout since last update or creation. * @param callback * @param ttl * @constructor @@ -376,3 +375,18 @@ export function ExpiringQueue(callback, ttl) { }, ttl); } } + +function getNavigationInfo() { + try { + return getLocationAndReferrer(self.top); + } catch (e) { + return getLocationAndReferrer(self); + } +} + +function getLocationAndReferrer(win) { + return { + ref: win.document.referrer, + loc: win.location + }; +} diff --git a/modules/adkernelAdnBidAdapter.js b/modules/adkernelAdnBidAdapter.js index 3131aa2a38c..483d6de52b9 100644 --- a/modules/adkernelAdnBidAdapter.js +++ b/modules/adkernelAdnBidAdapter.js @@ -1,7 +1,6 @@ -import * as utils from '../src/utils'; -import {registerBidder} from '../src/adapters/bidderFactory'; -import {BANNER, VIDEO} from '../src/mediaTypes'; -import {parse as parseUrl} from '../src/url'; +import * as utils from '../src/utils.js'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; +import {BANNER, VIDEO} from '../src/mediaTypes.js'; const DEFAULT_ADKERNEL_DSP_DOMAIN = 'tag.adkernel.com'; const DEFAULT_MIMES = ['video/mp4', 'video/webm', 'application/x-shockwave-flash', 'application/javascript']; @@ -49,28 +48,29 @@ function canonicalizeSizesArray(sizes) { return sizes; } -function buildRequestParams(tags, auctionId, transactionId, gdprConsent, refInfo) { +function buildRequestParams(tags, auctionId, transactionId, gdprConsent, uspConsent, refInfo) { let req = { id: auctionId, tid: transactionId, site: buildSite(refInfo), imp: tags }; - - if (gdprConsent && (gdprConsent.gdprApplies !== undefined || gdprConsent.consentString !== undefined)) { - req.user = {}; + if (gdprConsent) { if (gdprConsent.gdprApplies !== undefined) { - req.user.gdpr = ~~(gdprConsent.gdprApplies); + utils.deepSetValue(req, 'user.gdpr', ~~gdprConsent.gdprApplies); } if (gdprConsent.consentString !== undefined) { - req.user.consent = gdprConsent.consentString; + utils.deepSetValue(req, 'user.consent', gdprConsent.consentString); } } + if (uspConsent) { + utils.deepSetValue(req, 'user.us_privacy', uspConsent); + } return req; } function buildSite(refInfo) { - let loc = parseUrl(refInfo.referer); + let loc = utils.parseUrl(refInfo.referer); let result = { page: `${loc.protocol}://${loc.hostname}${loc.pathname}`, secure: ~~(loc.protocol === 'https') @@ -132,11 +132,11 @@ export const spec = { return acc; }, {}); - let {auctionId, gdprConsent, transactionId, refererInfo} = bidderRequest; + let {auctionId, gdprConsent, uspConsent, transactionId, refererInfo} = bidderRequest; let requests = []; Object.keys(dispatch).forEach(host => { Object.keys(dispatch[host]).forEach(pubId => { - let request = buildRequestParams(dispatch[host][pubId], auctionId, transactionId, gdprConsent, refererInfo); + let request = buildRequestParams(dispatch[host][pubId], auctionId, transactionId, gdprConsent, uspConsent, refererInfo); requests.push({ method: 'POST', url: `https://${host}/tag?account=${pubId}&pb=1${isRtbDebugEnabled(refererInfo) ? '&debug=1' : ''}`, diff --git a/modules/adkernelBidAdapter.js b/modules/adkernelBidAdapter.js index 29c23452814..1a16801ba67 100644 --- a/modules/adkernelBidAdapter.js +++ b/modules/adkernelBidAdapter.js @@ -1,9 +1,8 @@ -import * as utils from '../src/utils'; -import { BANNER, VIDEO } from '../src/mediaTypes'; -import {registerBidder} from '../src/adapters/bidderFactory'; -import find from 'core-js/library/fn/array/find'; -import includes from 'core-js/library/fn/array/includes'; -import {parse as parseUrl} from '../src/url'; +import * as utils from '../src/utils.js'; +import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; +import find from 'core-js/library/fn/array/find.js'; +import includes from 'core-js/library/fn/array/includes.js'; /* * In case you're AdKernel whitelable platform's client who needs branded adapter to @@ -15,7 +14,30 @@ import {parse as parseUrl} from '../src/url'; const VIDEO_TARGETING = ['mimes', 'minduration', 'maxduration', 'protocols', 'startdelay', 'linearity', 'boxingallowed', 'playbackmethod', 'delivery', 'pos', 'api', 'ext']; -const VERSION = '1.3'; +const VERSION = '1.4'; + +const NATIVE_MODEL = [ + {name: 'title', assetType: 'title'}, + {name: 'icon', assetType: 'img', type: 1}, + {name: 'image', assetType: 'img', type: 3}, + {name: 'body', assetType: 'data', type: 2}, + {name: 'body2', assetType: 'data', type: 10}, + {name: 'sponsoredBy', assetType: 'data', type: 1}, + {name: 'phone', assetType: 'data', type: 8}, + {name: 'address', assetType: 'data', type: 9}, + {name: 'price', assetType: 'data', type: 6}, + {name: 'salePrice', assetType: 'data', type: 7}, + {name: 'cta', assetType: 'data', type: 12}, + {name: 'rating', assetType: 'data', type: 3}, + {name: 'downloads', assetType: 'data', type: 5}, + {name: 'likes', assetType: 'data', type: 4}, + {name: 'displayUrl', assetType: 'data', type: 11} +]; + +const NATIVE_INDEX = NATIVE_MODEL.reduce((acc, val, idx) => { + acc[val.name] = {id: idx, ...val}; + return acc; +}, {}); /** * Adapter for requesting bids from AdKernel white-label display platform @@ -24,7 +46,7 @@ export const spec = { code: 'adkernel', aliases: ['headbidding', 'adsolut', 'oftmediahb', 'audiencemedia', 'waardex_ak', 'roqoon'], - supportedMediaTypes: [BANNER, VIDEO], + supportedMediaTypes: [BANNER, VIDEO, NATIVE], isBidRequestValid: function(bidRequest) { return 'params' in bidRequest && typeof bidRequest.params.host !== 'undefined' && @@ -32,15 +54,15 @@ export const spec = { !isNaN(Number(bidRequest.params.zoneId)) && bidRequest.params.zoneId > 0 && bidRequest.mediaTypes && - (bidRequest.mediaTypes.banner || bidRequest.mediaTypes.video); + (bidRequest.mediaTypes.banner || bidRequest.mediaTypes.video || (bidRequest.mediaTypes.native && validateNativeAdUnit(bidRequest.mediaTypes.native))); }, buildRequests: function(bidRequests, bidderRequest) { let impDispatch = dispatchImps(bidRequests, bidderRequest.refererInfo); - const {gdprConsent, auctionId, refererInfo, timeout} = bidderRequest; + const {gdprConsent, auctionId, refererInfo, timeout, uspConsent} = bidderRequest; const requests = []; Object.keys(impDispatch).forEach(host => { Object.keys(impDispatch[host]).forEach(zoneId => { - const request = buildRtbRequest(impDispatch[host][zoneId], auctionId, gdprConsent, refererInfo, timeout); + const request = buildRtbRequest(impDispatch[host][zoneId], auctionId, gdprConsent, uspConsent, refererInfo, timeout); requests.push({ method: 'POST', url: `https://${host}/hb?zone=${zoneId}&v=${VERSION}`, @@ -76,12 +98,14 @@ export const spec = { prBid.width = rtbBid.w; prBid.height = rtbBid.h; prBid.ad = formatAdMarkup(rtbBid); - } - if ('video' in imp) { + } else if ('video' in imp) { prBid.mediaType = VIDEO; prBid.vastUrl = rtbBid.nurl; prBid.width = imp.video.w; prBid.height = imp.video.h; + } else if ('native' in imp) { + prBid.mediaType = NATIVE; + prBid.native = buildNativeAd(JSON.parse(rtbBid.adm)); } return prBid; }); @@ -138,6 +162,12 @@ function buildImp(bidRequest, secure) { .filter(key => includes(VIDEO_TARGETING, key)) .forEach(key => imp.video[key] = bidRequest.params.video[key]); } + } else if (utils.deepAccess(bidRequest, 'mediaTypes.native')) { + let nativeRequest = buildNativeRequest(bidRequest.mediaTypes.native); + imp.native = { + ver: '1.1', + request: JSON.stringify(nativeRequest) + } } if (secure) { imp.secure = 1; @@ -145,16 +175,62 @@ function buildImp(bidRequest, secure) { return imp; } +/** + * Builds native request from native adunit + */ +function buildNativeRequest(nativeReq) { + let request = {ver: '1.1', assets: []}; + for (let k of Object.keys(nativeReq)) { + let v = nativeReq[k]; + let desc = NATIVE_INDEX[k]; + if (desc === undefined) { + continue; + } + let assetRoot = { + id: desc.id, + required: ~~v.required, + }; + if (desc.assetType === 'img') { + assetRoot[desc.assetType] = buildImageAsset(desc, v); + } else if (desc.assetType === 'data') { + assetRoot.data = utils.cleanObj({type: desc.type, len: v.len}); + } else if (desc.assetType === 'title') { + assetRoot.title = {len: v.len || 90}; + } else { + return; + } + request.assets.push(assetRoot); + } + return request; +} + +/** + * Builds image asset request + */ +function buildImageAsset(desc, val) { + let img = { + type: desc.type + }; + if (val.sizes) { + [img.w, img.h] = val.sizes; + } else if (val.aspect_ratios) { + img.wmin = val.aspect_ratios[0].min_width; + img.hmin = val.aspect_ratios[0].min_height; + } + return utils.cleanObj(img); +} + /** * Builds complete rtb request * @param imps collection of impressions * @param auctionId - * @param gdprConsent + * @param gdprConsent {string=} + * @param uspConsent {string=} * @param refInfo * @param timeout * @return Object complete rtb request */ -function buildRtbRequest(imps, auctionId, gdprConsent, refInfo, timeout) { +function buildRtbRequest(imps, auctionId, gdprConsent, uspConsent, refInfo, timeout) { let req = { 'id': auctionId, 'imp': imps, @@ -174,11 +250,16 @@ function buildRtbRequest(imps, auctionId, gdprConsent, refInfo, timeout) { if (utils.getDNT()) { req.device.dnt = 1; } - if (gdprConsent && gdprConsent.gdprApplies !== undefined) { - req.regs = {ext: {gdpr: Number(gdprConsent.gdprApplies)}}; + if (gdprConsent) { + if (gdprConsent.gdprApplies !== undefined) { + utils.deepSetValue(req, 'regs.ext.gdpr', ~~gdprConsent.gdprApplies); + } + if (gdprConsent.consentString !== undefined) { + utils.deepSetValue(req, 'user.ext.consent', gdprConsent.consentString); + } } - if (gdprConsent && gdprConsent.consentString !== undefined) { - req.user = {ext: {consent: gdprConsent.consentString}}; + if (uspConsent) { + utils.deepSetValue(req, 'regs.ext.us_privacy', uspConsent); } return req; } @@ -192,10 +273,10 @@ function getLanguage() { * Creates site description object */ function createSite(refInfo) { - let url = parseUrl(refInfo.referer); + let url = utils.parseUrl(refInfo.referer); let site = { 'domain': url.hostname, - 'page': url.protocol + '://' + url.hostname + url.pathname + 'page': `${url.protocol}://${url.hostname}${url.pathname}` }; if (self === top && document.referrer) { site.ref = document.referrer; @@ -218,3 +299,51 @@ function formatAdMarkup(bid) { } return adm; } + +/** + * Basic validates to comply with platform requirements + */ +function validateNativeAdUnit(adUnit) { + return validateNativeImageSize(adUnit.image) && validateNativeImageSize(adUnit.icon) && + !utils.deepAccess(adUnit, 'privacyLink.required') && // not supported yet + !utils.deepAccess(adUnit, 'privacyIcon.required'); // not supported yet +} + +/** + * Validates image asset size definition + */ +function validateNativeImageSize(img) { + if (!img) { + return true; + } + if (img.sizes) { + return utils.isArrayOfNums(img.sizes, 2); + } + if (utils.isArray(img.aspect_ratios)) { + return img.aspect_ratios.length > 0 && img.aspect_ratios[0].min_height && img.aspect_ratios[0].min_width; + } + return true; +} + +/** + * Creates native ad for native 1.1 response + */ +function buildNativeAd(nativeResp) { + const {assets, link, imptrackers, jstracker, privacy} = nativeResp.native; + let nativeAd = { + clickUrl: link.url, + impressionTrackers: imptrackers, + javascriptTrackers: jstracker ? [jstracker] : undefined, + privacyLink: privacy, + }; + utils._each(assets, asset => { + let assetName = NATIVE_MODEL[asset.id].name; + let assetType = NATIVE_MODEL[asset.id].assetType; + nativeAd[assetName] = asset[assetType].text || asset[assetType].value || utils.cleanObj({ + url: asset[assetType].url, + width: asset[assetType].w, + height: asset[assetType].h + }); + }); + return utils.cleanObj(nativeAd); +} diff --git a/modules/adkernelBidAdapter.md b/modules/adkernelBidAdapter.md index f89fa5a26df..b3854d721ad 100644 --- a/modules/adkernelBidAdapter.md +++ b/modules/adkernelBidAdapter.md @@ -9,43 +9,71 @@ Maintainer: prebid-dev@adkernel.com # Description Connects to AdKernel whitelabel platform. -Banner and video formats are supported. +Banner, video and native formats are supported. # Test Parameters ``` - var adUnits = [{ - code: 'banner-ad-div', - mediaTypes: { - banner: { - sizes: [[300, 250]], // banner size - } - }, - bids: [ - { - bidder: 'adkernel', - params: { - zoneId: '30164', //required parameter - host: 'cpm.metaadserving.com' //required parameter - } - } - ] - }, { - code: 'video-ad-player', - mediaTypes: { - video: { - context: 'instream', // or 'outstream' - playerSize: [640, 480] // video player size - } - }, - bids: [ - { - bidder: 'adkernel', - params: { - zoneId: '30164', //required parameter - host: 'cpm.metaadserving.com' //required parameter - } - } - ] - }]; +var adUnits = [{ + code: 'banner-ad-div', + mediaTypes: { + banner: { + sizes: [[300, 250]], // banner size + } + }, + bids: [{ + bidder: 'adkernel', + params: { + zoneId: '30164', //required parameter + host: 'cpm.metaadserving.com' //required parameter + } + }] +}, { + code: 'video-ad-player', + mediaTypes: { + video: { + context: 'instream', // or 'outstream' + playerSize: [640, 480] // video player size + } + }, + bids: [{ + bidder: 'adkernel', + params: { + zoneId: '30164', //required parameter + host: 'cpm.metaadserving.com' //required parameter + } + }] +}, { + code: 'native-ad', + mediaTypes: { + native: { + title: { + required: true + }, + body: { + required: true + }, + icon: { + required: true, + size: [64, 64] + }, + sponsoredBy: { + required: true + }, + clickUrl: { + required: true + }, + displayUrl: { + required: false + } + } + }, + bids: [{ + bidder: 'adkernel', + params: { + host: 'cpm.metaadserving.com', + zoneId: 30164 + } + }] +}]; ``` diff --git a/modules/adliveBidAdapter.js b/modules/adliveBidAdapter.js index cb3d9579832..4c703628c4d 100644 --- a/modules/adliveBidAdapter.js +++ b/modules/adliveBidAdapter.js @@ -1,6 +1,6 @@ -import * as utils from '../src/utils'; -import { registerBidder } from '../src/adapters/bidderFactory'; -import { BANNER } from '../src/mediaTypes'; +import * as utils from '../src/utils.js'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { BANNER } from '../src/mediaTypes.js'; const BIDDER_CODE = 'adlive'; const ENDPOINT_URL = 'https://api.publishers.adlive.io/get?pbjs=1'; diff --git a/modules/admanBidAdapter.js b/modules/admanBidAdapter.js index 4720d06d094..5dc3412ee66 100644 --- a/modules/admanBidAdapter.js +++ b/modules/admanBidAdapter.js @@ -1,79 +1,107 @@ -import {registerBidder} from '../src/adapters/bidderFactory'; -import * as utils from '../src/utils'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; +import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js'; +import * as utils from '../src/utils.js'; const BIDDER_CODE = 'adman'; +const AD_URL = 'https://pub.admanmedia.com/?c=o&m=multi'; +const URL_SYNC = 'https://pub.admanmedia.com/?c=o&m=sync'; + +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 && bid.native.title && bid.native.image && bid.native.impressionTrackers); + default: + return false; + } +} export const spec = { code: BIDDER_CODE, - supportedMediaTypes: ['video', 'banner'], - isBidRequestValid: function(bid) { - const isValid = _validateId(utils.deepAccess(bid, 'params.id')); - if (!isValid) { - utils.logError('Adman id parameter is required. Bid aborted.'); - } - return isValid; + supportedMediaTypes: [BANNER, VIDEO, NATIVE], + + isBidRequestValid: (bid) => { + return Boolean(bid.bidId && bid.params && !isNaN(bid.params.placementId)); }, - buildRequests: function(validBidRequests, bidderRequest) { - const ENDPOINT_URL = '//bidtor.admanmedia.com/prebid'; - const bids = validBidRequests.map(buildRequestObject); - const payload = { - referer: utils.getTopWindowUrl(), - bids, - deviceWidth: screen.width - }; - if (bidderRequest && bidderRequest.gdprConsent) { - payload.gdpr = { - consent: bidderRequest.gdprConsent.consentString, - applies: bidderRequest.gdprConsent.gdprApplies - }; - } else { - payload.gdpr = { - consent: '' + buildRequests: (validBidRequests = [], bidderRequest) => { + let winTop = window; + let location; + try { + location = new URL(bidderRequest.refererInfo.referer) + winTop = window.top; + } catch (e) { + location = winTop.location; + utils.logMessage(e); + }; + let placements = []; + let request = { + 'deviceWidth': winTop.screen.width, + 'deviceHeight': winTop.screen.height, + 'language': (navigator && navigator.language) ? navigator.language : '', + 'secure': 1, + 'host': location.host, + 'page': location.pathname, + 'placements': placements + }; + request.language.indexOf('-') != -1 && (request.language = request.language.split('-')[0]) + if (bidderRequest) { + if (bidderRequest.uspConsent) { + request.ccpa = bidderRequest.uspConsent; + } + if (bidderRequest.gdprConsent) { + request.gdpr = bidderRequest.gdprConsent } } + const len = validBidRequests.length; + + for (let i = 0; i < len; i++) { + let bid = validBidRequests[i]; + let traff = bid.params.traffic || BANNER - const payloadString = JSON.stringify(payload); + placements.push({ + placementId: bid.params.placementId, + bidId: bid.bidId, + sizes: bid.mediaTypes && bid.mediaTypes[traff] && bid.mediaTypes[traff].sizes ? bid.mediaTypes[traff].sizes : [], + traffic: traff + }); + if (bid.schain) { + placements.schain = bid.schain; + } + } return { method: 'POST', - url: ENDPOINT_URL, - data: payloadString, + url: AD_URL, + data: request }; }, - interpretResponse: function(serverResponse) { + + interpretResponse: (serverResponse) => { + let response = []; serverResponse = serverResponse.body; - if (serverResponse && typeof serverResponse.bids === 'object') { - return serverResponse.bids; + for (let i = 0; i < serverResponse.length; i++) { + let resItem = serverResponse[i]; + if (isBidResponseValid(resItem)) { + response.push(resItem); + } } - return []; + return response; }, - getUserSyncs: function(syncOptions) { - if (syncOptions.iframeEnabled) { - return [{ - type: 'iframe', - url: '//cs.admanmedia.com/sync_tag/html' - }]; - } - } -}; -function buildRequestObject(bid) { - return { - params: { - id: utils.getValue(bid.params, 'id'), - bidId: bid.bidId - }, - sizes: bid.sizes, - bidId: utils.getBidIdParameter('bidId', bid), - bidderRequestId: utils.getBidIdParameter('bidderRequestId', bid), - adUnitCode: utils.getBidIdParameter('adUnitCode', bid), - auctionId: utils.getBidIdParameter('auctionId', bid), - transactionId: utils.getBidIdParameter('transactionId', bid) - }; -} + getUserSyncs: (syncOptions, serverResponses) => { + return [{ + type: 'image', + url: URL_SYNC + }]; + } -function _validateId(id = '') { - return (id.length === 8); -} +}; registerBidder(spec); diff --git a/modules/admanBidAdapter.md b/modules/admanBidAdapter.md index 900c828ea5c..07a268af489 100644 --- a/modules/admanBidAdapter.md +++ b/modules/admanBidAdapter.md @@ -1,35 +1,69 @@ # Overview -**Module Name**: Adman Bidder Adapter -**Module Type**: Bidder Adapter -**Maintainer**: prebid@admanmedia.com +``` +Module Name: adman Bidder Adapter +Module Type: Bidder Adapter +``` # Description -Use `adman` as bidder. +Module that connects to AdmanMedia' demand sources -`id` is required and must be 8 alphanumeric characters. - -## AdUnits configuration example +# Test Parameters ``` - var adUnits = [{ - code: 'test-div', - sizes: [[300, 250]], - bids: [{ - bidder: 'adman', - params: { - id: 1234asdf - } - }] - },{ - code: 'test-div, - sizes: [[600, 338]], - bids: [{ - bidder: 'adman', - params: { - id: asdf1234 - } - }] - }]; + var adUnits = [ + // Will return static native ad. Assets are stored through user UI for each placement separetly + { + code: 'placementId_0', + mediaTypes: { + native: {} + }, + bids: [ + { + bidder: 'adman', + params: { + placementId: 0, + traffic: 'native' + } + } + ] + }, + // Will return static test banner + { + code: 'placementId_0', + mediaTypes: { + banner: { + sizes: [[300, 250]], + } + }, + bids: [ + { + bidder: 'adman', + params: { + placementId: 0, + traffic: 'banner' + } + } + ] + }, + // Will return test vast xml. All video params are stored under placement in publishers UI + { + code: 'placementId_0', + mediaTypes: { + video: { + playerSize: [640, 480], + context: 'instream' + } + }, + bids: [ + { + bidder: 'adman', + params: { + placementId: 0, + traffic: 'video' + } + } + ] + } + ]; ``` - diff --git a/modules/admaticBidAdapter.js b/modules/admaticBidAdapter.js index 727b1553d21..d46c01f7f48 100644 --- a/modules/admaticBidAdapter.js +++ b/modules/admaticBidAdapter.js @@ -1,8 +1,8 @@ -import * as utils from '../src/utils'; -import { registerBidder } from '../src/adapters/bidderFactory'; +import * as utils from '../src/utils.js'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; const BIDDER_CODE = 'admatic'; -const ENDPOINT_URL = '//ads4.admatic.com.tr/prebid/v3/bidrequest'; +const ENDPOINT_URL = 'https://ads4.admatic.com.tr/prebid/v3/bidrequest'; export const spec = { code: BIDDER_CODE, @@ -108,7 +108,7 @@ export const spec = { if (syncOptions.iframeEnabled) { syncs.push({ type: 'iframe', - url: '//ads4.admatic.com.tr/prebid/static/usersync/v3/async_usersync.html' + url: 'https://ads4.admatic.com.tr/prebid/static/usersync/v3/async_usersync.html' }); } diff --git a/modules/admediaBidAdapter.js b/modules/admediaBidAdapter.js index 73d6ea08eea..0a9e510843c 100644 --- a/modules/admediaBidAdapter.js +++ b/modules/admediaBidAdapter.js @@ -1,8 +1,8 @@ -import * as utils from '../src/utils'; -import {registerBidder} from '../src/adapters/bidderFactory'; +import * as utils from '../src/utils.js'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; const BIDDER_CODE = 'admedia'; -const ENDPOINT_URL = '//prebid.admedia.com/bidder/'; +const ENDPOINT_URL = 'https://prebid.admedia.com/bidder/'; export const spec = { code: BIDDER_CODE, diff --git a/modules/admixerBidAdapter.js b/modules/admixerBidAdapter.js index c6d6dd34a11..e8a27a033b4 100644 --- a/modules/admixerBidAdapter.js +++ b/modules/admixerBidAdapter.js @@ -1,34 +1,28 @@ -import * as utils from '../src/utils'; -import {registerBidder} from '../src/adapters/bidderFactory'; +import * as utils from '../src/utils.js'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; const BIDDER_CODE = 'admixer'; const ALIASES = ['go2net']; -const ENDPOINT_URL = '//inv-nets.admixer.net/prebid.1.0.aspx'; +const ENDPOINT_URL = 'https://inv-nets.admixer.net/prebid.1.0.aspx'; export const spec = { code: BIDDER_CODE, aliases: ALIASES, supportedMediaTypes: ['banner', 'video'], /** * 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.zone; }, /** * Make a server request from the list of BidRequests. - * - * @param {bidderRequest} - bidderRequest.bids[] is an array of AdUnits and bids - * @return ServerRequest Info describing the request to the server. */ - buildRequests: function (bidderRequest) { + buildRequests: function (validRequest, bidderRequest) { const payload = { imps: [], - referrer: encodeURIComponent(utils.getTopWindowUrl()), + referrer: encodeURIComponent(bidderRequest.refererInfo.referer), }; - bidderRequest.forEach((bid) => { + validRequest.forEach((bid) => { payload.imps.push(bid); }); const payloadString = JSON.stringify(payload); @@ -40,9 +34,6 @@ export const spec = { }, /** * 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, bidRequest) { const bidResponses = []; diff --git a/modules/adnuntiusBidAdapter.js b/modules/adnuntiusBidAdapter.js new file mode 100644 index 00000000000..16594b3453c --- /dev/null +++ b/modules/adnuntiusBidAdapter.js @@ -0,0 +1,68 @@ + +import { registerBidder } from '../src/adapters/bidderFactory.js'; +const BIDDER_CODE = 'adnuntius'; +const ENDPOINT_URL = 'https://delivery.adnuntius.com/i?tzo=-60&format=json'; + +export const spec = { + code: BIDDER_CODE, + + isBidRequestValid: function (bid) { + return !!(bid.params.auId || (bid.params.member && bid.params.invCode)); + }, + + buildRequests: function (validBidRequests) { + const networks = {}; + const bidRequests = {}; + const requests = []; + + for (var i = 0; i < validBidRequests.length; i++) { + const bid = validBidRequests[i] + const network = bid.params.network || 'network'; + bidRequests[network] = bidRequests[network] || []; + bidRequests[network].push(bid); + + networks[network] = networks[network] || {}; + networks[network].adUnits = networks[network].adUnits || []; + networks[network].adUnits.push({ ...bid.params.targeting, auId: bid.params.auId }); + } + + const networkKeys = Object.keys(networks) + for (var j = 0; j < networkKeys.length; j++) { + const network = networkKeys[j]; + requests.push({ + method: 'POST', + url: ENDPOINT_URL, + data: JSON.stringify(networks[network]), + bid: bidRequests[network] + }); + } + + return requests; + }, + + interpretResponse: function (serverResponse, bidRequest) { + const bidResponses = []; + const serverBody = serverResponse.body; + + for (var k = 0; k < serverBody.adUnits.length; k++) { + const adUnit = serverBody.adUnits[k] + if (adUnit.matchedAdCount > 0) { + const bid = adUnit.ads[0]; + bidResponses.push({ + requestId: bidRequest.bid[k].bidId, + cpm: (bid.cpm) ? bid.cpm.amount : 0, + width: Number(bid.creativeWidth), + height: Number(bid.creativeHeight), + creativeId: bid.creativeId, + currency: (bid.cpm) ? bid.cpm.currency : 'EUR', + netRevenue: false, + ttl: 360, + ad: adUnit.html + }); + } + } + return bidResponses; + }, + +} +registerBidder(spec); diff --git a/modules/adnuntiusBidAdapter.md b/modules/adnuntiusBidAdapter.md new file mode 100644 index 00000000000..aed12079856 --- /dev/null +++ b/modules/adnuntiusBidAdapter.md @@ -0,0 +1,36 @@ +# Overview + +``` +Module Name: Adnuntius Bidder Adapter +Module Type: Bidder Adapter +Maintainer: info@adnuntius.com +``` + +# Description + +Adnuntius Bidder Adapter for Prebid.js. +Only Banner format is supported. + +# Test Parameters +``` + var adUnits = [ + { + code: "test-div", + mediaTypes: { + banner: { + sizes: [[980, 360], [980, 300], [980, 240], [980, 120]] + } + }, + bids: [ + { + bidder: "adnuntius", + params: { + auId: "8b6bc", + network: "adnuntius", + } + }, + ] + }, + + ]; +``` diff --git a/modules/adoceanBidAdapter.js b/modules/adoceanBidAdapter.js index aa89bf3a23d..2b14876fe6f 100644 --- a/modules/adoceanBidAdapter.js +++ b/modules/adoceanBidAdapter.js @@ -1,5 +1,5 @@ -import * as utils from '../src/utils'; -import { registerBidder } from '../src/adapters/bidderFactory'; +import * as utils from '../src/utils.js'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; const BIDDER_CODE = 'adocean'; @@ -12,7 +12,8 @@ function buildEndpointUrl(emiter, payload) { payloadString += k + '=' + encodeURIComponent(v); }); - return 'https://' + emiter + '/ad.json?' + payloadString; + const randomizedPart = Math.random().toString().slice(2); + return 'https://' + emiter + '/_' + randomizedPart + '/ad.json?' + payloadString; } function buildRequest(masterBidRequests, masterId, gdprConsent) { @@ -57,7 +58,8 @@ function assignToMaster(bidRequest, bidRequestsByMaster) { } function interpretResponse(placementResponse, bidRequest, bids) { - if (!placementResponse.error) { + const requestId = bidRequest.bidIdMap[placementResponse.id]; + if (!placementResponse.error && requestId) { let adCode = ' - +```javascript +{ + bidder: 'between', + params: { + s: BETWEEN_SECTION_ID, + cur: 'USD' + } +} +``` + +### GDPR +Also, we support GDPR. To find out how to use GDPR in Prebid you can visit [this page](http://prebid.org/dev-docs/modules/consentManagement.html) - + + + + }); + -

Prebid.js BetweenBidAdapter Test

- +

Prebid.js BetweenBidAdapter Test

+ - -``` \ No newline at end of file + +``` diff --git a/modules/bidfluenceBidAdapter.js b/modules/bidfluenceBidAdapter.js index 4a9c4433ee0..f8a1f9ac92f 100644 --- a/modules/bidfluenceBidAdapter.js +++ b/modules/bidfluenceBidAdapter.js @@ -1,5 +1,8 @@ -import * as utils from '../src/utils'; -import { registerBidder } from '../src/adapters/bidderFactory'; +import * as utils from '../src/utils.js'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { getStorageManager } from '../src/storageManager.js'; + +const storage = getStorageManager(); const BIDDER_CODE = 'bidfluence'; function stdTimezoneOffset(t) { @@ -46,7 +49,7 @@ export const spec = { var payload = { v: '2.0', azr: true, - ck: utils.cookiesAreEnabled(), + ck: storage.cookiesAreEnabled(), re: refInfo ? refInfo.referer : '', st: refInfo ? refInfo.stack : [], tz: getBdfTz(new Date()), @@ -81,7 +84,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 f5991f7f3a5..6db35f184ca 100644 --- a/modules/bidglassBidAdapter.js +++ b/modules/bidglassBidAdapter.js @@ -1,134 +1,134 @@ -import * as utils from '../src/utils'; -// import {config} from 'src/config'; -import {registerBidder} from '../src/adapters/bidderFactory'; - -const BIDDER_CODE = 'bidglass'; - -export const spec = { - code: BIDDER_CODE, - aliases: ['bg'], // short 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.adUnitId && !isNaN(parseFloat(bid.params.adUnitId)) && isFinite(bid.params.adUnitId)); - }, - /** - * Make a server request from the list of BidRequests. - * - * @param {validBidRequests[]} - an array of bids - * @return ServerRequest Info describing the request to the server. - */ +import * as utils from '../src/utils.js'; +// import {config} from 'src/config.js'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; + +const BIDDER_CODE = 'bidglass'; + +export const spec = { + code: BIDDER_CODE, + aliases: ['bg'], // short 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.adUnitId && !isNaN(parseFloat(bid.params.adUnitId)) && isFinite(bid.params.adUnitId)); + }, + /** + * 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: function(validBidRequests, bidderRequest) { - /* - Sample array entry for validBidRequests[]: - [{ - "bidder": "bidglass", - "bidId": "51ef8751f9aead", - "params": { - "adUnitId": 11, - ... - }, - "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 - }] - */ - - let imps = []; + /* + Sample array entry for validBidRequests[]: + [{ + "bidder": "bidglass", + "bidId": "51ef8751f9aead", + "params": { + "adUnitId": 11, + ... + }, + "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 + }] + */ + + let imps = []; 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]; - + 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]); - + // Derive the parent origin + var parts = document.referrer.split('/'); + + ori.push('https://' + parts[2]); + if (window.parent !== window.top) { - // Additional unknown origins exist + // Additional unknown origins exist ori.push('null'); } - } - + } + return ori; - }; - + }; + 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)); - - // Stuff to send: [bid id, sizes, adUnitId] - imps.push({ - bidId: bid.bidId, - sizes: bid.sizes, - adUnitId: utils.getBidIdParameter('adUnitId', bid.params) + bid.sizes = ((utils.isArray(bid.sizes) && utils.isArray(bid.sizes[0])) ? bid.sizes : [bid.sizes]); + bid.sizes = bid.sizes.filter(size => utils.isArray(size)); + + // Stuff to send: [bid id, sizes, adUnitId] + imps.push({ + bidId: bid.bidId, + sizes: bid.sizes, + adUnitId: utils.getBidIdParameter('adUnitId', bid.params) }); - }); - - // Stuff to send: page URL - const bidReq = { - reqId: utils.getUniqueIdentifierStr(), - imps: imps, - ref: getReferer(), - ori: getOrigins() - }; - - let url = 'https://bid.glass/ad/hb.php?' + - `src=$$REPO_AND_VERSION$$`; - - return { - method: 'POST', - url: url, - data: JSON.stringify(bidReq), - options: { - contentType: 'text/plain', - withCredentials: false - } + }); + + // Stuff to send: page URL + const bidReq = { + reqId: utils.getUniqueIdentifierStr(), + imps: imps, + ref: getReferer(), + ori: getOrigins() + }; + + let url = 'https://bid.glass/ad/hb.php?' + + `src=$$REPO_AND_VERSION$$`; + + return { + method: 'POST', + url: url, + data: JSON.stringify(bidReq), + options: { + contentType: 'text/plain', + withCredentials: false + } } - }, - - /** - * 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. - */ + }, + + /** + * 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 bidResponses = []; - + const bidResponses = []; + utils._each(serverResponse.body.bidResponses, function(bid) { - bidResponses.push({ - requestId: bid.requestId, - cpm: parseFloat(bid.cpm), - width: parseInt(bid.width, 10), - height: parseInt(bid.height, 10), - creativeId: bid.creativeId, - dealId: bid.dealId || null, - currency: bid.currency || 'USD', - mediaType: bid.mediaType || 'banner', - netRevenue: true, - ttl: bid.ttl || 10, - ad: bid.ad + bidResponses.push({ + requestId: bid.requestId, + cpm: parseFloat(bid.cpm), + width: parseInt(bid.width, 10), + height: parseInt(bid.height, 10), + creativeId: bid.creativeId, + dealId: bid.dealId || null, + currency: bid.currency || 'USD', + mediaType: bid.mediaType || 'banner', + netRevenue: true, + ttl: bid.ttl || 10, + ad: bid.ad }); - }); - + }); + return bidResponses; - } - -} - -registerBidder(spec); + } + +} + +registerBidder(spec); diff --git a/modules/bidlabBidAdapter.js b/modules/bidlabBidAdapter.js new file mode 100644 index 00000000000..8f501505a6d --- /dev/null +++ b/modules/bidlabBidAdapter.js @@ -0,0 +1,112 @@ +import {registerBidder} from '../src/adapters/bidderFactory.js'; +import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js'; +import * as utils from '../src/utils.js'; + +const BIDDER_CODE = 'bidlab'; +const AD_URL = 'https://service.bidlab.ai/?c=o&m=multi'; +const URL_SYNC = 'https://service.bidlab.ai/?c=o&m=sync'; +const NO_SYNC = true; + +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 && bid.native.title && bid.native.image && bid.native.impressionTrackers); + default: + return false; + } +} + +export const spec = { + code: BIDDER_CODE, + supportedMediaTypes: [BANNER, VIDEO, NATIVE], + noSync: NO_SYNC, + + isBidRequestValid: (bid) => { + return Boolean(bid.bidId && bid.params && !isNaN(parseInt(bid.params.placementId))); + }, + + buildRequests: (validBidRequests = [], bidderRequest) => { + let winTop = window; + let location; + try { + location = new URL(bidderRequest.refererInfo.referer) + winTop = window.top; + } catch (e) { + location = winTop.location; + utils.logMessage(e); + }; + let placements = []; + let request = { + 'deviceWidth': winTop.screen.width, + 'deviceHeight': winTop.screen.height, + 'language': (navigator && navigator.language) ? navigator.language.split('-')[0] : '', + 'secure': 1, + 'host': location.host, + 'page': location.pathname, + 'placements': placements + }; + request.language.indexOf('-') != -1 && (request.language = request.language.split('-')[0]) + if (bidderRequest) { + if (bidderRequest.uspConsent) { + request.ccpa = bidderRequest.uspConsent; + } + if (bidderRequest.gdprConsent) { + request.gdpr = bidderRequest.gdprConsent + } + } + const len = validBidRequests.length; + + for (let i = 0; i < len; i++) { + let bid = validBidRequests[i]; + let traff = bid.params.traffic || BANNER + + placements.push({ + placementId: bid.params.placementId, + bidId: bid.bidId, + sizes: bid.mediaTypes && bid.mediaTypes[traff] && bid.mediaTypes[traff].sizes ? bid.mediaTypes[traff].sizes : [], + traffic: traff + }); + if (bid.schain) { + placements.schain = bid.schain; + } + } + return { + method: 'POST', + url: AD_URL, + data: request + }; + }, + + interpretResponse: (serverResponse) => { + let response = []; + for (let i = 0; i < serverResponse.body.length; i++) { + let resItem = serverResponse.body[i]; + if (isBidResponseValid(resItem)) { + response.push(resItem); + } + } + return response; + }, + + getUserSyncs: (syncOptions, serverResponses) => { + if (NO_SYNC) { + return false + } else { + return [{ + type: 'image', + url: URL_SYNC + }]; + } + } + +}; + +registerBidder(spec); diff --git a/modules/bidlabBidAdapter.md b/modules/bidlabBidAdapter.md new file mode 100644 index 00000000000..3e5fe3128ed --- /dev/null +++ b/modules/bidlabBidAdapter.md @@ -0,0 +1,53 @@ +# Overview + +``` +Module Name: bidlab Bidder Adapter +Module Type: bidlab Bidder Adapter +``` + +# Description + +Module that connects to bidlab demand sources + +# Test Parameters +``` + var adUnits = [ + // Will return static test banner + { + code: 'placementId_0', + mediaTypes: { + banner: { + sizes: [[300, 250]], + } + }, + bids: [ + { + bidder: 'bidlab', + params: { + placementId: 0, + traffic: 'banner' + } + } + ] + }, + // Will return test vast xml. All video params are stored under placement in publishers UI + { + code: 'placementId_0', + mediaTypes: { + video: { + playerSize: [640, 480], + context: 'instream' + } + }, + bids: [ + { + bidder: 'bidlab', + params: { + placementId: 0, + traffic: 'video' + } + } + ] + } + ]; +``` diff --git a/modules/bidphysicsBidAdapter.js b/modules/bidphysicsBidAdapter.js index cbd76c8bc10..b6b5690ede5 100644 --- a/modules/bidphysicsBidAdapter.js +++ b/modules/bidphysicsBidAdapter.js @@ -1,8 +1,8 @@ -import {registerBidder} from '../src/adapters/bidderFactory'; -import * as utils from '../src/utils'; -import {BANNER} from '../src/mediaTypes'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; +import * as utils from '../src/utils.js'; +import {BANNER} from '../src/mediaTypes.js'; -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 a9b202b4c97..00000000000 --- 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 a5d076d8fd0..00000000000 --- 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 index cac827e5a5d..a95a19f0402 100644 --- a/modules/bridgewellBidAdapter.js +++ b/modules/bridgewellBidAdapter.js @@ -1,10 +1,10 @@ -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'; +import * as utils from '../src/utils.js'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { BANNER, NATIVE } from '../src/mediaTypes.js'; +import find from 'core-js/library/fn/array/find.js'; const BIDDER_CODE = 'bridgewell'; -const REQUEST_ENDPOINT = '//rec.scupio.com/recweb/prebid.aspx?cb=' + Math.random(); +const REQUEST_ENDPOINT = 'https://prebid.scupio.com/recweb/prebid.aspx?cb=' + Math.random(); const BIDDER_VERSION = '0.0.2'; export const spec = { @@ -17,23 +17,11 @@ export const spec = { * @param {BidRequest} bid The bid params to validate. * @return boolean True if this is a valid bid, and false otherwise. */ - isBidRequestValid: function(bid) { + 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; - } - } + + if (bid && bid.params && bid.params.ChannelID) { + valid = true; } return valid; @@ -45,11 +33,12 @@ export const spec = { * @param {BidRequest[]} validBidRequests - an array of bids * @return ServerRequest Info describing the request to the server. */ - buildRequests: function(validBidRequests) { + buildRequests: function (validBidRequests, bidderRequest) { const adUnits = []; - utils._each(validBidRequests, function(bid) { + utils._each(validBidRequests, function (bid) { adUnits.push({ ChannelID: bid.params.ChannelID, + adUnitCode: bid.adUnitCode, mediaTypes: bid.mediaTypes || { banner: { sizes: bid.sizes @@ -58,6 +47,11 @@ export const spec = { }); }); + let topUrl = ''; + if (bidderRequest && bidderRequest.refererInfo) { + topUrl = bidderRequest.refererInfo.referer; + } + return { method: 'POST', url: REQUEST_ENDPOINT, @@ -67,8 +61,8 @@ export const spec = { bridgewell: BIDDER_VERSION }, inIframe: utils.inIframe(), - url: utils.getTopWindowUrl(), - referrer: utils.getTopWindowReferrer(), + url: topUrl, + referrer: getTopWindowReferrer(), adUnits: adUnits }, validBidRequests: validBidRequests @@ -82,40 +76,41 @@ export const spec = { * @param {*} bidRequest * @return {Bid[]} An array of bids which were nested inside the server. */ - interpretResponse: function(serverResponse, bidRequest) { + interpretResponse: function (serverResponse, bidRequest) { const bidResponses = []; // map responses to requests - utils._each(bidRequest.validBidRequests, function(req) { + utils._each(bidRequest.validBidRequests, function (req) { const bidResponse = {}; if (!serverResponse.body) { return; } - let matchedResponse = find(serverResponse.body, function(res) { + 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; + if (res && !res.consumed) { + let mediaTypes = req.mediaTypes; + let adUnitCode = req.adUnitCode; + if (res.adUnitCode) { + return res.adUnitCode === adUnitCode; + } else if (res.width && res.height && mediaTypes) { + if (mediaTypes.native) { // dont care native sizes + valid = true; + } else if (mediaTypes.banner) { + if (mediaTypes.banner.sizes) { + let width = res.width; + let height = res.height; + let sizes = mediaTypes.banner.sizes; + // check response size validation + if (typeof sizes[0] === 'number') { // for foramt Array[Number] check + valid = width === sizes[0] && height === sizes[1]; + } else { // for format Array[Array[Number]] check + valid = !!find(sizes, function (size) { + return (width === size[0] && height === size[1]); + }); + } } } } @@ -139,7 +134,7 @@ export const spec = { } bidResponse.requestId = req.bidId; - bidResponse.cpm = matchedResponse.cpm * req.params.cpmWeight; + bidResponse.cpm = matchedResponse.cpm; bidResponse.width = matchedResponse.width; bidResponse.height = matchedResponse.height; bidResponse.ttl = matchedResponse.ttl; @@ -266,4 +261,12 @@ export const spec = { } }; +function getTopWindowReferrer() { + try { + return window.top.document.referrer; + } catch (e) { + return ''; + } +} + registerBidder(spec); diff --git a/modules/bridgewellBidAdapter.md b/modules/bridgewellBidAdapter.md index 014be62ccef..6bcab4b8820 100644 --- a/modules/bridgewellBidAdapter.md +++ b/modules/bridgewellBidAdapter.md @@ -1,8 +1,8 @@ # Overview -Module Name: Bridgewell Bidder Adapter -Module Type: Bidder Adapter -Maintainer: kuchunchou@bridgewell.com +Module Name: Bridgewell Bidder Adapter +Module Type: Bidder Adapter +Maintainer: scupio@bridgewell.com # Description @@ -12,34 +12,15 @@ Module that connects to Bridgewell demand source to fetch bids. ``` var adUnits = [{ code: 'test-div', - sizes: [ - [300, 250] - ], - bids: [{ - bidder: 'bridgewell', - params: { - ChannelID: 'CgUxMjMzOBIBNiIFcGVubnkqCQisAhD6ARoBOQ' - } - }] - }, { - code: 'test-div', - sizes: [ - [728, 90] - ], - bids: [{ - bidder: 'bridgewell', - params: { - ChannelID: 'CgUxMjMzOBIBNiIGcGVubnkzKggI2AUQWhoBOQ', - cpmWeight: 1.5 + mediaTypes: { + banner: { + sizes: [300, 250] } - }] - }, { - code: 'test-div', - sizes: [728, 90], + }, bids: [{ bidder: 'bridgewell', params: { - ChannelID: 'CgUxMjMzOBIBNiIGcGVubnkzKggI2AUQWhoBOQ' + ChannelID: 'CgUxMjMzOBIBNiIFcGVubnkqCQisAhD6ARoBOQ' } }] }, { diff --git a/modules/brightcomBidAdapter.js b/modules/brightcomBidAdapter.js index 862933d076b..a4b013a2fe2 100644 --- a/modules/brightcomBidAdapter.js +++ b/modules/brightcomBidAdapter.js @@ -1,8 +1,7 @@ -import * as utils from '../src/utils'; -import * as url from '../src/url'; -import { registerBidder } from '../src/adapters/bidderFactory'; -import { BANNER } from '../src/mediaTypes'; -import { config } from '../src/config'; +import * as utils from '../src/utils.js'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { BANNER } from '../src/mediaTypes.js'; +import { config } from '../src/config.js'; const BIDDER_CODE = 'brightcom'; const URL = 'https://brightcombid.marphezis.com/hb'; @@ -57,7 +56,7 @@ function buildRequests(bidReqs, bidderRequest) { id: utils.getUniqueIdentifierStr(), imp: brightcomImps, site: { - domain: url.parse(referrer).host, + domain: utils.parseUrl(referrer).host, page: referrer, publisher: { id: publisherId diff --git a/modules/britepoolIdSystem.js b/modules/britepoolIdSystem.js index 2eb24968c08..17a39e96aad 100644 --- a/modules/britepoolIdSystem.js +++ b/modules/britepoolIdSystem.js @@ -5,9 +5,9 @@ * @requires module:modules/userId */ -import * as utils from '../src/utils' -import {ajax} from '../src/ajax'; -import {submodule} from '../src/hook'; +import * as utils from '../src/utils.js' +import {ajax} from '../src/ajax.js'; +import {submodule} from '../src/hook.js'; /** @type {Submodule} */ export const britepoolIdSubmodule = { @@ -89,7 +89,7 @@ export const britepoolIdSubmodule = { if (params.getter) { // Custom getter will not require other params if (typeof params.getter !== 'function') { - errors.push(`${MODULE_NAME} - britepoolId submodule requires getter to be a function`); + errors.push(`userIdTargeting - britepoolId submodule requires getter to be a function`); return { errors }; } } else { diff --git a/modules/browsiRtdProvider.js b/modules/browsiRtdProvider.js index 795c9c86f1e..3765b6603af 100644 --- a/modules/browsiRtdProvider.js +++ b/modules/browsiRtdProvider.js @@ -13,16 +13,23 @@ * @property {string} pubKey * @property {string} url * @property {?string} keyName - * @property {number} auctionDelay + * @property {?number} auctionDelay + * @property {?number} timeout */ import {config} from '../src/config.js'; -import * as utils from '../src/utils'; -import {submodule} from '../src/hook'; -import {ajax} from '../src/ajax'; +import * as utils from '../src/utils.js'; +import {submodule} from '../src/hook.js'; +import {ajaxBuilder} from '../src/ajax.js'; +import {loadExternalScript} from '../src/adloader.js'; +import { getStorageManager } from '../src/storageManager.js'; + +const storage = getStorageManager(); /** @type {string} */ const MODULE_NAME = 'realTimeData'; +/** @type {number} */ +const DEF_TIMEOUT = 1000; /** @type {ModuleParams} */ let _moduleParams = {}; /** @type {null|Object} */ @@ -32,17 +39,20 @@ let _dataReadyCallback = null; /** * add browsi script to page - * @param {string} bptUrl + * @param {Object} data */ -export function addBrowsiTag(bptUrl) { - let script = document.createElement('script'); +export function addBrowsiTag(data) { + let script = loadExternalScript(data.u, 'browsi'); script.async = true; script.setAttribute('data-sitekey', _moduleParams.siteKey); script.setAttribute('data-pubkey', _moduleParams.pubKey); script.setAttribute('prebidbpt', 'true'); script.setAttribute('id', 'browsi-tag'); - script.setAttribute('src', bptUrl); - document.head.appendChild(script); + script.setAttribute('src', data.u); + script.prebidData = utils.deepClone(data); + if (_moduleParams.keyName) { + script.prebidData.kn = _moduleParams.keyName; + } return script; } @@ -55,7 +65,7 @@ function collectData() { const doc = win.document; let browsiData = null; try { - browsiData = utils.getDataFromLocalStorage('__brtd'); + browsiData = storage.getDataFromLocalStorage('__brtd'); } catch (e) { utils.logError('unable to parse __brtd'); } @@ -111,17 +121,20 @@ function sendDataToModule(adUnits, onDone) { return onDone({}); } const slots = getAllSlots(); - if (!slots) { + if (!slots || !slots.length) { return onDone({}); } let dataToReturn = adUnits.reduce((rp, cau) => { const adUnitCode = cau && cau.code; if (!adUnitCode) { return rp } - const predictionData = _predictions[adUnitCode]; + const adSlot = getSlotById(adUnitCode); + if (!adSlot) { return rp } + const macroId = getMacroId(_predictionsData.pmd, adUnitCode, adSlot); + const predictionData = _predictions[macroId]; if (!predictionData) { return rp } if (predictionData.p) { - if (!isIdMatchingAdUnit(adUnitCode, slots, predictionData.w)) { + if (!isIdMatchingAdUnit(adUnitCode, adSlot, predictionData.w)) { return rp; } rp[adUnitCode] = getKVObject(predictionData.p, _predictionsData.kn); @@ -157,24 +170,75 @@ function getKVObject(p, keyName) { /** * check if placement id matches one of given ad units * @param {number} id placement id - * @param {Object[]} allSlots google slots on page + * @param {Object} slot google slot * @param {string[]} whitelist ad units * @return {boolean} */ -export function isIdMatchingAdUnit(id, allSlots, whitelist) { +export function isIdMatchingAdUnit(id, slot, whitelist) { if (!whitelist || !whitelist.length) { return true; } - const slot = allSlots.filter(s => s.getSlotElementId() === id); - const slotAdUnits = slot.map(s => s.getAdUnitPath()); - return slotAdUnits.some(a => whitelist.indexOf(a) !== -1); + const slotAdUnits = slot.getAdUnitPath(); + return whitelist.indexOf(slotAdUnits) !== -1; +} + +/** + * get GPT slot by placement id + * @param {string} id placement id + * @return {?Object} + */ +function getSlotById(id) { + const slots = getAllSlots(); + if (!slots || !slots.length) { + return null; + } + return slots.filter(s => s.getSlotElementId() === id)[0] || null; +} + +/** + * generate id according to macro script + * @param {string} macro replacement macro + * @param {string} id placement id + * @param {Object} slot google slot + * @return {?Object} + */ +function getMacroId(macro, id, slot) { + if (macro) { + try { + const macroResult = evaluate(macro, slot.getSlotElementId(), slot.getAdUnitPath(), (match, p1) => { + return (p1 && slot.getTargeting(p1).join('_')) || 'NA'; + }); + return macroResult; + } catch (e) { + utils.logError(`failed to evaluate: ${macro}`); + } + } + return id; } +function evaluate(macro, divId, adUnit, replacer) { + let macroResult = macro.p + .replace(/['"]+/g, '') + .replace(//g, divId); + + if (adUnit) { + macroResult = macroResult.replace(//g, adUnit); + } + if (replacer) { + macroResult = macroResult.replace(//g, replacer); + } + if (macro.s) { + macroResult = macroResult.substring(macro.s.s, macro.s.e); + } + return macroResult; +} /** * XMLHttpRequest to get data form browsi server * @param {string} url server url with query params */ function getPredictionsFromServer(url) { + let ajax = ajaxBuilder(_moduleParams.auctionDelay || _moduleParams.timeout || DEF_TIMEOUT); + ajax(url, { success: function (response, req) { @@ -182,11 +246,11 @@ function getPredictionsFromServer(url) { try { const data = JSON.parse(response); if (data && data.p && data.kn) { - setData({p: data.p, kn: data.kn}); + setData({p: data.p, kn: data.kn, pmd: data.pmd}); } else { setData({}); } - addBrowsiTag(data.u); + addBrowsiTag(data); } catch (err) { utils.logError('unable to parse data'); setData({}) @@ -237,6 +301,7 @@ export function init(config) { _moduleParams = realTimeData.dataProviders && realTimeData.dataProviders.filter( pr => pr.name && pr.name.toLowerCase() === 'browsi')[0].params; _moduleParams.auctionDelay = realTimeData.auctionDelay; + _moduleParams.timeout = realTimeData.timeout; } catch (e) { _moduleParams = {}; } diff --git a/modules/bucksenseBidAdapter.js b/modules/bucksenseBidAdapter.js index 12a9e287f38..3f327e62121 100644 --- a/modules/bucksenseBidAdapter.js +++ b/modules/bucksenseBidAdapter.js @@ -1,10 +1,10 @@ -import { registerBidder } from '../src/adapters/bidderFactory'; -import { BANNER } from '../src/mediaTypes'; -import * as utils from '../src/utils'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { BANNER } from '../src/mediaTypes.js'; +import * as utils from '../src/utils.js'; const WHO = 'BKSHBID-005'; const BIDDER_CODE = 'bucksense'; -const URL = 'https://prebid.bksn.se:445/prebidjs/'; +const URL = 'https://prebid.bksn.se/prebidjs/'; export const spec = { code: BIDDER_CODE, diff --git a/modules/buzzoolaBidAdapter.js b/modules/buzzoolaBidAdapter.js index da2a3b30c2e..f87607657c3 100644 --- a/modules/buzzoolaBidAdapter.js +++ b/modules/buzzoolaBidAdapter.js @@ -1,8 +1,8 @@ -import * as utils from '../src/utils'; -import {registerBidder} from '../src/adapters/bidderFactory'; -import {BANNER, VIDEO} from '../src/mediaTypes'; -import {Renderer} from '../src/Renderer'; -import {OUTSTREAM} from '../src/video'; +import * as utils from '../src/utils.js'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; +import {BANNER, VIDEO} from '../src/mediaTypes.js'; +import {Renderer} from '../src/Renderer.js'; +import {OUTSTREAM} from '../src/video.js'; const BIDDER_CODE = 'buzzoola'; const ENDPOINT = 'https://exchange.buzzoola.com/ssp/prebidjs'; diff --git a/modules/byplayBidAdapter.js b/modules/byplayBidAdapter.js new file mode 100644 index 00000000000..6133cdfa647 --- /dev/null +++ b/modules/byplayBidAdapter.js @@ -0,0 +1,67 @@ +import { config } from '../src/config.js'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { Renderer } from '../src/Renderer.js'; +import { VIDEO } from '../src/mediaTypes.js'; + +const BIDDER_CODE = 'byplay'; +const ENDPOINT_URL = 'https://prebid.byplay.net/bidder'; +const VIDEO_PLAYER_URL = 'https://cdn.byplay.net/prebid-byplay-v2.js'; + +export const spec = { + code: BIDDER_CODE, + supportedMediaTypes: [VIDEO], + isBidRequestValid: (bid) => { + return !!bid.params.sectionId; + }, + buildRequests: function(validBidRequests) { + return validBidRequests.map(req => { + const payload = { + requestId: req.bidId, + sectionId: req.params.sectionId, + ...(req.params.env ? { env: req.params.env } : {}) + }; + + return { + method: 'POST', + url: ENDPOINT_URL, + data: JSON.stringify(payload), + options: { + withCredentials: false + } + }; + }); + }, + interpretResponse: (serverResponse, bidderRequest) => { + const response = serverResponse.body; + const data = JSON.parse(bidderRequest.data); + const bidResponse = { + requestId: data.requestId, + cpm: response.cpm, + width: response.width, + height: response.height, + creativeId: response.creativeId || '0', + ttl: config.getConfig('_bidderTimeout'), + currency: 'JPY', + netRevenue: response.netRevenue, + mediaType: VIDEO, + vastXml: response.vastXml, + renderer: createRenderer() + }; + + return [bidResponse]; + } +}; + +function createRenderer() { + const renderer = Renderer.install({ url: VIDEO_PLAYER_URL }); + + renderer.setRender(bid => { + bid.renderer.push(() => { + window.adtagRender(bid); + }); + }); + + return renderer; +} + +registerBidder(spec); diff --git a/modules/byplayBidAdapter.md b/modules/byplayBidAdapter.md new file mode 100644 index 00000000000..67fb9c40d35 --- /dev/null +++ b/modules/byplayBidAdapter.md @@ -0,0 +1,37 @@ +# Overview + +``` +Module Name: ByPlay Bidder Adapter +Module Type: Bidder Adapter +Maintainer: byplayers@tsumikiinc.com +``` + +# Description + +Connects to ByPlay exchange for bids. + +ByPlay bid adapter supports Video. + +# Test Parameters +``` + const adUnits = [ + { + code: 'byplay-ad', + mediaTypes: { + video: { + playerSize: [400, 225], + context: 'outstream' + } + }, + bids: [ + { + bidder: 'byplay', + params: { + sectionId: '7986', + env: 'dev' + } + } + ] + } + ]; +``` diff --git a/modules/c1xBidAdapter.js b/modules/c1xBidAdapter.js index 1e8d3cf2e0a..8e1f1487ba7 100644 --- a/modules/c1xBidAdapter.js +++ b/modules/c1xBidAdapter.js @@ -1,10 +1,10 @@ -import { registerBidder } from '../src/adapters/bidderFactory'; -import * as utils from '../src/utils'; -import { userSync } from '../src/userSync'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import * as utils from '../src/utils.js'; +import { userSync } from '../src/userSync.js'; 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/categoryTranslation.js b/modules/categoryTranslation.js index 091b16c8211..5342220d13a 100644 --- a/modules/categoryTranslation.js +++ b/modules/categoryTranslation.js @@ -11,12 +11,14 @@ * If publisher has not defined translation file than prebid will use default prebid translation file provided here //cdn.jsdelivr.net/gh/prebid/category-mapping-file@1/freewheel-mapping.json */ -import { config } from '../src/config'; -import { setupBeforeHookFnOnce, hook } from '../src/hook'; -import { ajax } from '../src/ajax'; -import { timestamp, logError, setDataInLocalStorage, getDataFromLocalStorage } from '../src/utils'; -import { addBidResponse } from '../src/auction'; +import { config } from '../src/config.js'; +import { setupBeforeHookFnOnce, hook } from '../src/hook.js'; +import { ajax } from '../src/ajax.js'; +import { timestamp, logError } from '../src/utils.js'; +import { addBidResponse } from '../src/auction.js'; +import { getCoreStorageManager } from '../src/storageManager.js'; +export const storage = getCoreStorageManager('categoryTranslation'); const DEFAULT_TRANSLATION_FILE_URL = 'https://cdn.jsdelivr.net/gh/prebid/category-mapping-file@1/freewheel-mapping.json'; const DEFAULT_IAB_TO_FW_MAPPING_KEY = 'iabToFwMappingkey'; const DEFAULT_IAB_TO_FW_MAPPING_KEY_PUB = 'iabToFwMappingkeyPub'; @@ -43,7 +45,7 @@ export function getAdserverCategoryHook(fn, adUnitCode, bid) { let localStorageKey = (config.getConfig('brandCategoryTranslation.translationFile')) ? DEFAULT_IAB_TO_FW_MAPPING_KEY_PUB : DEFAULT_IAB_TO_FW_MAPPING_KEY; if (bid.meta && !bid.meta.adServerCatId) { - let mapping = getDataFromLocalStorage(localStorageKey); + let mapping = storage.getDataFromLocalStorage(localStorageKey); if (mapping) { try { mapping = JSON.parse(mapping); @@ -65,7 +67,7 @@ export function getAdserverCategoryHook(fn, adUnitCode, bid) { export function initTranslation(url, localStorageKey) { setupBeforeHookFnOnce(addBidResponse, getAdserverCategoryHook, 50); - let mappingData = getDataFromLocalStorage(localStorageKey); + let mappingData = storage.getDataFromLocalStorage(localStorageKey); if (!mappingData || timestamp() < mappingData.lastUpdated + refreshInDays * 24 * 60 * 60 * 1000) { ajax(url, { @@ -73,7 +75,7 @@ export function initTranslation(url, localStorageKey) { try { response = JSON.parse(response); response['lastUpdated'] = timestamp(); - setDataInLocalStorage(localStorageKey, JSON.stringify(response)); + storage.setDataInLocalStorage(localStorageKey, JSON.stringify(response)); } catch (error) { logError('Failed to parse translation mapping file'); } diff --git a/modules/ccxBidAdapter.js b/modules/ccxBidAdapter.js index 226ed44f6da..ee15d6bb3ec 100644 --- a/modules/ccxBidAdapter.js +++ b/modules/ccxBidAdapter.js @@ -1,6 +1,9 @@ -import * as utils from '../src/utils' -import { registerBidder } from '../src/adapters/bidderFactory' -import { config } from '../src/config' +import * as utils from '../src/utils.js' +import { registerBidder } from '../src/adapters/bidderFactory.js' +import { config } from '../src/config.js' +import { getStorageManager } from '../src/storageManager.js'; + +const storage = getStorageManager(); const BIDDER_CODE = 'ccx' const BID_URL = 'https://delivery.clickonometrics.pl/ortb/prebid/bid' const SUPPORTED_VIDEO_PROTOCOLS = [2, 3, 5, 6] @@ -15,9 +18,9 @@ function _getDeviceObj () { return device } -function _getSiteObj () { +function _getSiteObj (bidderRequest) { let site = {} - let url = config.getConfig('pageUrl') || utils.getTopWindowUrl() + let url = config.getConfig('pageUrl') || utils.deepAccess(window, 'location.href'); if (url.length > 0) { url = url.split('?')[0] } @@ -167,10 +170,26 @@ export const spec = { if (validBidRequests.length > 0) { let requestBody = {} requestBody.imp = [] - requestBody.site = _getSiteObj() + requestBody.site = _getSiteObj(bidderRequest) requestBody.device = _getDeviceObj() requestBody.id = bidderRequest.bids[0].auctionId - requestBody.ext = {'ce': (utils.cookiesAreEnabled() ? 1 : 0)} + requestBody.ext = {'ce': (storage.cookiesAreEnabled() ? 1 : 0)} + + // Attaching GDPR Consent Params + if (bidderRequest && bidderRequest.gdprConsent) { + requestBody.user = { + ext: { + consent: bidderRequest.gdprConsent.consentString + } + }; + + requestBody.regs = { + ext: { + gdpr: (bidderRequest.gdprConsent.gdprApplies ? 1 : 0) + } + }; + } + utils._each(validBidRequests, function (bid) { requestBody.imp.push(_buildBid(bid)) }) diff --git a/modules/cedatoBidAdapter.js b/modules/cedatoBidAdapter.js index 9d6f3642f3e..ab381698f01 100644 --- a/modules/cedatoBidAdapter.js +++ b/modules/cedatoBidAdapter.js @@ -1,13 +1,15 @@ -import * as utils from '../src/utils'; -import { registerBidder } from '../src/adapters/bidderFactory'; -import { BANNER, VIDEO } from '../src/mediaTypes'; +import * as utils from '../src/utils.js'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { BANNER, VIDEO } from '../src/mediaTypes.js'; +import { getStorageManager } from '../src/storageManager.js'; + +const storage = getStorageManager(); const BIDDER_CODE = 'cedato'; const BID_URL = 'https://h.cedatoplayer.com/hb'; const SYNC_URL = 'https://h.cedatoplayer.com/hb_usync'; const TTL = 10000; const CURRENCY = 'USD'; -const FIRST_PRICE = 1; const NET_REVENUE = true; export const spec = { @@ -20,16 +22,13 @@ export const spec = { bid.params && bid.params.player_id && utils.checkCookieSupport() && - utils.cookiesAreEnabled() + storage.cookiesAreEnabled() ); }, buildRequests: function(bidRequests, bidderRequest) { - const req = bidRequests[Math.floor(Math.random() * bidRequests.length)]; - const params = req.params; - const at = FIRST_PRICE; - const site = { id: params.player_id, domain: document.domain }; - const device = { ua: navigator.userAgent }; + const site = { domain: document.domain }; + const device = { ua: navigator.userAgent, w: screen.width, h: screen.height }; const currency = CURRENCY; const tmax = bidderRequest.timeout; const auctionId = bidderRequest.auctionId; @@ -39,7 +38,7 @@ export const spec = { const imp = bidRequests.map(req => { const banner = getMediaType(req, 'banner'); const video = getMediaType(req, 'video'); - const bidfloor = params.bidfloor; + const params = req.params; const bidId = req.bidId; const adUnitCode = req.adUnitCode; const bidRequestsCount = req.bidRequestsCount; @@ -51,16 +50,15 @@ export const spec = { banner, video, adUnitCode, - bidfloor, bidRequestsCount, bidderWinsCount, - transactionId + transactionId, + params }; }); const payload = { version: '$prebid.version$', - at, site, device, imp, @@ -83,12 +81,7 @@ export const spec = { } } - return { - method: 'POST', - url: params.bid_url || BID_URL, - data: JSON.stringify(payload), - bidderRequest - }; + return formatRequest(payload, bidderRequest); }, interpretResponse: function(resp, {bidderRequest}) { @@ -186,9 +179,36 @@ function newBid(serverBid, bidderRequest) { return bid; } +function formatRequest(payload, bidderRequest) { + const payloadByUrl = {}; + const requests = []; + + payload.imp.forEach(imp => { + const url = imp.params.bid_url || BID_URL; + if (!payloadByUrl[url]) { + payloadByUrl[url] = { + ...payload, + imp: [] + }; + } + payloadByUrl[url].imp.push(imp); + }); + + for (const url in payloadByUrl) { + requests.push({ + url, + method: 'POST', + data: JSON.stringify(payloadByUrl[url]), + bidderRequest + }); + } + + return requests; +} + const getSync = (type, gdprConsent, uspConsent = '') => { const syncUrl = SYNC_URL; - let params = '&type=' + type + '&us_privacy=' + uspConsent; + let params = '?type=' + type + '&us_privacy=' + uspConsent; if (gdprConsent && typeof gdprConsent.consentString === 'string') { if (typeof gdprConsent.gdprApplies === 'boolean') { params += `&gdpr=${Number(gdprConsent.gdprApplies)}&gdpr_consent=${gdprConsent.consentString}`; diff --git a/modules/cleanmedianetBidAdapter.js b/modules/cleanmedianetBidAdapter.js index 15871e1a6ae..a8f37450d68 100644 --- a/modules/cleanmedianetBidAdapter.js +++ b/modules/cleanmedianetBidAdapter.js @@ -1,11 +1,14 @@ -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'; +import * as utils from '../src/utils.js'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; +import {config} from '../src/config.js'; +import {Renderer} from '../src/Renderer.js'; +import {BANNER, VIDEO} from '../src/mediaTypes.js'; export const helper = { + getTopWindowDomain: function (url) { + const domainStart = url.indexOf('://') + '://'.length; + return url.substring(domainStart, url.indexOf('/', domainStart) < 0 ? url.length : url.indexOf('/', domainStart)); + }, startsWith: function (str, search) { return str.substr(0, search.length) === search; }, @@ -66,15 +69,22 @@ export const spec = { const rtbBidRequest = { id: auctionId, site: { - domain: parse(url).hostname, + domain: helper.getTopWindowDomain(url), page: url, ref: bidderRequest.refererInfo.referer }, device: { - ua: navigator.userAgent + ua: navigator.userAgent, + dnt: utils.getDNT() ? 1 : 0, + h: screen.height, + w: screen.width, + language: navigator.language }, imp: [], - ext: {} + ext: {}, + user: { + ext: {} + } }; if ( @@ -86,6 +96,16 @@ export const spec = { consent_string: bidderRequest.gdprConsent.consentString, consent_required: bidderRequest.gdprConsent.gdprApplies }; + rtbBidRequest.regs = { + ext: { + gdpr: bidderRequest.gdprConsent.gdprApplies === true ? 1 : 0 + } + }; + rtbBidRequest.user = { + ext: { + consent: bidderRequest.gdprConsent.consentString + } + } } const imp = { @@ -94,12 +114,7 @@ export const spec = { tagid: adUnitCode, bidfloor: params.bidfloor || 0, bidfloorcur: 'USD', - secure: helper.startsWith( - utils.getTopWindowUrl().toLowerCase(), - 'http://' - ) - ? 0 - : 1 + secure: 1 }; const hasFavoredMediaType = @@ -113,7 +128,7 @@ export const spec = { w: sizes.length ? sizes[0][0] : 300, h: sizes.length ? sizes[0][1] : 250, pos: params.pos || 0, - topframe: bidderRequest.refererInfo.reachedTop + topframe: utils.inIframe() ? 0 : 1 } }); rtbBidRequest.imp.push(bannerImp); @@ -179,7 +194,7 @@ export const spec = { cpm: bid.price, width: bid.w, height: bid.h, - ttl: 60 * 10, + ttl: 360, creativeId: bid.crid || bid.adid, netRevenue: true, currency: bid.cur || response.cur, @@ -264,7 +279,7 @@ function newRenderer(bidRequest, bid, rendererOptions = {}) { url: (bidRequest.params && bidRequest.params.rendererUrl) || (bid.ext && bid.ext.renderer_url) || - '//s.wlplayer.com/video/latest/renderer.js', + 'https://s.wlplayer.com/video/latest/renderer.js', config: rendererOptions, loaded: false }); diff --git a/modules/clickforceBidAdapter.js b/modules/clickforceBidAdapter.js index 16ecdf713d9..20408fe9177 100644 --- a/modules/clickforceBidAdapter.js +++ b/modules/clickforceBidAdapter.js @@ -1,8 +1,8 @@ -import * as utils from '../src/utils'; -import {registerBidder} from '../src/adapters/bidderFactory'; -import {BANNER, NATIVE} from '../src/mediaTypes'; +import * as utils from '../src/utils.js'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; +import {BANNER, NATIVE} from '../src/mediaTypes.js'; 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.holmesmind.com/adserver/prebid.json?cb=' + new Date().getTime() + '&hb=1&ver=1.21'; export const spec = { code: BIDDER_CODE, @@ -112,12 +112,12 @@ export const spec = { if (syncOptions.iframeEnabled) { return [{ type: 'iframe', - url: 'https://cdn.doublemax.net/js/capmapping.htm' + url: 'https://cdn.holmesmind.com/js/capmapping.htm' }] } else if (syncOptions.pixelEnabled) { return [{ type: 'image', - url: 'https://c.doublemax.net/cm' + url: 'https://c.holmesmind.com/cm' }] } } diff --git a/modules/clicktripzBidAdapter.js b/modules/clicktripzBidAdapter.js new file mode 100644 index 00000000000..2149cbe4527 --- /dev/null +++ b/modules/clicktripzBidAdapter.js @@ -0,0 +1,67 @@ +import {logError, _each} from '../src/utils.js'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; + +const BIDDER_CODE = 'clicktripz'; +const ENDPOINT_URL = 'https://www.clicktripz.com/x/prebid/v1'; + +export const spec = { + code: BIDDER_CODE, + aliases: ['ctz'], // short code + + isBidRequestValid: function (bid) { + if (bid && bid.params && bid.params.placementId && bid.params.siteId) { + return true; + } + + return false; + }, + + buildRequests: function (validBidRequests) { + let bidRequests = []; + + _each(validBidRequests, function (bid) { + bidRequests.push({ + bidId: bid.bidId, + placementId: bid.params.placementId, + siteId: bid.params.siteId, + sizes: bid.sizes.map(function (size) { + return size.join('x') + }) + }); + }); + return { + method: 'POST', + url: ENDPOINT_URL, + data: bidRequests + }; + }, + + interpretResponse: function (serverResponse) { + let bidResponses = []; + + if (serverResponse && serverResponse.body) { + _each(serverResponse.body, function (bid) { + if (bid.errors) { + logError(bid.errors); + return; + } + + const size = bid.size.split('x'); + bidResponses.push({ + requestId: bid.bidId, + cpm: bid.cpm, + width: size[0], + height: size[1], + creativeId: bid.creativeId, + currency: bid.currency, + netRevenue: bid.netRevenue, + ttl: bid.ttl, + adUrl: bid.adUrl + }); + }); + } + return bidResponses; + } +}; + +registerBidder(spec); diff --git a/modules/clicktripzBidAdapter.md b/modules/clicktripzBidAdapter.md new file mode 100644 index 00000000000..1de1e26f37a --- /dev/null +++ b/modules/clicktripzBidAdapter.md @@ -0,0 +1,35 @@ +# Overview + +``` +Module Name: Clicktripz Bidder Adapter +Module Type: Bidder Adapter +Maintainer: integration-support@clicktripz.com +``` + +# Description +Our module makes it easy to integrate Clicktripz demand sources into your website. + +Supported Ad Fortmats: +* Banner + +# Test Parameters +``` + var adUnits = [ + { + code: 'test-div', + mediaTypes: { + banner: { + sizes: [[300, 250], [300,600]], + } + }, + bids: [ + { + bidder: "clicktripz", + params: { + placementId: '4312c63f', + siteId: 'prebid', + } + } + ] + } + ]; diff --git a/modules/coinzillaBidAdapter.js b/modules/coinzillaBidAdapter.js index 26ea7bb71e1..240a3f1fcde 100644 --- a/modules/coinzillaBidAdapter.js +++ b/modules/coinzillaBidAdapter.js @@ -1,6 +1,6 @@ -import * as utils from '../src/utils'; -import {config} from '../src/config'; -import {registerBidder} from '../src/adapters/bidderFactory'; +import * as utils from '../src/utils.js'; +import {config} from '../src/config.js'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; const BIDDER_CODE = 'coinzilla'; const ENDPOINT_URL = 'https://request.czilladx.com/serve/request.php'; diff --git a/modules/collectcentBidAdapter.js b/modules/collectcentBidAdapter.js index 50ac377788e..add3e06430d 100644 --- a/modules/collectcentBidAdapter.js +++ b/modules/collectcentBidAdapter.js @@ -1,10 +1,10 @@ -import { registerBidder } from '../src/adapters/bidderFactory'; -import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes'; -import * as utils from '../src/utils'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js'; +import * as utils from '../src/utils.js'; 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 index e5ebc41ebfd..59257babdbe 100644 --- a/modules/colombiaBidAdapter.js +++ b/modules/colombiaBidAdapter.js @@ -1,72 +1,82 @@ -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); +import * as utils from '../src/utils.js'; +import {config} from '../src/config.js'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; +import { BANNER } from '../src/mediaTypes.js'; +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'], + supportedMediaTypes: [BANNER], + isBidRequestValid: function(bid) { + return !!(bid.params.placementId); + }, + 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.placementId; + const cb = Math.floor(Math.random() * 99999999999); + const bidId = bidRequest.bidId; + const referrer = (bidderRequest && bidderRequest.refererInfo) ? bidderRequest.refererInfo.referer : ''; + 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; + let cpm = response.cpm || 0; + if (width == 300 && height == 250) { + cpm = cpm * 0.2; + } + if (width == 320 && height == 50) { + cpm = cpm * 0.55; + } + if (cpm < 1) { + return bidResponses; + } + 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 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: bidRequest.data.r, + ad: response.ad + }; + bidResponses.push(bidResponse); + } + return bidResponses; + } +} +registerBidder(spec); diff --git a/modules/colombiaBidAdapter.md b/modules/colombiaBidAdapter.md index 2131fcb4c5a..c754e49771d 100644 --- a/modules/colombiaBidAdapter.md +++ b/modules/colombiaBidAdapter.md @@ -10,13 +10,17 @@ Maintainer: colombiaonline@timesinteret.in Connect to COLOMBIA for bids. -THE COLOMBIA adapter requires setup and approval from the COLOMBIA team. Please reach out to your account team or colombiaonline@timesinteret.in for more information. +COLOMBIA adapter requires setup and approval from the COLOMBIA team. Please reach out to your account team or colombiaonline@timesinteret.in for more information. # Test Parameters ``` var adUnits = [{ code: 'test-ad-div', - sizes: [[300, 250]], + mediaTypes: { + banner: { + sizes: [[300, 250],[728,90],[320,50]] + } + }, bids: [{ bidder: 'colombia', params: { diff --git a/modules/colossussspBidAdapter.js b/modules/colossussspBidAdapter.js index adcd5df9fb6..baa60a76a0d 100644 --- a/modules/colossussspBidAdapter.js +++ b/modules/colossussspBidAdapter.js @@ -1,6 +1,6 @@ -import { registerBidder } from '../src/adapters/bidderFactory'; -import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes'; -import * as utils from '../src/utils'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js'; +import * as utils from '../src/utils.js'; const BIDDER_CODE = 'colossusssp'; const G_URL = 'https://colossusssp.com/?c=o&m=multi'; @@ -23,6 +23,19 @@ function isBidResponseValid(bid) { } } +function getUserId(eids, id, source, uidExt) { + if (id) { + var uid = { id }; + if (uidExt) { + uid.ext = uidExt; + } + eids.push({ + source, + uids: [ uid ] + }); + } +} + export const spec = { code: BIDDER_CODE, supportedMediaTypes: [BANNER, VIDEO, NATIVE], @@ -60,13 +73,17 @@ export const spec = { 'secure': location.protocol === 'https:' ? 1 : 0, 'host': location.host, 'page': location.pathname, - 'placements': placements + 'placements': placements, }; if (bidderRequest) { if (bidderRequest.uspConsent) { request.ccpa = bidderRequest.uspConsent; } + if (bidderRequest.gdprConsent) { + request.gdpr_consent = bidderRequest.gdprConsent.consentString || 'ALL' + request.gdpr_require = bidderRequest.gdprConsent.gdprApplies ? 1 : 0 + } } for (let i = 0; i < validBidRequests.length; i++) { @@ -76,11 +93,20 @@ export const spec = { placementId: bid.params.placement_id, bidId: bid.bidId, sizes: bid.mediaTypes[traff].sizes, - traffic: traff + traffic: traff, + eids: [] }; if (bid.schain) { placement.schain = bid.schain; } + if (bid.userId) { + getUserId(placement.eids, bid.userId.britepoolid, 'britepool.com'); + getUserId(placement.eids, bid.userId.idl_env, 'identityLink'); + getUserId(placement.eids, bid.userId.id5id, 'id5-sync.com') + getUserId(placement.eids, bid.userId.tdid, 'adserver.org', { + rtiPartner: 'TDID' + }); + } placements.push(placement); } return { diff --git a/modules/connectadBidAdapter.js b/modules/connectadBidAdapter.js new file mode 100644 index 00000000000..3dcb8da9838 --- /dev/null +++ b/modules/connectadBidAdapter.js @@ -0,0 +1,299 @@ +import * as utils from '../src/utils.js'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { BANNER } from '../src/mediaTypes.js' +import {config} from '../src/config.js'; + +const BIDDER_CODE = 'connectad'; +const BIDDER_CODE_ALIAS = 'connectadrealtime'; +const ENDPOINT_URL = 'https://i.connectad.io/api/v2'; +const SUPPORTED_MEDIA_TYPES = [BANNER]; + +export const spec = { + code: BIDDER_CODE, + aliases: [ BIDDER_CODE_ALIAS ], + supportedMediaTypes: SUPPORTED_MEDIA_TYPES, + + isBidRequestValid: function(bid) { + return !!(bid.params.networkId && bid.params.siteId); + }, + + buildRequests: function(validBidRequests, bidderRequest) { + let digitrust; + + let ret = { + method: 'POST', + url: '', + data: '', + bidRequest: [] + }; + + if (validBidRequests.length < 1) { + return ret; + } + + const data = Object.assign({ + placements: [], + time: Date.now(), + user: {}, + url: (bidderRequest.refererInfo && bidderRequest.refererInfo.referer) ? bidderRequest.refererInfo.referer : window.location.href, + referrer: window.document.referrer, + referrer_info: bidderRequest.refererInfo, + screensize: getScreenSize(), + dnt: (navigator.doNotTrack == 'yes' || navigator.doNotTrack == '1' || navigator.msDoNotTrack == '1') ? 1 : 0, + language: navigator.language, + ua: navigator.userAgent + }); + + // coppa compliance + if (config.getConfig('coppa') === true) { + utils.deepSetValue(data, 'user.coppa', 1); + } + + // adding schain object + if (validBidRequests[0].schain) { + utils.deepSetValue(data, 'source.ext.schain', validBidRequests[0].schain); + } + + // Attaching GDPR Consent Params + if (bidderRequest.gdprConsent) { + let gdprApplies; + if (typeof bidderRequest.gdprConsent.gdprApplies === 'boolean') { + gdprApplies = bidderRequest.gdprConsent.gdprApplies ? 1 : 0; + } + utils.deepSetValue(data, 'user.ext.gdpr', gdprApplies); + utils.deepSetValue(data, 'user.ext.consent', bidderRequest.gdprConsent.consentString); + } + + // CCPA + if (bidderRequest.uspConsent) { + utils.deepSetValue(data, 'user.ext.us_privacy', bidderRequest.uspConsent); + } + + // Digitrust Support + const bidRequestDigitrust = utils.deepAccess(validBidRequests[0], 'userId.digitrustid.data'); + if (bidRequestDigitrust && (!bidRequestDigitrust.privacy || !bidRequestDigitrust.privacy.optout)) { + digitrust = { + id: bidRequestDigitrust.id, + keyv: bidRequestDigitrust.keyv + } + } + + if (digitrust) { + utils.deepSetValue(data, 'user.ext.digitrust', { + id: digitrust.id, + keyv: digitrust.keyv + }) + } + + if (validBidRequests[0].userId && typeof validBidRequests[0].userId === 'object' && (validBidRequests[0].userId.tdid || validBidRequests[0].userId.pubcid || validBidRequests[0].userId.lipb || validBidRequests[0].userId.id5id || validBidRequests[0].userId.parrableid)) { + utils.deepSetValue(data, 'user.ext.eids', []); + + if (validBidRequests[0].userId.tdid) { + data.user.ext.eids.push({ + source: 'adserver.org', + uids: [{ + id: validBidRequests[0].userId.tdid, + ext: { + rtiPartner: 'TDID' + } + }] + }); + } + + if (validBidRequests[0].userId.pubcid) { + data.user.ext.eids.push({ + source: 'pubcommon', + uids: [{ + id: validBidRequests[0].userId.pubcid, + }] + }); + } + + if (validBidRequests[0].userId.id5id) { + data.user.ext.eids.push({ + source: 'id5-sync.com', + uids: [{ + id: validBidRequests[0].userId.id5id, + }] + }); + } + + if (validBidRequests[0].userId.parrableid) { + data.user.ext.eids.push({ + source: 'parrable.com', + uids: [{ + id: validBidRequests[0].userId.parrableid, + }] + }); + } + + if (validBidRequests[0].userId.lipb && validBidRequests[0].userId.lipb.lipbid) { + data.user.ext.eids.push({ + source: 'liveintent.com', + uids: [{ + id: validBidRequests[0].userId.lipb.lipbid + }] + }); + } + } + + validBidRequests.map(bid => { + const placement = Object.assign({ + id: bid.transactionId, + divName: bid.bidId, + sizes: bid.mediaTypes.banner.sizes, + adTypes: getSize(bid.mediaTypes.banner.sizes || bid.sizes) + }, bid.params); + + if (placement.networkId && placement.siteId) { + data.placements.push(placement); + } + }); + + ret.data = JSON.stringify(data); + ret.bidRequest = validBidRequests; + ret.url = ENDPOINT_URL; + + return ret; + }, + + interpretResponse: function(serverResponse, bidRequest, bidderRequest) { + let bid; + let bids; + let bidId; + let bidObj; + let bidResponses = []; + + bids = bidRequest.bidRequest; + + serverResponse = (serverResponse || {}).body; + for (let i = 0; i < bids.length; i++) { + bid = {}; + bidObj = bids[i]; + bidId = bidObj.bidId; + + if (serverResponse) { + const decision = serverResponse.decisions && serverResponse.decisions[bidId]; + const price = decision && decision.pricing && decision.pricing.clearPrice; + + if (decision && price) { + bid.requestId = bidId; + bid.cpm = price; + bid.width = decision.width; + bid.height = decision.height; + bid.dealid = decision.dealid || null; + bid.ad = retrieveAd(decision); + bid.currency = 'USD'; + bid.creativeId = decision.adId; + bid.ttl = 360; + bid.netRevenue = true; + bidResponses.push(bid); + } + } + } + + return bidResponses; + }, + + getUserSyncs: function(syncOptions, serverResponses, gdprConsent, uspConsent) { + let syncEndpoint = 'https://cdn.connectad.io/connectmyusers.php?'; + + if (gdprConsent) { + syncEndpoint = utils.tryAppendQueryString(syncEndpoint, 'gdpr', (gdprConsent.gdprApplies ? 1 : 0)); + } + + if (gdprConsent && typeof gdprConsent.consentString === 'string') { + syncEndpoint = utils.tryAppendQueryString(syncEndpoint, 'gdpr_consent', gdprConsent.consentString); + } + + if (uspConsent) { + syncEndpoint = utils.tryAppendQueryString(syncEndpoint, 'us_privacy', uspConsent); + } + + if (config.getConfig('coppa') === true) { + syncEndpoint = utils.tryAppendQueryString(syncEndpoint, 'coppa', 1); + } + + if (syncOptions.iframeEnabled) { + return [{ + type: 'iframe', + url: syncEndpoint + }]; + } else { + utils.logWarn('Bidder ConnectAd: Please activate iFrame Sync'); + } + } +}; + +const sizeMap = [ + null, + '120x90', + '200x200', + '468x60', + '728x90', + '300x250', + '160x600', + '120x600', + '300x100', + '180x150', + '336x280', + '240x400', + '234x60', + '88x31', + '120x60', + '120x240', + '125x125', + '220x250', + '250x250', + '250x90', + '0x0', + '200x90', + '300x50', + '320x50', + '320x480', + '185x185', + '620x45', + '300x125', + '800x250', + '980x120', + '980x150', + '320x150', + '300x300', + '200x600', + '320x500', + '320x320' +]; + +sizeMap[77] = '970x90'; +sizeMap[123] = '970x250'; +sizeMap[43] = '300x600'; +sizeMap[286] = '970x66'; +sizeMap[3230] = '970x280'; +sizeMap[429] = '486x60'; +sizeMap[374] = '700x500'; +sizeMap[934] = '300x1050'; +sizeMap[1578] = '320x100'; +sizeMap[331] = '320x250'; +sizeMap[3301] = '320x267'; +sizeMap[2730] = '728x250'; + +function getSize(sizes) { + const result = []; + sizes.forEach(function(size) { + const index = sizeMap.indexOf(size[0] + 'x' + size[1]); + if (index >= 0) { + result.push(index); + } + }); + return result; +} + +function retrieveAd(decision) { + return decision.contents && decision.contents[0] && decision.contents[0].body; +} + +function getScreenSize() { + return [window.screen.width, window.screen.height].join('x'); +} + +registerBidder(spec); diff --git a/modules/connectadBidAdapter.md b/modules/connectadBidAdapter.md new file mode 100644 index 00000000000..e63494e1add --- /dev/null +++ b/modules/connectadBidAdapter.md @@ -0,0 +1,46 @@ +# Overview + +``` +Module Name: ConnectAd PreBid Adapter +Module Type: Bidder Adapter +Maintainer: support@connectad.io +``` + +# Description + +ConnectAd bid adapter supports only Banner at present. Video and Mobile will follow Q2/2020 + +# Sample Ad Unit: For Publishers +``` +var adUnits = [ +{ + code: 'test-div', + mediaTypes: { + banner: { + sizes: [[300, 250], [300,600]] + } + }, + bids: [{ + bidder: 'connectad', + params: { + siteId: 123456, + networkId: 123456, + bidfloor: 0.20 // Optional: Requested Bidfloor + } + }] +} + +# ## Configuration +ConnectAd recommends the UserSync configuration below otherwise we will not be able to performe user syncs. + +```javascript +pbjs.setConfig({ + userSync: { + filterSettings: { + iframe: { + bidders: ['connectad'], + filter: 'include' + } + } + } +}); \ No newline at end of file diff --git a/modules/consentManagement.js b/modules/consentManagement.js index d5703c1a784..4a1fa9ba8d0 100644 --- a/modules/consentManagement.js +++ b/modules/consentManagement.js @@ -4,11 +4,11 @@ * and make it available for any GDPR supported adapters to read/pass this information to * their system. */ -import * as utils from '../src/utils'; -import { config } from '../src/config'; -import { gdprDataHandler } from '../src/adapterManager'; -import includes from 'core-js/library/fn/array/includes'; -import strIncludes from 'core-js/library/fn/string/includes'; +import * as utils from '../src/utils.js'; +import { config } from '../src/config.js'; +import { gdprDataHandler } from '../src/adapterManager.js'; +import includes from 'core-js/library/fn/array/includes.js'; +import strIncludes from 'core-js/library/fn/string/includes.js'; const DEFAULT_CMP = 'iab'; const DEFAULT_CONSENT_TIMEOUT = 10000; @@ -17,8 +17,10 @@ const DEFAULT_ALLOW_AUCTION_WO_CONSENT = true; export let userCMP; export let consentTimeout; export let allowAuction; +export let gdprScope; export let staticConsentData; +let cmpVersion = 0; let consentData; let addedConsentHook = false; @@ -47,11 +49,70 @@ function lookupStaticConsentData(cmpSuccess, cmpError, hookConfig) { * @param {object} hookConfig contains module related variables (see comment in requestBidsHook function) */ function lookupIabConsent(cmpSuccess, cmpError, hookConfig) { - function handleCmpResponseCallbacks() { + function findCMP() { + let f = window; + let cmpFrame; + let cmpFunction; + while (!cmpFrame) { + try { + if (typeof f.__tcfapi === 'function' || typeof f.__cmp === 'function') { + if (typeof f.__tcfapi === 'function') { + cmpVersion = 2; + cmpFunction = f.__tcfapi; + } else { + cmpVersion = 1; + cmpFunction = f.__cmp; + } + cmpFrame = f; + break; + } + } catch (e) { } + + // need separate try/catch blocks due to the exception errors thrown when trying to check for a frame that doesn't exist in 3rd party env + try { + if (f.frames['__tcfapiLocator']) { + cmpVersion = 2; + cmpFrame = f; + break; + } + } catch (e) { } + + try { + if (f.frames['__cmpLocator']) { + cmpVersion = 1; + cmpFrame = f; + break; + } + } catch (e) { } + + if (f === window.top) break; + f = f.parent; + } + return { + cmpFrame, + cmpFunction + }; + } + + function v2CmpResponseCallback(tcfData, success) { + utils.logInfo('Received a response from CMP', tcfData); + if (success) { + if (tcfData.eventStatus === 'tcloaded' || tcfData.eventStatus === 'useractioncomplete') { + cmpSuccess(tcfData, hookConfig); + } else if (tcfData.eventStatus === 'cmpuishown' && tcfData.tcString && tcfData.purposeOneTreatment === true) { + cmpSuccess(tcfData, hookConfig); + } + } else { + cmpError('CMP unable to register callback function. Please check CMP setup.', hookConfig); + } + } + + function handleV1CmpResponseCallbacks() { const cmpResponse = {}; function afterEach() { if (cmpResponse.getConsentData && cmpResponse.getVendorConsents) { + utils.logInfo('Received all requested responses from CMP', cmpResponse); cmpSuccess(cmpResponse, hookConfig); } } @@ -68,10 +129,13 @@ function lookupIabConsent(cmpSuccess, cmpError, hookConfig) { } } - let callbackHandler = handleCmpResponseCallbacks(); + let v1CallbackHandler = handleV1CmpResponseCallbacks(); let cmpCallbacks = {}; - let cmpFunction; + let { cmpFrame, cmpFunction } = findCMP(); + if (!cmpFrame) { + return cmpError('CMP not found.', hookConfig); + } // to collect the consent information from the user, we perform two calls to the CMP in parallel: // first to collect the user's consent choices represented in an encoded string (via getConsentData) // second to collect the user's full unparsed consent information (via getVendorConsents) @@ -81,34 +145,28 @@ function lookupIabConsent(cmpSuccess, cmpError, hookConfig) { // check to see if prebid is in a safeframe (with CMP support) // else assume prebid may be inside an iframe and use the IAB CMP locator code to see if CMP's located in a higher parent window. this works in cross domain iframes // if the CMP is not found, the iframe function will call the cmpError exit callback to abort the rest of the CMP workflow - try { - cmpFunction = window.__cmp || utils.getWindowTop().__cmp; - } catch (e) { } if (utils.isFn(cmpFunction)) { - cmpFunction('getConsentData', null, callbackHandler.consentDataCallback); - cmpFunction('getVendorConsents', null, callbackHandler.vendorConsentsCallback); - } else if (inASafeFrame() && typeof window.$sf.ext.cmp === 'function') { - callCmpWhileInSafeFrame('getConsentData', callbackHandler.consentDataCallback); - callCmpWhileInSafeFrame('getVendorConsents', callbackHandler.vendorConsentsCallback); - } else { - // find the CMP frame - let f = window; - let cmpFrame; - while (!cmpFrame) { - try { - if (f.frames['__cmpLocator']) cmpFrame = f; - } catch (e) { } - if (f === window.top) break; - f = f.parent; + utils.logInfo('Detected CMP API is directly accessible, calling it now...'); + if (cmpVersion === 1) { + cmpFunction('getConsentData', null, v1CallbackHandler.consentDataCallback); + cmpFunction('getVendorConsents', null, v1CallbackHandler.vendorConsentsCallback); + } else if (cmpVersion === 2) { + cmpFunction('addEventListener', cmpVersion, v2CmpResponseCallback); } - - if (!cmpFrame) { - return cmpError('CMP not found.', hookConfig); + } else if (cmpVersion === 1 && inASafeFrame() && typeof window.$sf.ext.cmp === 'function') { + // this safeframe workflow is only supported with TCF v1 spec; the v2 recommends to use the iframe postMessage route instead (even if you are in a safeframe). + utils.logInfo('Detected Prebid.js is encased in a SafeFrame and CMP is registered, calling it now...'); + callCmpWhileInSafeFrame('getConsentData', v1CallbackHandler.consentDataCallback); + callCmpWhileInSafeFrame('getVendorConsents', v1CallbackHandler.vendorConsentsCallback); + } else { + utils.logInfo('Detected CMP is outside the current iframe where Prebid.js is located, calling it now...'); + if (cmpVersion === 1) { + callCmpWhileInIframe('getConsentData', cmpFrame, v1CallbackHandler.consentDataCallback); + callCmpWhileInIframe('getVendorConsents', cmpFrame, v1CallbackHandler.vendorConsentsCallback); + } else if (cmpVersion === 2) { + callCmpWhileInIframe('addEventListener', cmpFrame, v2CmpResponseCallback); } - - callCmpWhileInIframe('getConsentData', cmpFrame, callbackHandler.consentDataCallback); - callCmpWhileInIframe('getVendorConsents', cmpFrame, callbackHandler.vendorConsentsCallback); } function inASafeFrame() { @@ -138,17 +196,22 @@ function lookupIabConsent(cmpSuccess, cmpError, hookConfig) { } function callCmpWhileInIframe(commandName, cmpFrame, moduleCallback) { + let apiName = (cmpVersion === 2) ? '__tcfapi' : '__cmp'; + /* Setup up a __cmp function to do the postMessage and stash the callback. This function behaves (from the caller's perspective identicially to the in-frame __cmp call */ - window.__cmp = function (cmd, arg, callback) { + window[apiName] = function (cmd, arg, callback) { let callId = Math.random() + ''; + let callName = `${apiName}Call`; let msg = { - __cmpCall: { + [callName]: { command: cmd, parameter: arg, callId: callId } }; + if (cmpVersion !== 1) msg[callName].version = cmpVersion; + cmpCallbacks[callId] = callback; cmpFrame.postMessage(msg, '*'); } @@ -157,28 +220,19 @@ function lookupIabConsent(cmpSuccess, cmpError, hookConfig) { window.addEventListener('message', readPostMessageResponse, false); // call CMP - window.__cmp(commandName, null, cmpIframeCallback); + window[apiName](commandName, null, moduleCallback); function readPostMessageResponse(event) { - let json = (typeof event.data === 'string' && strIncludes(event.data, 'cmpReturn')) ? JSON.parse(event.data) : event.data; - if (json.__cmpReturn && json.__cmpReturn.callId) { - let i = json.__cmpReturn; + let cmpDataPkgName = `${apiName}Return`; + let json = (typeof event.data === 'string' && strIncludes(event.data, cmpDataPkgName)) ? JSON.parse(event.data) : event.data; + if (json[cmpDataPkgName] && json[cmpDataPkgName].callId) { + let payload = json[cmpDataPkgName]; // TODO - clean up this logic (move listeners?); we have duplicate messages responses because 2 eventlisteners are active from the 2 cmp requests running in parallel - if (typeof cmpCallbacks[i.callId] !== 'undefined') { - cmpCallbacks[i.callId](i.returnValue, i.success); - delete cmpCallbacks[i.callId]; + if (typeof cmpCallbacks[payload.callId] !== 'undefined') { + cmpCallbacks[payload.callId](payload.returnValue, payload.success); } } } - - function removePostMessageListener() { - window.removeEventListener('message', readPostMessageResponse, false); - } - - function cmpIframeCallback(consentObject) { - removePostMessageListener(); - moduleCallback(consentObject); - } } } @@ -204,6 +258,7 @@ export function requestBidsHook(fn, reqBidsConfigObj) { // in case we already have consent (eg during bid refresh) if (consentData) { + utils.logInfo('User consent information already known. Pulling internally stored information...'); return exitModule(null, hookConfig); } @@ -232,22 +287,50 @@ export function requestBidsHook(fn, reqBidsConfigObj) { * @param {object} hookConfig contains module related variables (see comment in requestBidsHook function) */ function processCmpData(consentObject, hookConfig) { - let gdprApplies = consentObject && consentObject.getConsentData && consentObject.getConsentData.gdprApplies; - if ( - (typeof gdprApplies !== 'boolean') || - (gdprApplies === true && - !(utils.isStr(consentObject.getConsentData.consentData) && - utils.isPlainObject(consentObject.getVendorConsents) && - Object.keys(consentObject.getVendorConsents).length > 1 + function checkV1Data(consentObject) { + let gdprApplies = consentObject && consentObject.getConsentData && consentObject.getConsentData.gdprApplies; + return !!( + (typeof gdprApplies !== 'boolean') || + (gdprApplies === true && + !(utils.isStr(consentObject.getConsentData.consentData) && + utils.isPlainObject(consentObject.getVendorConsents) && + Object.keys(consentObject.getVendorConsents).length > 1 + ) ) - ) - ) { - cmpFailed(`CMP returned unexpected value during lookup process.`, hookConfig, consentObject); - } else { - clearTimeout(hookConfig.timer); - storeConsentData(consentObject); + ); + } + + function checkV2Data() { + let gdprApplies = consentObject && consentObject.gdprApplies; + let tcString = consentObject && consentObject.tcString; + return !!( + (typeof gdprApplies !== 'boolean') || + (gdprApplies === true && !utils.isStr(tcString)) + ); + } - exitModule(null, hookConfig); + // do extra things for static config + if (userCMP === 'static') { + cmpVersion = (consentObject.getConsentData) ? 1 : (consentObject.getTCData) ? 2 : 0; + // remove extra layer in static v2 data object so it matches normal v2 CMP object for processing step + if (cmpVersion === 2) { + consentObject = consentObject.getTCData; + } + } + + // determine which set of checks to run based on cmpVersion + let checkFn = (cmpVersion === 1) ? checkV1Data : (cmpVersion === 2) ? checkV2Data : null; + + if (utils.isFn(checkFn)) { + if (checkFn(consentObject)) { + cmpFailed(`CMP returned unexpected value during lookup process.`, hookConfig, consentObject); + } else { + clearTimeout(hookConfig.timer); + storeConsentData(consentObject); + exitModule(null, hookConfig); + } + } else { + cmpFailed('Unable to derive CMP version to process data. Consent object does not conform to TCF v1 or v2 specs.', hookConfig, consentObject); } } @@ -279,17 +362,26 @@ function cmpFailed(errMsg, hookConfig, extraArgs) { * @param {object} cmpConsentObject required; an object representing user's consent choices (can be undefined in certain use-cases for this function only) */ function storeConsentData(cmpConsentObject) { - consentData = { - consentString: (cmpConsentObject) ? cmpConsentObject.getConsentData.consentData : undefined, - vendorData: (cmpConsentObject) ? cmpConsentObject.getVendorConsents : undefined, - gdprApplies: (cmpConsentObject) ? cmpConsentObject.getConsentData.gdprApplies : undefined - }; + if (cmpVersion === 1) { + consentData = { + consentString: (cmpConsentObject) ? cmpConsentObject.getConsentData.consentData : undefined, + vendorData: (cmpConsentObject) ? cmpConsentObject.getVendorConsents : undefined, + gdprApplies: (cmpConsentObject) ? cmpConsentObject.getConsentData.gdprApplies : gdprScope + }; + } else { + consentData = { + consentString: (cmpConsentObject) ? cmpConsentObject.tcString : undefined, + vendorData: (cmpConsentObject) || undefined, + gdprApplies: (cmpConsentObject) ? cmpConsentObject.gdprApplies : gdprScope + }; + } + consentData.apiVersion = cmpVersion; gdprDataHandler.setConsentData(consentData); } /** * This function handles the exit logic for the module. - * There are several paths in the module's logic to call this function and we only allow 1 of the 3 potential exits to happen before suppressing others. + * While there are several paths in the module's logic to call this function, we only allow 1 of the 3 potential exits to happen before suppressing others. * * We prevent multiple exits to avoid conflicting messages in the console depending on certain scenarios. * One scenario could be auction was canceled due to timeout with CMP being reached. @@ -336,12 +428,13 @@ function exitModule(errMsg, hookConfig, extraArgs) { export function resetConsentData() { consentData = undefined; userCMP = undefined; + cmpVersion = 0; gdprDataHandler.setConsentData(null); } /** * A configuration function that initializes some module variables, as well as add a hook into the requestBids function - * @param {object} config required; consentManagement module config settings; cmp (string), timeout (int), allowAuctionWithoutConsent (boolean) + * @param {{cmp:string, timeout:number, allowAuctionWithoutConsent:boolean, defaultGdprScope:boolean}} config required; consentManagement module config settings; cmp (string), timeout (int), allowAuctionWithoutConsent (boolean) */ export function setConsentConfig(config) { // if `config.gdpr` or `config.usp` exist, assume new config format. @@ -372,6 +465,9 @@ export function setConsentConfig(config) { utils.logInfo(`consentManagement config did not specify allowAuctionWithoutConsent. Using system default setting (${DEFAULT_ALLOW_AUCTION_WO_CONSENT}).`); } + // if true, then gdprApplies should be set to true + gdprScope = config.defaultGdprScope === true; + utils.logInfo('consentManagement module has been activated...'); if (userCMP === 'static') { diff --git a/modules/consentManagementUsp.js b/modules/consentManagementUsp.js index a210132947c..1a5879a40ff 100644 --- a/modules/consentManagementUsp.js +++ b/modules/consentManagementUsp.js @@ -4,9 +4,9 @@ * information and make it available for any USP (CCPA) supported adapters to * read/pass this information to their system. */ -import * as utils from '../src/utils'; -import { config } from '../src/config'; -import { uspDataHandler } from '../src/adapterManager'; +import * as utils from '../src/utils.js'; +import { config } from '../src/config.js'; +import { uspDataHandler } from '../src/adapterManager.js'; const DEFAULT_CONSENT_API = 'iab'; const DEFAULT_CONSENT_TIMEOUT = 50; @@ -14,20 +14,32 @@ const USPAPI_VERSION = 1; export let consentAPI; export let consentTimeout; +export let staticConsentData; let consentData; let addedConsentHook = false; // consent APIs const uspCallMap = { - 'iab': lookupUspConsent + 'iab': lookupUspConsent, + 'static': lookupStaticConsentData }; +/** + * This function reads the consent string from the config to obtain the consent information of the user. + * @param {function(string)} cmpSuccess acts as a success callback when the value is read from config; pass along consentObject (string) from CMP + * @param {function(string)} cmpError acts as an error callback while interacting with the config string; pass along an error message (string) + * @param {object} hookConfig contains module related variables (see comment in requestBidsHook function) + */ +function lookupStaticConsentData(cmpSuccess, cmpError, hookConfig) { + cmpSuccess(staticConsentData, hookConfig); +} + /** * This function handles interacting with an USP compliant consent manager to obtain the consent information of the user. * Given the async nature of the USP's API, we pass in acting success/error callback functions to exit this function * based on the appropriate result. - * @param {function(string)} uspSuccess acts as a success callback when USPAPI returns a value; pass along consentObject (string) from UPSAPI + * @param {function(string)} uspSuccess acts as a success callback when USPAPI returns a value; pass along consentObject (string) from USPAPI * @param {function(string)} uspError acts as an error callback while interacting with USPAPI; pass along an error message (string) * @param {object} hookConfig contains module related variables (see comment in requestBidsHook function) */ @@ -178,7 +190,7 @@ export function requestBidsHook(fn, reqBidsConfigObj) { function processUspData(consentObject, hookConfig) { const valid = !!(consentObject && consentObject.usPrivacy); if (!valid) { - uspapiFailed(`UPSAPI returned unexpected value during lookup process.`, hookConfig, consentObject); + uspapiFailed(`USPAPI returned unexpected value during lookup process.`, hookConfig, consentObject); return; } @@ -283,6 +295,14 @@ export function setConsentConfig(config) { utils.logInfo('USPAPI consentManagement module has been activated...'); + if (consentAPI === 'static') { + if (utils.isPlainObject(config.consentData) && utils.isPlainObject(config.consentData.getUSPData)) { + if (config.consentData.getUSPData.uspString) staticConsentData = { usPrivacy: config.consentData.getUSPData.uspString }; + consentTimeout = 0; + } else { + utils.logError(`consentManagement config with cmpApi: 'static' did not specify consentData. No consents will be available to adapters.`); + } + } if (!addedConsentHook) { $$PREBID_GLOBAL$$.requestBids.before(requestBidsHook, 50); } diff --git a/modules/consumableBidAdapter.js b/modules/consumableBidAdapter.js index bd24870c5e5..8eb56f7d0c2 100644 --- a/modules/consumableBidAdapter.js +++ b/modules/consumableBidAdapter.js @@ -1,5 +1,5 @@ -import * as utils from '../src/utils'; -import { registerBidder } from '../src/adapters/bidderFactory'; +import * as utils from '../src/utils.js'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; const BIDDER_CODE = 'consumable'; @@ -62,6 +62,10 @@ export const spec = { }; } + if (bidderRequest && bidderRequest.uspConsent) { + data.ccpa = bidderRequest.uspConsent; + } + validBidRequests.map(bid => { const sizes = (bid.mediaTypes && bid.mediaTypes.banner && bid.mediaTypes.banner.sizes) || bid.sizes || []; const placement = Object.assign({ @@ -133,7 +137,7 @@ export const spec = { if (syncOptions.iframeEnabled) { return [{ type: 'iframe', - url: '//sync.serverbid.com/ss/' + siteId + '.html' + url: 'https://sync.serverbid.com/ss/' + siteId + '.html' }]; } diff --git a/modules/contentigniteBidAdapter.js b/modules/contentigniteBidAdapter.js deleted file mode 100644 index 2e3092114f6..00000000000 --- 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/convergeBidAdapter.js b/modules/convergeBidAdapter.js new file mode 100644 index 00000000000..bea3b6cb1ab --- /dev/null +++ b/modules/convergeBidAdapter.js @@ -0,0 +1,313 @@ +import * as utils from '../src/utils.js'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; +import { Renderer } from '../src/Renderer.js'; +import { VIDEO, BANNER } from '../src/mediaTypes.js'; + +const BIDDER_CODE = 'converge'; +const ENDPOINT_URL = 'https://tech.convergd.com/hb'; +const TIME_TO_LIVE = 360; +const SYNC_URL = 'https://tech.convergd.com/push_sync'; +const RENDERER_URL = 'https://acdn.adnxs.com/video/outstream/ANOutstreamVideo.js'; + +let hasSynced = false; + +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, + supportedMediaTypes: [ BANNER, VIDEO ], + /** + * 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 + * @param {bidderRequest} bidderRequest - bidder request object + * @return ServerRequest Info describing the request to the server. + */ + buildRequests: function(validBidRequests, bidderRequest) { + const auids = []; + const bidsMap = {}; + const slotsMapByUid = {}; + const sizeMap = {}; + const bids = validBidRequests || []; + let priceType = 'net'; + let pageKeywords; + let reqId; + + bids.forEach(bid => { + if (bid.params.priceType === 'gross') { + priceType = 'gross'; + } + reqId = bid.bidderRequestId; + const {params: {uid}, adUnitCode} = bid; + auids.push(uid); + const sizesId = utils.parseSizesInput(bid.sizes); + + if (!pageKeywords && !utils.isEmpty(bid.params.keywords)) { + const keywords = utils.transformBidderParamKeywords(bid.params.keywords); + + if (keywords.length > 0) { + keywords.forEach(deleteValues); + } + pageKeywords = keywords; + } + + if (!slotsMapByUid[uid]) { + slotsMapByUid[uid] = {}; + } + const slotsMap = slotsMapByUid[uid]; + if (!slotsMap[adUnitCode]) { + slotsMap[adUnitCode] = {adUnitCode, bids: [bid], parents: []}; + } else { + slotsMap[adUnitCode].bids.push(bid); + } + const slot = slotsMap[adUnitCode]; + + sizesId.forEach((sizeId) => { + sizeMap[sizeId] = true; + if (!bidsMap[uid]) { + bidsMap[uid] = {}; + } + + if (!bidsMap[uid][sizeId]) { + bidsMap[uid][sizeId] = [slot]; + } else { + bidsMap[uid][sizeId].push(slot); + } + slot.parents.push({parent: bidsMap[uid], key: sizeId, uid}); + }); + }); + + const payload = { + pt: priceType, + auids: auids.join(','), + sizes: utils.getKeys(sizeMap).join(','), + r: reqId, + wrapperType: 'Prebid_js', + wrapperVersion: '$prebid.version$' + }; + + if (pageKeywords) { + payload.keywords = JSON.stringify(pageKeywords); + } + + if (bidderRequest) { + if (bidderRequest.refererInfo && bidderRequest.refererInfo.referer) { + payload.u = bidderRequest.refererInfo.referer; + } + if (bidderRequest.timeout) { + payload.wtimeout = bidderRequest.timeout; + } + if (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; + } + if (bidderRequest.uspConsent) { + payload.us_privacy = bidderRequest.uspConsent; + } + } + + return { + method: 'GET', + url: ENDPOINT_URL, + data: utils.parseQueryStringParameters(payload).replace(/\&$/, ''), + bidsMap: bidsMap, + }; + }, + /** + * Unpack the response from the server into a list of bids. + * + * @param {*} serverResponse A successful response from the server. + * @param {*} bidRequest + * @param {Renderer} RendererConst + * @return {Bid[]} An array of bids which were nested inside the server. + */ + interpretResponse: function(serverResponse, bidRequest, RendererConst = Renderer) { + 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, RendererConst); + }); + } + if (errorMessage) utils.logError(errorMessage); + return bidResponses; + }, + getUserSyncs: function (syncOptions, responses, gdprConsent, uspConsent) { + if (!hasSynced && syncOptions.pixelEnabled) { + let params = ''; + + if (gdprConsent && typeof gdprConsent.consentString === 'string') { + if (typeof gdprConsent.gdprApplies === 'boolean') { + params += `&gdpr=${Number(gdprConsent.gdprApplies)}&gdpr_consent=${gdprConsent.consentString}`; + } else { + params += `&gdpr_consent=${gdprConsent.consentString}`; + } + } + if (uspConsent) { + params += `&us_privacy=${uspConsent}`; + } + + hasSynced = true; + return { + type: 'image', + url: SYNC_URL + params + }; + } + } +}; + +function isPopulatedArray(arr) { + return !!(utils.isArray(arr) && arr.length > 0); +} + +function deleteValues(keyPairObj) { + if (isPopulatedArray(keyPairObj.value) && keyPairObj.value[0] === '') { + delete keyPairObj.value; + } +} + +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, RendererConst) { + 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) { + const sizeId = `${serverBid.w}x${serverBid.h}`; + if (awaitingBids[sizeId]) { + const slot = awaitingBids[sizeId][0]; + + const bid = slot.bids.shift(); + const bidResponse = { + requestId: bid.bidId, // bid.bidderRequestId, + bidderCode: spec.code, + cpm: serverBid.price, + width: serverBid.w, + height: serverBid.h, + creativeId: serverBid.auid, // bid.bidId, + currency: 'EUR', + netRevenue: priceType !== 'gross', + ttl: TIME_TO_LIVE, + dealId: serverBid.dealid + }; + if (serverBid.content_type === 'video' || (!serverBid.content_type && bid.mediaTypes && bid.mediaTypes.video)) { + bidResponse.vastXml = serverBid.adm; + bidResponse.mediaType = VIDEO; + bidResponse.adResponse = { + content: bidResponse.vastXml + }; + if (!bid.renderer && (!bid.mediaTypes || !bid.mediaTypes.video || bid.mediaTypes.video.context === 'outstream')) { + bidResponse.renderer = createRenderer(bidResponse, { + id: bid.bidId, + url: RENDERER_URL + }, RendererConst); + } + } else { + bidResponse.ad = serverBid.adm; + bidResponse.mediaType = BANNER; + } + + bidResponses.push(bidResponse); + + if (!slot.bids.length) { + slot.parents.forEach(({parent, key, uid}) => { + const index = parent[key].indexOf(slot); + if (index > -1) { + parent[key].splice(index, 1); + } + if (!parent[key].length) { + delete parent[key]; + if (!utils.getKeys(parent).length) { + delete bidsMap[uid]; + } + } + }); + } + } + } else { + errorMessage = LOG_ERROR_MESS.noPlacementCode + serverBid.auid; + } + } + if (errorMessage) { + utils.logError(errorMessage); + } +} + +function outstreamRender (bid) { + bid.renderer.push(() => { + window.ANOutstreamVideo.renderAd({ + targetId: bid.adUnitCode, + adResponse: bid.adResponse + }); + }); +} + +function createRenderer (bid, rendererParams, RendererConst) { + const rendererInst = RendererConst.install({ + id: rendererParams.id, + url: rendererParams.url, + loaded: false + }); + + try { + rendererInst.setRender(outstreamRender); + } catch (err) { + utils.logWarn('Prebid Error calling setRender on renderer', err); + } + + return rendererInst; +} + +export function resetUserSync() { + hasSynced = false; +} + +export function getSyncUrl() { + return SYNC_URL; +} + +registerBidder(spec); diff --git a/modules/convergeBidAdapter.md b/modules/convergeBidAdapter.md new file mode 100644 index 00000000000..ab916a8b3b6 --- /dev/null +++ b/modules/convergeBidAdapter.md @@ -0,0 +1,57 @@ +# Overview + +Module Name: Converge Bidder Adapter +Module Type: Bidder Adapter +Maintainer: support@converge-digital.com + +# Description + +Module that connects to Converge demand source to fetch bids. +Converge Bid Adapter supports Banner and Video (instream and outstream). + +# Test Parameters +``` + var adUnits = [ + { + code: 'test-div', + sizes: [[300, 250]], + bids: [ + { + bidder: "converge", + params: { + uid: '59', + priceType: 'gross' // by default is 'net' + } + } + ] + },{ + code: 'test-div', + sizes: [[728, 90]], + bids: [ + { + bidder: "converge", + params: { + uid: 1, + priceType: 'gross', + keywords: { + brandsafety: ['disaster'], + topic: ['stress', 'fear'] + } + } + } + ] + },{ + code: 'test-div', + sizes: [[640, 360]], + mediaTypes: { video: {} }, + bids: [ + { + bidder: "converge", + params: { + uid: 60 + } + } + ] + } + ]; +``` diff --git a/modules/conversantBidAdapter.js b/modules/conversantBidAdapter.js index bb11b1f87cb..2ecdb2b7e98 100644 --- a/modules/conversantBidAdapter.js +++ b/modules/conversantBidAdapter.js @@ -1,12 +1,17 @@ -import * as utils from '../src/utils'; -import {registerBidder} from '../src/adapters/bidderFactory'; -import { BANNER, VIDEO } from '../src/mediaTypes'; +import * as utils from '../src/utils.js'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; +import { BANNER, VIDEO } from '../src/mediaTypes.js'; +import { getStorageManager } from '../src/storageManager.js'; + +const GVLID = 24; +export const storage = getStorageManager(GVLID); const BIDDER_CODE = 'conversant'; const URL = 'https://web.hb.ad.cpe.dotomi.com/s2s/header/24'; export const spec = { code: BIDDER_CODE, + gvlid: GVLID, aliases: ['cnvr'], // short code supportedMediaTypes: [BANNER, VIDEO], @@ -53,6 +58,7 @@ export const spec = { let requestId = ''; let pubcid = null; let pubcidName = '_pubcid'; + let bidurl = URL; const conversantImps = validBidRequests.map(function(bid) { const bidfloor = utils.getBidIdParameter('bidfloor', bid.params); @@ -104,6 +110,9 @@ export const spec = { } else if (bid.crumbs && bid.crumbs.pubcid) { pubcid = bid.crumbs.pubcid; } + if (bid.params.white_label_url) { + bidurl = bid.params.white_label_url; + } return imp; }); @@ -159,7 +168,7 @@ export const spec = { return { method: 'POST', - url: URL, + url: bidurl, data: payload, }; }, @@ -314,36 +323,24 @@ function copyOptProperty(src, dst, dstName) { function collectEids(bidRequests) { const request = bidRequests[0]; // bidRequests have the same userId object const eids = []; - - addEid(eids, request, 'userId.tdid', 'adserver.org'); - addEid(eids, request, 'userId.idl_env', 'liveramp.com'); - addEid(eids, request, 'userId.criteoId', 'criteo.com'); - addEid(eids, request, 'userId.id5id', 'id5-sync.com'); - addEid(eids, request, 'userId.parrableid', 'parrable.com'); - addEid(eids, request, 'userId.digitrustid.data.id', 'digitru.st'); - addEid(eids, request, 'userId.lipb.lipbid', 'liveintent.com'); - - return eids; -} - -/** - * Extract and push a single extended id into eids array - * @param eids Array of extended IDs - * @param idObj Object containing IDs - * @param keyPath Nested properties expressed as a path - * @param source Source for the ID - */ -function addEid(eids, idObj, keyPath, source) { - const id = utils.deepAccess(idObj, keyPath); - if (id) { - eids.push({ - source: source, - uids: [{ - id: id, - atype: 1 - }] + if (utils.isArray(request.userIdAsEids) && request.userIdAsEids.length > 0) { + // later following white-list can be converted to block-list if needed + const requiredSourceValues = { + 'adserver.org': 1, + 'liveramp.com': 1, + 'criteo.com': 1, + 'id5-sync.com': 1, + 'parrable.com': 1, + 'digitru.st': 1, + 'liveintent.com': 1 + }; + request.userIdAsEids.forEach(function(eid) { + if (requiredSourceValues.hasOwnProperty(eid.source)) { + eids.push(eid); + } }); } + return eids; } /** @@ -355,13 +352,13 @@ function readStoredValue(key) { let storedValue; try { // check cookies first - storedValue = utils.getCookie(key); + storedValue = storage.getCookie(key); if (!storedValue) { // check expiration time before reading local storage - const storedValueExp = utils.getDataFromLocalStorage(`${key}_exp`); + const storedValueExp = storage.getDataFromLocalStorage(`${key}_exp`); if (storedValueExp === '' || (storedValueExp && (new Date(storedValueExp)).getTime() - Date.now() > 0)) { - storedValue = utils.getDataFromLocalStorage(key); + storedValue = storage.getDataFromLocalStorage(key); storedValue = storedValue ? decodeURIComponent(storedValue) : storedValue; } } diff --git a/modules/conversantBidAdapter.md b/modules/conversantBidAdapter.md index 5aba5653043..fba793adad2 100644 --- a/modules/conversantBidAdapter.md +++ b/modules/conversantBidAdapter.md @@ -38,6 +38,7 @@ var adUnits = [ site_id: '108060', api: [2], protocols: [1, 2], + white_label_url: 'https://web.hb.ad.cpe.dotomi.com/s2s/header/24', mimes: ['video/mp4'] } }] diff --git a/modules/cosmosBidAdapter.js b/modules/cosmosBidAdapter.js index 84131bfa131..73ee5c223b3 100644 --- a/modules/cosmosBidAdapter.js +++ b/modules/cosmosBidAdapter.js @@ -1,10 +1,10 @@ -import { registerBidder } from '../src/adapters/bidderFactory'; -import { BANNER, VIDEO } from '../src/mediaTypes'; -import * as utils from '../src/utils'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { BANNER, VIDEO } from '../src/mediaTypes.js'; +import * as utils from '../src/utils.js'; 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 84b76cbbc35..6146e704448 100644 --- a/modules/cpmstarBidAdapter.js +++ b/modules/cpmstarBidAdapter.js @@ -1,13 +1,13 @@ -import * as utils from '../src/utils'; -import { registerBidder } from '../src/adapters/bidderFactory'; -import {VIDEO, BANNER} from '../src/mediaTypes'; +import * as utils from '../src/utils.js'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import {VIDEO, BANNER} from '../src/mediaTypes.js'; 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/criteoBidAdapter.js b/modules/criteoBidAdapter.js index 7f292c76e20..5d137c994fe 100644 --- a/modules/criteoBidAdapter.js +++ b/modules/criteoBidAdapter.js @@ -1,34 +1,32 @@ -import { loadExternalScript } from '../src/adloader'; -import { registerBidder } from '../src/adapters/bidderFactory'; -import { config } from '../src/config'; -import { BANNER, VIDEO } from '../src/mediaTypes'; -import { parse } from '../src/url'; -import * as utils from '../src/utils'; -import find from 'core-js/library/fn/array/find'; -import JSEncrypt from 'jsencrypt/bin/jsencrypt'; -import sha256 from 'crypto-js/sha256'; - -export const ADAPTER_VERSION = 23; +import { loadExternalScript } from '../src/adloader.js'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { config } from '../src/config.js'; +import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js'; +import * as utils from '../src/utils.js'; +import find from 'core-js/library/fn/array/find.js'; +import { verify } from 'criteo-direct-rsa-validate/build/verify.js'; +import { getStorageManager } from '../src/storageManager.js'; + +const GVLID = 91; +export const ADAPTER_VERSION = 29; const BIDDER_CODE = 'criteo'; const CDB_ENDPOINT = 'https://bidder.criteo.com/cdb'; -const CRITEO_VENDOR_ID = 91; const PROFILE_ID_INLINE = 207; export const PROFILE_ID_PUBLISHERTAG = 185; +const storage = getStorageManager(GVLID); +const LOG_PREFIX = 'Criteo: '; // Unminified source code can be found in: https://github.com/Prebid-org/prebid-js-external-js-criteo/blob/master/dist/prod.js -const PUBLISHER_TAG_URL = '//static.criteo.net/js/ld/publishertag.prebid.js'; +const PUBLISHER_TAG_URL = 'https://static.criteo.net/js/ld/publishertag.prebid.js'; -export const FAST_BID_PUBKEY = `-----BEGIN PUBLIC KEY----- -MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDO1BjAITkFTtP0IMzmF7qsqhpu -y1dGaTPHnjMU9mRZsrnfR3C0sEN5pYEzEcFRPnkJjJuhH8Rnh5+CE+LcKg0Z8ZZ7 -OmOSj0/qnYTAYCu0cR5LiyWG79KlIgUyMbp92ulGg24gAyGrVn4+v/4c53WlOEUp -4YWvb82G0CD5NcDNpQIDAQAB ------END PUBLIC KEY-----`; +const FAST_BID_PUBKEY_E = 65537; +const FAST_BID_PUBKEY_N = 'ztQYwCE5BU7T9CDM5he6rKoabstXRmkzx54zFPZkWbK530dwtLBDeaWBMxHBUT55CYyboR/EZ4efghPi3CoNGfGWezpjko9P6p2EwGArtHEeS4slhu/SpSIFMjG6fdrpRoNuIAMhq1Z+Pr/+HOd1pThFKeGFr2/NhtAg+TXAzaU='; /** @type {BidderSpec} */ export const spec = { code: BIDDER_CODE, - supportedMediaTypes: [ BANNER, VIDEO ], + gvlid: GVLID, + supportedMediaTypes: [ BANNER, VIDEO, NATIVE ], /** * @param {object} bid @@ -59,7 +57,11 @@ export const spec = { let url; let data; - Object.assign(bidderRequest, { ceh: config.getConfig('criteo.ceh') }); + Object.assign(bidderRequest, { + publisherExt: config.getConfig('fpd.context'), + userExt: config.getConfig('fpd.user'), + ceh: config.getConfig('criteo.ceh') + }); // If publisher tag not already loaded try to get it from fast bid if (!publisherTagAvailable()) { @@ -75,7 +77,12 @@ export const spec = { } if (publisherTagAvailable()) { + // eslint-disable-next-line no-undef const adapter = new Criteo.PubTag.Adapters.Prebid(PROFILE_ID_PUBLISHERTAG, ADAPTER_VERSION, bidRequests, bidderRequest, '$prebid.version$'); + const enableSendAllBids = config.getConfig('enableSendAllBids'); + if (adapter.setEnableSendAllBids && typeof adapter.setEnableSendAllBids === 'function' && typeof enableSendAllBids === 'boolean') { + adapter.setEnableSendAllBids(enableSendAllBids); + } url = adapter.buildCdbUrl(); data = adapter.buildCdbRequest(); } else { @@ -98,6 +105,7 @@ export const spec = { const body = response.body || response; if (publisherTagAvailable()) { + // eslint-disable-next-line no-undef const adapter = Criteo.PubTag.Adapters.Prebid.GetAdapter(request); if (adapter) { return adapter.interpretResponse(body, request); @@ -121,9 +129,16 @@ export const spec = { width: slot.width, height: slot.height, dealId: slot.dealCode, - } + }; if (slot.native) { - bid.ad = createNativeAd(bidId, slot.native, bidRequest.params.nativeCallback); + if (bidRequest.params.nativeCallback) { + bid.ad = createNativeAd(bidId, slot.native, bidRequest.params.nativeCallback); + } else if (config.getConfig('enableSendAllBids') === true) { + return; + } else { + bid.native = createPrebidNativeAd(slot.native); + bid.mediaType = NATIVE; + } } else if (slot.video) { bid.vastUrl = slot.displayurl; bid.mediaType = VIDEO; @@ -142,6 +157,7 @@ export const spec = { */ onTimeout: (timeoutData) => { if (publisherTagAvailable()) { + // eslint-disable-next-line no-undef const adapter = Criteo.PubTag.Adapters.Prebid.GetAdapter(timeoutData.auctionId); adapter.handleBidTimeout(); } @@ -152,6 +168,7 @@ export const spec = { */ onBidWon: (bid) => { if (publisherTagAvailable()) { + // eslint-disable-next-line no-undef const adapter = Criteo.PubTag.Adapters.Prebid.GetAdapter(bid.auctionId); adapter.handleBidWon(bid); } @@ -162,6 +179,7 @@ export const spec = { */ onSetTargeting: (bid) => { if (publisherTagAvailable()) { + // eslint-disable-next-line no-undef const adapter = Criteo.PubTag.Adapters.Prebid.GetAdapter(bid.auctionId); adapter.handleSetTargeting(bid); } @@ -172,20 +190,20 @@ export const spec = { * @return {boolean} */ function publisherTagAvailable() { + // eslint-disable-next-line no-undef return typeof Criteo !== 'undefined' && Criteo.PubTag && Criteo.PubTag.Adapters && Criteo.PubTag.Adapters.Prebid; } /** * @param {BidRequest[]} bidRequests * @param bidderRequest - * @return {CriteoContext} */ function buildContext(bidRequests, bidderRequest) { let referrer = ''; if (bidderRequest && bidderRequest.refererInfo) { referrer = bidderRequest.refererInfo.referer; } - const queryString = parse(referrer).search; + const queryString = utils.parseUrl(referrer).search; const context = { url: referrer, @@ -198,7 +216,7 @@ function buildContext(bidRequests, bidderRequest) { if (bidRequest.params.integrationMode === 'amp') { context.amp = true; } - }) + }); return context; } @@ -227,9 +245,20 @@ function buildCdbUrl(context) { return url; } +function checkNativeSendId(bidRequest) { + return !(bidRequest.nativeParams && + ((bidRequest.nativeParams.image && bidRequest.nativeParams.image.sendId !== true) || + (bidRequest.nativeParams.icon && bidRequest.nativeParams.icon.sendId !== true) || + (bidRequest.nativeParams.clickUrl && bidRequest.nativeParams.clickUrl.sendId !== true) || + (bidRequest.nativeParams.displayUrl && bidRequest.nativeParams.displayUrl.sendId !== true) || + (bidRequest.nativeParams.privacyLink && bidRequest.nativeParams.privacyLink.sendId !== true) || + (bidRequest.nativeParams.privacyIcon && bidRequest.nativeParams.privacyIcon.sendId !== true))); +} + /** * @param {CriteoContext} context * @param {BidRequest[]} bidRequests + * @param bidderRequest * @return {*} */ function buildCdbRequest(context, bidRequests, bidderRequest) { @@ -237,6 +266,7 @@ function buildCdbRequest(context, bidRequests, bidderRequest) { const request = { publisher: { url: context.url, + ext: bidderRequest.publisherExt }, slots: bidRequests.map(bidRequest => { networkId = bidRequest.params.networkId || networkId; @@ -249,11 +279,20 @@ function buildCdbRequest(context, bidRequests, bidderRequest) { if (bidRequest.params.zoneId) { slot.zoneid = bidRequest.params.zoneId; } + if (bidRequest.fpd && bidRequest.fpd.context) { + slot.ext = bidRequest.fpd.context; + } + if (bidRequest.params.ext) { + slot.ext = Object.assign({}, slot.ext, bidRequest.params.ext); + } if (bidRequest.params.publisherSubId) { slot.publishersubid = bidRequest.params.publisherSubId; } - if (bidRequest.params.nativeCallback) { + if (bidRequest.params.nativeCallback || utils.deepAccess(bidRequest, `mediaTypes.${NATIVE}`)) { slot.native = true; + if (!checkNativeSendId(bidRequest)) { + utils.logWarn(LOG_PREFIX + 'all native assets containing URL should be sent as placeholders with sendId(icon, image, clickUrl, displayUrl, privacyLink, privacyIcon)'); + } } if (hasVideoMediaType(bidRequest)) { const video = { @@ -262,7 +301,7 @@ function buildCdbRequest(context, bidRequests, bidderRequest) { protocols: bidRequest.mediaTypes.video.protocols, maxduration: bidRequest.mediaTypes.video.maxduration, api: bidRequest.mediaTypes.video.api - } + }; video.skip = bidRequest.params.video.skip; video.placement = bidRequest.params.video.placement; @@ -278,7 +317,9 @@ function buildCdbRequest(context, bidRequests, bidderRequest) { if (networkId) { request.publisher.networkid = networkId; } - request.user = {}; + request.user = { + ext: bidderRequest.userExt + }; if (bidderRequest && bidderRequest.ceh) { request.user.ceh = bidderRequest.ceh; } @@ -287,14 +328,14 @@ function buildCdbRequest(context, bidRequests, bidderRequest) { if (typeof bidderRequest.gdprConsent.gdprApplies !== 'undefined') { request.gdprConsent.gdprApplies = !!(bidderRequest.gdprConsent.gdprApplies); } - if (bidderRequest.gdprConsent.vendorData && bidderRequest.gdprConsent.vendorData.vendorConsents && - typeof bidderRequest.gdprConsent.vendorData.vendorConsents[ CRITEO_VENDOR_ID.toString(10) ] !== 'undefined') { - request.gdprConsent.consentGiven = !!(bidderRequest.gdprConsent.vendorData.vendorConsents[ CRITEO_VENDOR_ID.toString(10) ]); - } + request.gdprConsent.version = bidderRequest.gdprConsent.apiVersion; if (typeof bidderRequest.gdprConsent.consentString !== 'undefined') { request.gdprConsent.consentData = bidderRequest.gdprConsent.consentString; } } + if (bidderRequest && bidderRequest.uspConsent) { + request.user.uspIab = bidderRequest.uspConsent; + } return request; } @@ -358,6 +399,27 @@ function hasValidVideoMediaType(bidRequest) { return false; } +/** + * Create prebid compatible native ad with native payload + * @param {*} payload + * @returns prebid native ad assets + */ +function createPrebidNativeAd(payload) { + return { + title: payload.products[0].title, + body: payload.products[0].description, + sponsoredBy: payload.advertiser.description, + icon: payload.advertiser.logo, + image: payload.products[0].image, + clickUrl: payload.products[0].click_url, + privacyLink: payload.privacy.optout_click_url, + privacyIcon: payload.privacy.optout_image_url, + cta: payload.products[0].call_to_action, + price: payload.products[0].price, + impressionTrackers: payload.impression_pixels.map(pix => pix.url) + }; +} + /** * @param {string} id * @param {*} payload @@ -366,32 +428,29 @@ function hasValidVideoMediaType(bidRequest) { */ function createNativeAd(id, payload, callback) { // Store the callback and payload in a global object to be later accessed from the creative - window.criteo_prebid_native_slots = window.criteo_prebid_native_slots || {}; - window.criteo_prebid_native_slots[id] = { callback, payload }; + var slotsName = 'criteo_prebid_native_slots'; + window[slotsName] = window[slotsName] || {}; + window[slotsName][id] = { callback, payload }; // The creative is in an iframe so we have to get the callback and payload // from the parent window (doesn't work with safeframes) - return ``; + return ` +`; } -/** - * @return {boolean} - */ export function tryGetCriteoFastBid() { try { const fastBidStorageKey = 'criteo_fast_bid'; const hashPrefix = '// Hash: '; - const fastBidFromStorage = localStorage.getItem(fastBidStorageKey); + const fastBidFromStorage = storage.getDataFromLocalStorage(fastBidStorageKey); if (fastBidFromStorage !== null) { // The value stored must contain the file's encrypted hash as first line @@ -400,20 +459,21 @@ export function tryGetCriteoFastBid() { if (firstLine.substr(0, hashPrefix.length) !== hashPrefix) { utils.logWarn('No hash found in FastBid'); - localStorage.removeItem(fastBidStorageKey); + storage.removeDataFromLocalStorage(fastBidStorageKey); } else { // Remove the hash part from the locally stored value const publisherTagHash = firstLine.substr(hashPrefix.length); const publisherTag = fastBidFromStorage.substr(firstLineEndPosition + 1); - var jsEncrypt = new JSEncrypt(); - jsEncrypt.setPublicKey(FAST_BID_PUBKEY); - if (jsEncrypt.verify(publisherTag, publisherTagHash, sha256)) { + if (verify(publisherTag, publisherTagHash, FAST_BID_PUBKEY_N, FAST_BID_PUBKEY_E)) { utils.logInfo('Using Criteo FastBid'); - eval(publisherTag); // eslint-disable-line no-eval + const script = document.createElement('script'); + script.type = 'text/javascript'; + script.text = publisherTag; + utils.insertElement(script); } else { utils.logWarn('Invalid Criteo FastBid found'); - localStorage.removeItem(fastBidStorageKey); + storage.removeDataFromLocalStorage(fastBidStorageKey); } } } diff --git a/modules/criteoIdSystem.js b/modules/criteoIdSystem.js index fe89de5d341..c44f0c843ae 100644 --- a/modules/criteoIdSystem.js +++ b/modules/criteoIdSystem.js @@ -5,11 +5,13 @@ * @requires module:modules/userId */ -import * as utils from '../src/utils' -import * as ajax from '../src/ajax' -import * as urlLib from '../src/url' -import { getRefererInfo } from '../src/refererDetection' -import { submodule } from '../src/hook'; +import * as utils from '../src/utils.js' +import * as ajax from '../src/ajax.js' +import { getRefererInfo } from '../src/refererDetection.js' +import { submodule } from '../src/hook.js'; +import { getStorageManager } from '../src/storageManager.js'; + +export const storage = getStorageManager(); const bididStorageKey = 'cto_bidid'; const bundleStorageKey = 'cto_bundle'; @@ -20,33 +22,33 @@ const pastDateString = new Date(0).toString(); const expirationString = new Date(utils.timestamp() + cookiesMaxAge).toString(); function areCookiesWriteable() { - utils.setCookie(cookieWriteableKey, '1'); - const canWrite = utils.getCookie(cookieWriteableKey) === '1'; - utils.setCookie(cookieWriteableKey, '', pastDateString); + storage.setCookie(cookieWriteableKey, '1'); + const canWrite = storage.getCookie(cookieWriteableKey) === '1'; + storage.setCookie(cookieWriteableKey, '', pastDateString); return canWrite; } function extractProtocolHost (url, returnOnlyHost = false) { - const parsedUrl = urlLib.parse(url) + const parsedUrl = utils.parseUrl(url) return returnOnlyHost ? `${parsedUrl.hostname}` : `${parsedUrl.protocol}://${parsedUrl.hostname}${parsedUrl.port ? ':' + parsedUrl.port : ''}/`; } function getFromAllStorages(key) { - return utils.getCookie(key) || utils.getDataFromLocalStorage(key); + return storage.getCookie(key) || storage.getDataFromLocalStorage(key); } function saveOnAllStorages(key, value) { if (key && value) { - utils.setCookie(key, value, expirationString); - utils.setDataInLocalStorage(key, value); + storage.setCookie(key, value, expirationString); + storage.setDataInLocalStorage(key, value); } } function deleteFromAllStorages(key) { - utils.setCookie(key, '', pastDateString); - utils.removeDataFromLocalStorage(key); + storage.setCookie(key, '', pastDateString); + storage.removeDataFromLocalStorage(key); } function getCriteoDataFromAllStorages() { @@ -56,18 +58,19 @@ function getCriteoDataFromAllStorages() { } } -function buildCriteoUsersyncUrl(topUrl, domain, bundle, areCookiesWriteable, isPublishertagPresent) { +function buildCriteoUsersyncUrl(topUrl, domain, bundle, areCookiesWriteable, isPublishertagPresent, gdprString) { const url = 'https://gum.criteo.com/sid/json?origin=prebid' + `${topUrl ? '&topUrl=' + encodeURIComponent(topUrl) : ''}` + `${domain ? '&domain=' + encodeURIComponent(domain) : ''}` + `${bundle ? '&bundle=' + encodeURIComponent(bundle) : ''}` + + `${gdprString ? '&gdprString=' + encodeURIComponent(gdprString) : ''}` + `${areCookiesWriteable ? '&cw=1' : ''}` + `${isPublishertagPresent ? '&pbt=1' : ''}` return url; } -function callCriteoUserSync(parsedCriteoData) { +function callCriteoUserSync(parsedCriteoData, gdprString) { const cw = areCookiesWriteable(); const topUrl = extractProtocolHost(getRefererInfo().referer); const domain = extractProtocolHost(document.location.href, true); @@ -78,7 +81,8 @@ function callCriteoUserSync(parsedCriteoData) { domain, parsedCriteoData.bundle, cw, - isPublishertagPresent + isPublishertagPresent, + gdprString ); ajax.ajaxBuilder()( @@ -119,11 +123,16 @@ export const criteoIdSubmodule = { /** * get the Criteo Id from local storages and initiate a new user sync * @function + * @param {SubmoduleParams} [configParams] + * @param {ConsentData} [consentData] * @returns {{id: {criteoId: string} | undefined}}} */ - getId() { + getId(configParams, consentData) { + const hasGdprData = consentData && typeof consentData.gdprApplies === 'boolean' && consentData.gdprApplies; + const gdprConsentString = hasGdprData ? consentData.consentString : undefined; + let localData = getCriteoDataFromAllStorages(); - callCriteoUserSync(localData); + callCriteoUserSync(localData, gdprConsentString); return { id: localData.bidId ? { criteoId: localData.bidId } : undefined } } diff --git a/modules/criteortusIdSystem.js b/modules/criteortusIdSystem.js deleted file mode 100644 index 8486bfae9f3..00000000000 --- a/modules/criteortusIdSystem.js +++ /dev/null @@ -1,106 +0,0 @@ -/** - * This module adds Criteo Real Time User Sync to the User ID module - * The {@link module:modules/userId} module is required - * @module modules/criteortusIdSystem - * @requires module:modules/userId - */ - -import * as utils from '../src/utils' -import { ajax } from '../src/ajax'; -import { submodule } from '../src/hook'; - -const key = '__pbjs_criteo_rtus'; - -/** @type {Submodule} */ -export const criteortusIdSubmodule = { - /** - * used to link submodule with config - * @type {string} - */ - name: 'criteortus', - /** - * decode the stored id value for passing to bid requests - * @function - * @returns {{criteortus:Object}} - */ - decode() { - let uid = utils.getCookie(key); - try { - uid = JSON.parse(uid); - return { 'criteortus': uid }; - } catch (error) { - utils.logError('Error in parsing criteo rtus data', error); - } - }, - /** - * performs action to obtain id and return a value in the callback's response argument - * @function - * @param {SubmoduleParams} [configParams] - * @returns {IdResponse|undefined} - */ - getId(configParams) { - if (!configParams || !utils.isPlainObject(configParams.clientIdentifier)) { - utils.logError('User ID - Criteo rtus requires client identifier to be defined'); - return; - } - - let uid = utils.getCookie(key); - if (uid) { - return {id: uid}; - } else { - let userIds = {}; - const resp = function(callback) { - let bidders = Object.keys(configParams.clientIdentifier); - - function afterAllResponses() { - // criteo rtus user id expires in 1 hour - const expiresStr = (new Date(Date.now() + (60 * 60 * 1000))).toUTCString(); - utils.setCookie(key, JSON.stringify(userIds), expiresStr); - callback(userIds); - } - - const onResponse = utils.delayExecution(afterAllResponses, bidders.length); - - bidders.forEach((bidder) => { - let url = `https://gum.criteo.com/sync?c=${configParams.clientIdentifier[bidder]}&r=3`; - const getSuccessHandler = (bidder) => { - return function onSuccess(response) { - if (response) { - try { - response = JSON.parse(response); - userIds[bidder] = response; - onResponse(); - } catch (error) { - utils.logError(error); - } - } - } - } - - const getFailureHandler = (bidder) => { - return function onFailure(error) { - utils.logError(`Criteo RTUS server call failed for ${bidder}`, error); - onResponse(); - } - } - - ajax( - url, - { - success: getSuccessHandler(bidder), - error: getFailureHandler(bidder) - }, - undefined, - Object.assign({ - method: 'GET', - withCredentials: true - }) - ); - }) - }; - return {callback: resp}; - } - } -}; - -submodule('userId', criteortusIdSubmodule); diff --git a/modules/currency.js b/modules/currency.js index 28e033fb1a2..0464d9b5cdb 100644 --- a/modules/currency.js +++ b/modules/currency.js @@ -1,8 +1,9 @@ -import { createBid } from '../src/bidfactory'; -import { STATUS } from '../src/constants'; -import { ajax } from '../src/ajax'; -import * as utils from '../src/utils'; -import { config } from '../src/config'; +import { getGlobal } from '../src/prebidGlobal.js'; +import { createBid } from '../src/bidfactory.js'; +import { STATUS } from '../src/constants.json'; +import { ajax } from '../src/ajax.js'; +import * as utils from '../src/utils.js'; +import { config } from '../src/config.js'; import { getHook } from '../src/hook.js'; const DEFAULT_CURRENCY_RATE_URL = 'https://cdn.jsdelivr.net/gh/prebid/currency-file@1/latest.json?date=$$TODAY$$'; @@ -122,6 +123,8 @@ function initCurrency(url) { utils.logInfo('Installing addBidResponse decorator for currency module', arguments); + // Adding conversion function to prebid global for external module and on page use + getGlobal().convertCurrency = (cpm, fromCurrency, toCurrency) => parseFloat(cpm) * getCurrencyConversion(fromCurrency, toCurrency); getHook('addBidResponse').before(addBidResponseHook, 100); // call for the file if we haven't already @@ -149,6 +152,7 @@ function resetCurrency() { utils.logInfo('Uninstalling addBidResponse decorator for currency module', arguments); getHook('addBidResponse').getHooks({hook: addBidResponseHook}).remove(); + delete getGlobal().convertCurrency; adServerCurrency = 'USD'; conversionCache = {}; diff --git a/modules/customIdSystem.js b/modules/customIdSystem.js index 5133797dcb4..d10db8b262e 100644 --- a/modules/customIdSystem.js +++ b/modules/customIdSystem.js @@ -5,8 +5,8 @@ * @requires module:modules/userId */ -import * as utils from '../src/utils'; -import {submodule} from '../src/hook'; +import * as utils from '../src/utils.js'; +import {submodule} from '../src/hook.js'; /** @type {Submodule} */ export const customIdSubmodule = { diff --git a/modules/dailyhuntBidAdapter.js b/modules/dailyhuntBidAdapter.js index bcad7679c4f..5b28f086938 100644 --- a/modules/dailyhuntBidAdapter.js +++ b/modules/dailyhuntBidAdapter.js @@ -1,6 +1,6 @@ -import { registerBidder } from '../src/adapters/bidderFactory'; -import * as mediaTypes from '../src/mediaTypes'; -import * as utils from '../src/utils'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import * as mediaTypes from '../src/mediaTypes.js'; +import * as utils from '../src/utils.js'; const BIDDER_CODE = 'dailyhunt'; const BIDDER_ALIAS = 'dh'; diff --git a/modules/danmarketBidAdapter.js b/modules/danmarketBidAdapter.js deleted file mode 100644 index 77f90f43319..00000000000 --- 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/datablocksAnalyticsAdapter.js b/modules/datablocksAnalyticsAdapter.js index 76dd490180b..5e977155284 100644 --- a/modules/datablocksAnalyticsAdapter.js +++ b/modules/datablocksAnalyticsAdapter.js @@ -2,8 +2,8 @@ * Analytics Adapter for Datablocks */ -import adapter from '../src/AnalyticsAdapter'; -import adapterManager from '../src/adapterManager'; +import adapter from '../src/AnalyticsAdapter.js'; +import adapterManager from '../src/adapterManager.js'; var datablocksAdapter = adapter({ global: 'datablocksAnalytics', diff --git a/modules/datablocksBidAdapter.js b/modules/datablocksBidAdapter.js index 3e9bf219c75..b00a3eae659 100644 --- a/modules/datablocksBidAdapter.js +++ b/modules/datablocksBidAdapter.js @@ -1,7 +1,6 @@ -import * as utils from '../src/utils'; -import { registerBidder } from '../src/adapters/bidderFactory'; -import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes'; -import { parse as parseUrl } from '../src/url'; +import * as utils from '../src/utils.js'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js'; const NATIVE_MAP = { 'body': 2, 'body2': 10, @@ -61,7 +60,7 @@ export const spec = { let imps = {}; let site = {}; let device = {}; - let refurl = parseUrl(bidderRequest.referrer); + let refurl = utils.parseUrl(bidderRequest.referrer); let requests = []; validBidRequests.forEach(bidRequest => { @@ -232,7 +231,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 65d3032d3f8..00000000000 --- 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/deepintentBidAdapter.js b/modules/deepintentBidAdapter.js index 39866086cfa..d72477a582a 100644 --- a/modules/deepintentBidAdapter.js +++ b/modules/deepintentBidAdapter.js @@ -1,9 +1,9 @@ -import {registerBidder} from '../src/adapters/bidderFactory'; -import {BANNER} from '../src/mediaTypes'; -import * as utils from '../src/utils'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; +import {BANNER} from '../src/mediaTypes.js'; +import * as utils from '../src/utils.js'; const BIDDER_CODE = 'deepintent'; const BIDDER_ENDPOINT = 'https://prebid.deepintent.com/prebid'; -const USER_SYNC_URL = 'https://beacon.deepintent.com/usersync.html'; +const USER_SYNC_URL = 'https://cdn.deepintent.com/syncpixel.html'; const DI_M_V = '1.0.0'; export const spec = { code: BIDDER_CODE, @@ -37,9 +37,13 @@ export const spec = { imp: validBidRequests.map(bid => buildImpression(bid)), site: buildSite(bidderRequest), device: buildDevice(), - user: user && user.length == 1 ? user[0] : {} + user: user && user.length === 1 ? user[0] : {} }; + if (bidderRequest && bidderRequest.uspConsent) { + utils.deepSetValue(openRtbBidRequest, 'regs.ext.us_privacy', bidderRequest.uspConsent); + } + return { method: 'POST', url: BIDDER_ENDPOINT, @@ -127,13 +131,15 @@ function buildBanner(bid) { if (utils.isArray(sizes) && sizes.length > 0) { return { h: sizes[0][1], - w: sizes[0][0] + w: sizes[0][0], + pos: bid && bid.params && bid.params.pos ? bid.params.pos : 0 } } } else { return { h: bid.params.height, - w: bid.params.width + w: bid.params.width, + pos: bid && bid.params && bid.params.pos ? bid.params.pos : 0 } } } diff --git a/modules/deepintentBidAdapter.md b/modules/deepintentBidAdapter.md index 7f5afbd233a..79a6a1679e2 100644 --- a/modules/deepintentBidAdapter.md +++ b/modules/deepintentBidAdapter.md @@ -29,6 +29,7 @@ Module that connects to Deepintent's demand sources. tagId: '1300', // Required parameter w: 300, // Width and Height here will override sizes in mediatype h: 250, + pos: 1, custom: { // Custom parameters in form of key value pairs user_min_age: 18 } diff --git a/modules/dfpAdServerVideo.js b/modules/dfpAdServerVideo.js index c3f867308d1..031d46c52d0 100644 --- a/modules/dfpAdServerVideo.js +++ b/modules/dfpAdServerVideo.js @@ -2,13 +2,12 @@ * This module adds [DFP support]{@link https://www.doubleclickbygoogle.com/} for Video to Prebid. */ -import { registerVideoSupport } from '../src/adServerManager'; -import { targeting } from '../src/targeting'; -import { formatQS, format as buildUrl, parse } from '../src/url'; -import { deepAccess, isEmpty, logError, parseSizesInput } from '../src/utils'; -import { config } from '../src/config'; -import { getHook, submodule } from '../src/hook'; -import { auctionManager } from '../src/auctionManager'; +import { registerVideoSupport } from '../src/adServerManager.js'; +import { targeting } from '../src/targeting.js'; +import { deepAccess, isEmpty, logError, parseSizesInput, formatQS, parseUrl, buildUrl } from '../src/utils.js'; +import { config } from '../src/config.js'; +import { getHook, submodule } from '../src/hook.js'; +import { auctionManager } from '../src/auctionManager.js'; /** * @typedef {Object} DfpVideoParams @@ -74,7 +73,7 @@ export function buildDfpVideoUrl(options) { if (options.url) { // when both `url` and `params` are given, parsed url will be overwriten // with any matching param components - urlComponents = parse(options.url, {noDecodeWholeURL: true}); + urlComponents = parseUrl(options.url, {noDecodeWholeURL: true}); if (isEmpty(options.params)) { return buildUrlFromAdserverUrlComponents(urlComponents, bid, options); @@ -256,6 +255,13 @@ function getCustParams(bid, options) { adserverTargeting, optCustParams, ); + // TODO : Remove below function and change the constant value in file to update the key names for video + // Changing few key name might have impact on banner as well as we ignore few key names , hence using below function + // to get the cust_params that should be attached to dfp. + // It will also handle the send allBids cases + if (window.PWT && window.PWT.getCustomParamsForDFPVideo) { + customParams = window.PWT.getCustomParamsForDFPVideo(optCustParams, bid); + } return encodeURIComponent(formatQS(customParams)); } diff --git a/modules/dgadsBidAdapter.js b/modules/dgadsBidAdapter.js deleted file mode 100644 index c8a97d86990..00000000000 --- 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/digiTrustIdSystem.js b/modules/digiTrustIdSystem.js index 89557e0917e..d8aa8be9376 100644 --- a/modules/digiTrustIdSystem.js +++ b/modules/digiTrustIdSystem.js @@ -9,9 +9,13 @@ * @requires module:modules/userId */ -import * as utils from '../src/utils' -import { ajax } from '../src/ajax'; -import { submodule } from '../src/hook'; +import * as utils from '../src/utils.js' +import { ajax } from '../src/ajax.js'; +import { submodule } from '../src/hook.js'; +import { getStorageManager } from '../src/storageManager.js'; + +const DT_VENDOR_ID = 64; // cmp gvlVendorId +const storage = getStorageManager(DT_VENDOR_ID); var fallbackTimeout = 1550; // timeout value that allows userId system to execute first var fallbackTimer = 0; // timer Id for fallback init so we don't double call @@ -24,6 +28,7 @@ function isInitialized() { if (window.DigiTrust == null) { return false; } + // eslint-disable-next-line no-undef return DigiTrust.isClient; // this is set to true after init } @@ -44,7 +49,14 @@ var isFunc = function (fn) { return typeof (fn) === 'function'; } +var _savedId = null; // closure variable for storing Id to avoid additional requests + function callApi(options) { + var ajaxOptions = { + method: 'GET', + withCredentials: true + }; + ajax( DT_ID_SVC, { @@ -52,9 +64,7 @@ function callApi(options) { error: options.fail }, null, - { - method: 'GET' - } + ajaxOptions ); } @@ -67,7 +77,7 @@ function encId(id) { if (typeof (id) !== 'string') { id = JSON.stringify(id); } - return encodeURIComponent(btoa(id)); + return btoa(id); } catch (ex) { return id; } @@ -81,8 +91,32 @@ function writeDigiId(id) { var key = 'DigiTrust.v1.identity'; var date = new Date(); date.setTime(date.getTime() + 604800000); - var exp = 'expires=' + date.toUTCString(); - document.cookie = key + '=' + encId(id) + '; ' + exp + '; path=/;SameSite=none;'; + storage.setCookie(key, encId(id), date.toUTCString(), 'none'); +} + +/** + * Tests to see if the current browser is FireFox + */ +function isFirefoxBrowser(ua) { + ua = ua || navigator.userAgent; + ua = ua.toLowerCase(); + if (ua.indexOf('firefox') !== -1) { + return true; + } + return false; +} + +/** + * Test to see if the user has a browser that is disallowed for making AJAX + * requests due to the behavior not supported DigiTrust ID Cookie. + */ +function isDisallowedBrowserForApiCall() { + if (utils.isSafariBrowser()) { + return true; + } else if (isFirefoxBrowser()) { + return true; + } + return false; } /** @@ -90,8 +124,6 @@ function writeDigiId(id) { * */ function initDigitrustFacade(config) { - var _savedId = null; // closure variable for storing Id to avoid additional requests - clearTimeout(fallbackTimer); fallbackTimer = 0; @@ -110,17 +142,17 @@ function initDigitrustFacade(config) { inter.callCount++; // wrap the initializer callback, if present - var checkCallInitializeCb = function (idResponse) { + var checkAndCallInitializeCb = function (idResponse) { if (inter.callCount <= 1 && isFunc(inter.initCallback)) { try { inter.initCallback(idResponse); } catch (ex) { - utils.logError('Exception in passed DigiTrust init callback'); + utils.logError('Exception in passed DigiTrust init callback', ex); } } } - if (!isMemberIdValid) { + if (!isMemberIdValid(obj.member)) { if (!isAsync) { return errResp } else { @@ -130,9 +162,9 @@ function initDigitrustFacade(config) { } if (_savedId != null) { - checkCallInitializeCb(_savedId); if (isAsync) { - cb(_savedId); + checkAndCallInitializeCb(_savedId); + // cb(_savedId); return; } else { return _savedId; @@ -145,21 +177,34 @@ function initDigitrustFacade(config) { success: true } try { - writeDigiId(respText); idResult.identity = JSON.parse(respText); - _savedId = idResult; + _savedId = idResult; // Save result to the cache variable + writeDigiId(respText); } catch (ex) { idResult.success = false; + delete idResult.identity; } - checkCallInitializeCb(idResult); - cb(idResult); + checkAndCallInitializeCb(idResult); }, fail: function (statusErr, result) { utils.logError('DigiTrustId API error: ' + statusErr); } } - callApi(opts); + // check gdpr vendor here. Full DigiTrust library has vendor check built in + gdprConsent.hasConsent(null, function (hasConsent) { + if (hasConsent) { + if (isDisallowedBrowserForApiCall()) { + let resultObj = { + success: false, + err: 'Your browser does not support DigiTrust Identity' + } + checkAndCallInitializeCb(resultObj); + return; + } + callApi(opts); + } + }) if (!isAsync) { return errResp; // even if it will be successful later, without a callback we report a "failure in this moment" @@ -189,6 +234,46 @@ var isMemberIdValid = function (memberId) { } }; +/** + * DigiTrust consent handler for GDPR and __cmp. + * */ +var gdprConsent = { + hasConsent: function (options, consentCb) { + options = options || { consentTimeout: 1500 }; + var stopTimer; + var processed = false; + var consentAnswer = false; + if (typeof (window.__cmp) !== 'undefined') { + stopTimer = setTimeout(function () { + consentAnswer = false; + processed = true; + consentCb(consentAnswer); + }, options.consentTimeout); + + window.__cmp('ping', null, function(pingAnswer) { + if (pingAnswer.gdprAppliesGlobally) { + window.__cmp('getVendorConsents', [DT_VENDOR_ID], function (result) { + if (processed) { return; } // timeout before cmp answer, cancel + clearTimeout(stopTimer); + var myconsent = result.vendorConsents[DT_VENDOR_ID]; + consentCb(myconsent); + }); + } else { + if (processed) { return; } // timeout before cmp answer, cancel + clearTimeout(stopTimer); + consentAnswer = true; + consentCb(consentAnswer); + } + }); + } else { + // __cmp library is not preset. + // ignore this check and rely on id system GDPR consent management + consentAnswer = true; + consentCb(consentAnswer); + } + } +} + /** * Encapsulation of needed info for the callback return. * @@ -207,6 +292,10 @@ var ResultWrapper = function (opts) { */ this.userIdCallback = function (callback) { idSystemFn = callback; + if (me.idObj == null) { + me.idObj = _savedId; + } + if (me.idObj != null && isFunc(callback)) { callback(wrapIdResult()); } @@ -216,6 +305,10 @@ var ResultWrapper = function (opts) { * Return a wrapped result formatted for userId system */ function wrapIdResult() { + if (me.idObj == null) { + me.idObj = _savedId; + } + if (me.idObj == null) { return null; } @@ -240,6 +333,7 @@ var ResultWrapper = function (opts) { this.retryId = 0; this.executeIdRequest = function (configParams) { + // eslint-disable-next-line no-undef DigiTrust.getUser({ member: 'prebid' }, function (idResult) { me.idObj = idResult; var cb = function () { @@ -321,6 +415,7 @@ export function surfaceTestHook() { } testHook.initDigitrustFacade = initDigitrustFacade; // expose for unit tests +testHook.gdpr = gdprConsent; /** @type {Submodule} */ export const digiTrustIdSubmodule = { diff --git a/modules/districtmDMXBidAdapter.js b/modules/districtmDMXBidAdapter.js index 205017066a8..03dca0b607d 100644 --- a/modules/districtmDMXBidAdapter.js +++ b/modules/districtmDMXBidAdapter.js @@ -1,6 +1,6 @@ -import * as utils from '../src/utils'; -import { registerBidder } from '../src/adapters/bidderFactory'; -import {config} from '../src/config'; +import * as utils from '../src/utils.js'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import {config} from '../src/config.js'; const BIDDER_CODE = 'districtmDMX'; @@ -27,6 +27,9 @@ export const spec = { nBid.requestId = nBid.impid; nBid.width = nBid.w || width; nBid.height = nBid.h || height; + if (nBid.dealid) { + nBid.dealId = nBid.dealid; + } nBid.ad = nBid.adm; nBid.netRevenue = true; nBid.creativeId = nBid.crid; @@ -69,6 +72,7 @@ export const spec = { publisher: { id: String(bidRequest[0].params.memberid) || null } } } + try { let params = config.getConfig('dmx'); dmxRequest.user = params.user || {}; @@ -77,6 +81,18 @@ export const spec = { } catch (e) { } + + let eids = []; + if (bidRequest && bidRequest.userId) { + bindUserId(eids, utils.deepAccess(bidRequest, `userId.idl_env`), 'liveramp.com', 1); + bindUserId(eids, utils.deepAccess(bidRequest, `userId.digitrustid.data.id`), 'digitru.st', 1); + bindUserId(eids, utils.deepAccess(bidRequest, `userId.id5id`), 'id5-sync.com', 1); + bindUserId(eids, utils.deepAccess(bidRequest, `userId.pubcid`), 'pubcid.org', 1); + bindUserId(eids, utils.deepAccess(bidRequest, `userId.tdid`), 'adserver.org', 1); + dmxRequest.user = dmxRequest.user || {}; + dmxRequest.user.ext = dmxRequest.user.ext || {}; + dmxRequest.user.ext.eids = eids; + } if (!dmxRequest.test) { delete dmxRequest.test; } @@ -88,6 +104,13 @@ export const spec = { dmxRequest.user.ext = {}; dmxRequest.user.ext.consent = bidderRequest.gdprConsent.consentString; } + dmxRequest.regs = dmxRequest.regs || {}; + dmxRequest.regs.coppa = config.getConfig('coppa') === true ? 1 : 0; + if (bidderRequest && bidderRequest.uspConsent) { + dmxRequest.regs = dmxRequest.regs || {}; + dmxRequest.regs.ext = dmxRequest.regs.ext || {}; + dmxRequest.regs.ext.us_privacy = bidderRequest.uspConsent; + } try { schain = bidRequest[0].schain; dmxRequest.source = {}; @@ -125,11 +148,22 @@ export const spec = { test() { return window.location.href.indexOf('dmTest=true') !== -1 ? 1 : 0; }, - getUserSyncs(optionsType) { + getUserSyncs(optionsType, serverResponses, gdprConsent, uspConsent) { + let query = []; + let url = 'https://cdn.districtm.io/ids/index.html' + if (gdprConsent && gdprConsent.gdprApplies && typeof gdprConsent.consentString === 'string') { + query.push(['gdpr', gdprConsent.consentString]) + } + if (uspConsent) { + query.push(['ccpa', uspConsent]) + } + if (query.length > 0) { + url += '?' + query.map(q => q.join('=')).join('&') + } if (optionsType.iframeEnabled) { return [{ type: 'iframe', - url: 'https://cdn.districtm.io/ids/index.html' + url: url }]; } } @@ -262,4 +296,18 @@ export function defaultSize(thebidObj) { returnObject.height = checkDeepArray(sizes)[1]; return returnObject; } + +export function bindUserId(eids, value, source, atype) { + if (utils.isStr(value) && Array.isArray(eids)) { + eids.push({ + source, + uids: [ + { + id: value, + atype + } + ] + }) + } +} registerBidder(spec); diff --git a/modules/districtmDmxBidAdapter.md b/modules/districtmDmxBidAdapter.md index 5bc1e5d5780..792cf2e7305 100644 --- a/modules/districtmDmxBidAdapter.md +++ b/modules/districtmDmxBidAdapter.md @@ -13,6 +13,8 @@ The `districtmDmxAdapter` module allows publishers to include DMX Exchange deman * Single Request * Multi-Size Support * GDPR Compliant +* CCPA Compliant +* COPPA Compliant * Bids returned in **NET** ## Media Types @@ -23,8 +25,8 @@ The `districtmDmxAdapter` module allows publishers to include DMX Exchange deman | Key | Scope | Type | Description | --- | --- | --- | --- -| dmxid | Mandatory | Integer | Unique identifier of the placement, dmxid can be obtained in the district m Boost platform. -| memberid | Mandatory | Integer | Unique identifier for your account, memberid can be obtained in the district m Boost platform. +| `dmxid` | Mandatory | Integer | Unique identifier of the placement, dmxid can be obtained in the district m Boost platform. +| `memberid` | Mandatory | Integer | Unique identifier for your account, memberid can be obtained in the district m Boost platform. # Ad Unit Configuration Example @@ -47,6 +49,9 @@ The `districtmDmxAdapter` module allows publishers to include DMX Exchange deman ``` +# Ad Unit Configuration when COPPA is needed + + # Quick Start Guide ###### 1. Including the `districtmDmxAdapter` in your build process. diff --git a/modules/djaxBidAdapter.js b/modules/djaxBidAdapter.js index 58f500d2a2b..ffaf61a3f15 100644 --- a/modules/djaxBidAdapter.js +++ b/modules/djaxBidAdapter.js @@ -1,14 +1,14 @@ -import { registerBidder } from '../src/adapters/bidderFactory'; -import { config } from '../src/config'; -import * as utils from '../src/utils'; -import {BANNER, VIDEO} from '../src/mediaTypes'; -import { ajax } from '../src/ajax'; -import {Renderer} from '../src/Renderer'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { config } from '../src/config.js'; +import * as utils from '../src/utils.js'; +import {BANNER, VIDEO} from '../src/mediaTypes.js'; +import { ajax } from '../src/ajax.js'; +import {Renderer} from '../src/Renderer.js'; 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 index a109bc612db..16764e76ede 100644 --- a/modules/dspxBidAdapter.js +++ b/modules/dspxBidAdapter.js @@ -1,9 +1,10 @@ -import * as utils from '../src/utils'; -import {config} from '../src/config'; -import {registerBidder} from '../src/adapters/bidderFactory'; +import * as utils from '../src/utils.js'; +import {config} from '../src/config.js'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; const BIDDER_CODE = 'dspx'; const ENDPOINT_URL = 'https://buyer.dspx.tv/request/'; +const ENDPOINT_URL_DEV = 'https://dcbuyer.dspx.tv/request/'; export const spec = { code: BIDDER_CODE, @@ -14,14 +15,17 @@ export const spec = { 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 referrer = encodeURIComponent(bidderRequest.refererInfo.referer); const bidId = bidRequest.bidId; + const isDev = params.devMode || false; + + let bannerSizes = utils.parseSizesInput(utils.deepAccess(bidRequest, 'mediaTypes.banner.sizes') || bidRequest.sizes); + let [width, height] = bannerSizes[0].split('x'); + + let endpoint = isDev ? ENDPOINT_URL_DEV : ENDPOINT_URL; + const payload = { _f: 'html', alternative: 'prebid_js', @@ -42,9 +46,12 @@ export const spec = { if (params.dvt !== undefined) { payload.dvt = params.dvt; } + if (isDev) { + payload.prebidDevMode = 1; + } return { method: 'GET', - url: ENDPOINT_URL, + url: endpoint, data: objectToQueryString(payload), } }); @@ -58,7 +65,6 @@ export const spec = { 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, @@ -68,8 +74,8 @@ export const spec = { dealId: dealId, currency: currency, netRevenue: netRevenue, + type: response.type, ttl: config.getConfig('_bidderTimeout'), - referrer: referrer, ad: response.adTag }; bidResponses.push(bidResponse); diff --git a/modules/dspxBidAdapter.md b/modules/dspxBidAdapter.md index 362f4fbcb69..9945dc5e6dd 100644 --- a/modules/dspxBidAdapter.md +++ b/modules/dspxBidAdapter.md @@ -8,7 +8,7 @@ Maintainer: prebid@dspx.tv # Description -Dspx adapter for Prebid.js 1.0 +Dspx adapter for Prebid.js 3.0 # Test Parameters ``` @@ -28,6 +28,7 @@ Dspx adapter for Prebid.js 1.0 bidder: "dspx", params: { placement: '101', + devMode: true, // if true: library uses dev server for tests pfilter: { floorprice: 1000000, // EUR * 1,000,000 private_auction: 1, // Is private auction? 0 - no, 1 - yes diff --git a/modules/e_volutionBidAdapter.js b/modules/e_volutionBidAdapter.js new file mode 100644 index 00000000000..9fc7035db32 --- /dev/null +++ b/modules/e_volutionBidAdapter.js @@ -0,0 +1,111 @@ +import {registerBidder} from '../src/adapters/bidderFactory.js'; +import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js'; +import * as utils from '../src/utils.js'; + +const BIDDER_CODE = 'e_volution'; +const AD_URL = 'https://service.e-volution.ai/?c=o&m=multi'; +const URL_SYNC = 'https://service.e-volution.ai/?c=o&m=sync'; +const NO_SYNC = true; + +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 && bid.native.title && bid.native.image && bid.native.impressionTrackers); + default: + return false; + } +} + +export const spec = { + code: BIDDER_CODE, + supportedMediaTypes: [BANNER, VIDEO, NATIVE], + noSync: NO_SYNC, + + isBidRequestValid: (bid) => { + return Boolean(bid.bidId && bid.params && !isNaN(parseInt(bid.params.placementId))); + }, + + buildRequests: (validBidRequests = [], bidderRequest) => { + let winTop = window; + let location; + try { + location = new URL(bidderRequest.refererInfo.referer) + winTop = window.top; + } catch (e) { + location = winTop.location; + utils.logMessage(e); + }; + let placements = []; + let request = { + 'deviceWidth': winTop.screen.width, + 'deviceHeight': winTop.screen.height, + 'language': (navigator && navigator.language) ? navigator.language.split('-')[0] : '', + 'secure': 1, + 'host': location.host, + 'page': location.pathname, + 'placements': placements + }; + if (bidderRequest) { + if (bidderRequest.uspConsent) { + request.ccpa = bidderRequest.uspConsent; + } + if (bidderRequest.gdprConsent) { + request.gdpr = bidderRequest.gdprConsent + } + } + const len = validBidRequests.length; + + for (let i = 0; i < len; i++) { + let bid = validBidRequests[i]; + let traff = bid.params.traffic || BANNER + + placements.push({ + placementId: bid.params.placementId, + bidId: bid.bidId, + sizes: bid.mediaTypes && bid.mediaTypes[traff] && bid.mediaTypes[traff].sizes ? bid.mediaTypes[traff].sizes : [], + traffic: traff + }); + if (bid.schain) { + placements.schain = bid.schain; + } + } + return { + method: 'POST', + url: AD_URL, + data: request + }; + }, + + interpretResponse: (serverResponse) => { + let response = []; + for (let i = 0; i < serverResponse.body.length; i++) { + let resItem = serverResponse.body[i]; + if (isBidResponseValid(resItem)) { + response.push(resItem); + } + } + return response; + }, + + getUserSyncs: (syncOptions, serverResponses) => { + if (NO_SYNC) { + return false + } else { + return [{ + type: 'image', + url: URL_SYNC + }]; + } + } + +}; + +registerBidder(spec); diff --git a/modules/e_volutionBidAdapter.md b/modules/e_volutionBidAdapter.md new file mode 100644 index 00000000000..ff5b2860e05 --- /dev/null +++ b/modules/e_volutionBidAdapter.md @@ -0,0 +1,53 @@ +# Overview + +``` +Module Name: e_volution Bidder Adapter +Module Type: Bidder Adapter +``` + +# Description + +Module that connects to e-volution-tech demand sources + +# Test Parameters +``` + var adUnits = [ + // Will return static test banner + { + code: 'placementId_0', + mediaTypes: { + banner: { + sizes: [[300, 250]], + } + }, + bids: [ + { + bidder: 'e_volution', + params: { + placementId: 0, + traffic: 'banner' + } + } + ] + }, + // Will return test vast xml. All video params are stored under placement in publishers UI + { + code: 'placementId_0', + mediaTypes: { + video: { + playerSize: [640, 480], + context: 'instream' + } + }, + bids: [ + { + bidder: 'e_volution', + params: { + placementId: 0, + traffic: 'video' + } + } + ] + } + ]; +``` diff --git a/modules/ebdrBidAdapter.js b/modules/ebdrBidAdapter.js index 79bf4bb1004..c30c10d8a90 100644 --- a/modules/ebdrBidAdapter.js +++ b/modules/ebdrBidAdapter.js @@ -1,6 +1,6 @@ -import * as utils from '../src/utils'; -import { VIDEO, BANNER } from '../src/mediaTypes'; -import { registerBidder } from '../src/adapters/bidderFactory'; +import * as utils from '../src/utils.js'; +import { VIDEO, BANNER } from '../src/mediaTypes.js'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; const BIDDER_CODE = 'ebdr'; export const spec = { code: BIDDER_CODE, @@ -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/emoteevBidAdapter.js b/modules/emoteevBidAdapter.js index fb62e4381e3..e0f88725d8a 100644 --- a/modules/emoteevBidAdapter.js +++ b/modules/emoteevBidAdapter.js @@ -14,8 +14,8 @@ * @author Emoteev Engineering . */ -import {registerBidder} from '../src/adapters/bidderFactory'; -import {BANNER} from '../src/mediaTypes'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; +import {BANNER} from '../src/mediaTypes.js'; import { triggerPixel, getUniqueIdentifierStr, @@ -24,10 +24,12 @@ import { isArray, isInteger, getParameterByName, - getCookie -} from '../src/utils'; -import {config} from '../src/config'; -import * as url from '../src/url'; + buildUrl +} from '../src/utils.js'; +import {config} from '../src/config.js'; +import { getStorageManager } from '../src/storageManager.js'; + +export const storage = getStorageManager(); export const BIDDER_CODE = 'emoteev'; @@ -232,7 +234,7 @@ export const domain = (env) => { * @param {string} env Emoteev environment parameter * @returns {string} The full URL which events is sent to. */ -export const eventsUrl = env => url.format({ +export const eventsUrl = env => buildUrl({ protocol: (env === DEVELOPMENT) ? 'http' : 'https', hostname: domain(env), pathname: EVENTS_PATH @@ -244,7 +246,7 @@ export const eventsUrl = env => url.format({ * @param {string} env Emoteev environment parameter * @returns {string} The full URL which bidderRequest is sent to. */ -export const bidderUrl = env => url.format({ +export const bidderUrl = env => buildUrl({ protocol: (env === DEVELOPMENT) ? 'http' : 'https', hostname: domain(env), pathname: BIDDER_PATH @@ -256,7 +258,7 @@ export const bidderUrl = env => url.format({ * @param {string} env Emoteev environment parameter * @returns {string} The full URL called for iframe-based user sync */ -export const userSyncIframeUrl = env => url.format({ +export const userSyncIframeUrl = env => buildUrl({ protocol: (env === DEVELOPMENT) ? 'http' : 'https', hostname: domain(env), pathname: USER_SYNC_IFRAME_PATH @@ -268,7 +270,7 @@ export const userSyncIframeUrl = env => url.format({ * @param {string} env Emoteev environment parameter * @returns {string} The full URL called for image-based user sync */ -export const userSyncImageUrl = env => url.format({ +export const userSyncImageUrl = env => buildUrl({ protocol: (env === DEVELOPMENT) ? 'http' : 'https', hostname: domain(env), pathname: USER_SYNC_IMAGE_PATH @@ -506,12 +508,12 @@ export const spec = { bidderRequest), interpretResponse: interpretResponse, onBidWon: (bidObject) => - triggerPixel(url.format(onBidWon( + triggerPixel(buildUrl(onBidWon( resolveEnv(config.getConfig(), getParameterByName('emoteevEnv')), - getCookie('_pubcid'), + storage.getCookie('_pubcid'), bidObject))), onTimeout: (bidRequest) => - triggerPixel(url.format(onTimeout( + triggerPixel(buildUrl(onTimeout( resolveEnv(config.getConfig(), getParameterByName('emoteevEnv')), bidRequest))), getUserSyncs: (syncOptions) => diff --git a/modules/emx_digitalBidAdapter.js b/modules/emx_digitalBidAdapter.js index 0768c8386fb..480e98b31d3 100644 --- a/modules/emx_digitalBidAdapter.js +++ b/modules/emx_digitalBidAdapter.js @@ -1,13 +1,14 @@ -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'; +import * as utils from '../src/utils.js'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { BANNER, VIDEO } from '../src/mediaTypes.js'; +import { Renderer } from '../src/Renderer.js'; +import includes from 'core-js/library/fn/array/includes.js'; +import find from 'core-js/library/fn/array/find.js'; 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 RENDERER_URL = 'https://js.brealtime.com/outstream/1.30.0/bundle.js'; +const ADAPTER_VERSION = '1.5.1'; const DEFAULT_CUR = 'USD'; export const emxAdapter = { @@ -41,11 +42,14 @@ export const emxAdapter = { }, 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 - }); + if (bidRequest.bidderRequest && bidRequest.bidderRequest.bids && bidRequest.bidderRequest.bids.length > 0) { + const matchingBid = find(bidRequest.bidderRequest.bids, bid => bidResponse.requestId && bid.bidId && bidResponse.requestId === bid.bidId && bid.mediaTypes && bid.mediaTypes.video && bid.mediaTypes.video.context === 'outstream'); + if (matchingBid) { + bidResponse.renderer = emxAdapter.createRenderer(bidResponse, { + id: emxBid.id, + url: RENDERER_URL + }); + } } return bidResponse; }, @@ -128,6 +132,14 @@ export const emxAdapter = { return document.referrer; } }, + getSite: (refInfo) => { + let url = utils.parseUrl(refInfo.referer); + return { + domain: url.hostname, + page: refInfo.referer, + ref: emxAdapter.getReferrer() + } + }, getGdpr: (bidRequests, emxData) => { if (bidRequests.gdprConsent) { emxData.regs = { @@ -188,16 +200,14 @@ export const spec = { return true; }, - buildRequests: function (validBidRequests, bidRequest) { + buildRequests: function (validBidRequests, bidderRequest) { const emxImps = []; - const timeout = bidRequest.timeout || ''; + const timeout = bidderRequest.timeout || ''; const timestamp = Date.now(); - const url = location.protocol + '//' + ENDPOINT + ('?t=' + timeout + '&ts=' + timestamp + '&src=pbjs'); + const url = 'https://' + 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(); + const site = emxAdapter.getSite(bidderRequest.refererInfo); utils._each(validBidRequests, function (bid) { let tagid = utils.getBidIdParameter('tagid', bid.params); @@ -217,30 +227,26 @@ export const spec = { }); let emxData = { - id: bidRequest.auctionId, + id: bidderRequest.auctionId, imp: emxImps, device, - site: { - domain, - page, - ref - }, + site, cur: DEFAULT_CUR, version: ADAPTER_VERSION }; - emxData = emxAdapter.getGdpr(bidRequest, Object.assign({}, emxData)); - if (bidRequest && bidRequest.uspConsent) { - emxData.us_privacy = bidRequest.uspConsent + emxData = emxAdapter.getGdpr(bidderRequest, Object.assign({}, emxData)); + if (bidderRequest && bidderRequest.uspConsent) { + emxData.us_privacy = bidderRequest.uspConsent } return { method: 'POST', - url: url, + url, data: JSON.stringify(emxData), options: { withCredentials: true }, - bidRequest + bidderRequest }; }, interpretResponse: function (serverResponse, bidRequest) { @@ -278,7 +284,7 @@ export const spec = { if (syncOptions.iframeEnabled) { syncs.push({ type: 'iframe', - url: '//biddr.brealtime.com/check.html' + url: 'https://biddr.brealtime.com/check.html' }); } return syncs; diff --git a/modules/envivoBidAdapter.js b/modules/envivoBidAdapter.js new file mode 100644 index 00000000000..b9c80ffd468 --- /dev/null +++ b/modules/envivoBidAdapter.js @@ -0,0 +1,129 @@ +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { config } from '../src/config.js'; +import * as utils from '../src/utils.js'; +import {BANNER, VIDEO} from '../src/mediaTypes.js'; +import { ajax } from '../src/ajax.js'; +import {Renderer} from '../src/Renderer.js'; + +const SUPPORTED_AD_TYPES = [BANNER, VIDEO]; +const BIDDER_CODE = 'envivo'; +const DOMAIN = 'https://ad.nvivo.tv/'; +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); +} + +function buildRequests(validBidRequests) { + return { + method: 'POST', + url: DOMAIN + 'ads/www/admin/plugins/Prebid/getAd.php', + options: { + withCredentials: false, + crossOrigin: true + }, + data: validBidRequests, + }; +} + +function interpretResponse(serverResponse, request) { + const response = serverResponse.body; + const bidResponses = []; + var bidRequestResponses = []; + + utils._each(response, function(bidAd) { + bidAd.adResponse = { + content: bidAd.vastXml, + height: bidAd.height, + width: bidAd.width + }; + bidAd.ttl = config.getConfig('_bidderTimeout') + bidAd.renderer = bidAd.context === 'outstream' ? createRenderer(bidAd, { + id: bidAd.adUnitCode, + url: RENDERER_URL + }, bidAd.adUnitCode) : undefined; + bidResponses.push(bidAd); + }); + + bidRequestResponses.push({ + function: 'saveResponses', + request: request, + response: bidResponses + }); + sendResponseToServer(bidRequestResponses); + return bidResponses; +} + +function outstreamRender(bidAd) { + bidAd.renderer.push(() => { + window.ANOutstreamVideo.renderAd({ + sizes: [bidAd.width, bidAd.height], + width: bidAd.width, + height: bidAd.height, + targetId: bidAd.adUnitCode, + adResponse: bidAd.adResponse, + rendererOptions: { + showVolume: false, + allowFullscreen: false + } + }); + }); +} + +function createRenderer(bidAd, rendererParams, adUnitCode) { + const renderer = Renderer.install({ + id: rendererParams.id, + url: rendererParams.url, + loaded: false, + config: {'player_height': bidAd.height, 'player_width': bidAd.width}, + adUnitCode + }); + try { + renderer.setRender(outstreamRender); + } catch (err) { + utils.logWarn('Prebid Error calling setRender on renderer', err); + } + return renderer; +} + +function onBidWon(bid) { + let wonBids = []; + wonBids.push(bid); + wonBids[0].function = 'onBidWon'; + sendResponseToServer(wonBids); +} + +function onTimeout(details) { + details.unshift({ 'function': 'onTimeout' }); + sendResponseToServer(details); +} + +function sendResponseToServer(data) { + ajax(DOMAIN + 'ads/www/admin/plugins/Prebid/tracking/track.php', null, JSON.stringify(data), { + withCredentials: false, + method: 'POST', + crossOrigin: true + }); +} + +function getUserSyncs(syncOptions) { + if (syncOptions.iframeEnabled) { + return [{ + type: 'iframe', + url: DOMAIN + 'ads/www/admin/plugins/Prebid/userSync.php' + }]; + } +} + +export const spec = { + code: BIDDER_CODE, + supportedMediaTypes: SUPPORTED_AD_TYPES, + isBidRequestValid, + buildRequests, + interpretResponse, + getUserSyncs, + onBidWon, + onTimeout +}; + +registerBidder(spec); diff --git a/modules/envivoBidAdapter.md b/modules/envivoBidAdapter.md new file mode 100644 index 00000000000..3ecc8a251f3 --- /dev/null +++ b/modules/envivoBidAdapter.md @@ -0,0 +1,50 @@ +# Overview + +``` +Module Name: envivo Bid Adapter +Module Type: Bidder Adapter +Maintainer : adtech@nvivo.tv +``` + +# Description + +Connects to Envivo Ad Server for bids. + +envivo bid adapter supports Banner and Video. + +# Test Parameters +``` + var adUnits = [ + //bannner object + { + code: 'banner-ad-slot', + mediaTypes: { + banner: { + sizes: [[300, 250]], + } + }, + bids: [{ + bidder: 'envivo', + params: { + publisherId: 14 + } + }] + + }, + //video object + { + code: 'video-ad-slot', + mediaTypes: { + video: { + context: 'instream', + playerSize: [640, 480], + }, + }, + bids: [{ + bidder: "envivo", + params: { + publisherId: 14 + } + }] + }]; +``` diff --git a/modules/eplanningAnalyticsAdapter.js b/modules/eplanningAnalyticsAdapter.js index 21ecddfbc3a..08db2f2ca9d 100644 --- a/modules/eplanningAnalyticsAdapter.js +++ b/modules/eplanningAnalyticsAdapter.js @@ -1,7 +1,7 @@ -import {ajax} from '../src/ajax'; -import adapter from '../src/AnalyticsAdapter'; -import adapterManager from '../src/adapterManager'; -import * as utils from '../src/utils'; +import {ajax} from '../src/ajax.js'; +import adapter from '../src/AnalyticsAdapter.js'; +import adapterManager from '../src/adapterManager.js'; +import * as utils from '../src/utils.js'; const CONSTANTS = require('../src/constants.json'); diff --git a/modules/eplanningBidAdapter.js b/modules/eplanningBidAdapter.js index d9e14554483..a4b4f2d6728 100644 --- a/modules/eplanningBidAdapter.js +++ b/modules/eplanningBidAdapter.js @@ -1,11 +1,14 @@ -import * as utils from '../src/utils'; -import { registerBidder } from '../src/adapters/bidderFactory'; +import * as utils from '../src/utils.js'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { getStorageManager } from '../src/storageManager.js'; + +export const storage = getStorageManager(); 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 PARAMS = ['ci', 'sv', 't', 'ml']; const DOLLARS = 'USD'; const NET_REVENUE = true; const TTL = 120; @@ -21,7 +24,7 @@ export const spec = { return Boolean(bid.params.ci) || Boolean(bid.params.t); }, - buildRequests: function(bidRequests) { + buildRequests: function(bidRequests, bidderRequest) { const method = 'GET'; const dfpClientId = '1'; const sec = 'ROS'; @@ -29,28 +32,33 @@ export const spec = { let params; const urlConfig = getUrlConfig(bidRequests); const pcrs = getCharset(); - const spaces = getSpaces(bidRequests); + const spaces = getSpaces(bidRequests, urlConfig.ml); + const pageUrl = bidderRequest.refererInfo.referer; + const getDomain = (url) => { + let anchor = document.createElement('a'); + anchor.href = url; + return anchor.hostname; + } if (urlConfig.t) { - url = urlConfig.isv + '/layers/t_pbjs_2.json'; + url = 'https://' + 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(); + url = 'https://' + (urlConfig.sv || DEFAULT_SV) + '/hb/1/' + urlConfig.ci + '/' + dfpClientId + '/' + getDomain(pageUrl) + '/' + sec; + const referrerUrl = bidderRequest.refererInfo.referer.reachedTop ? encodeURIComponent(window.top.document.referrer) : encodeURIComponent(bidderRequest.refererInfo.referer); - if (utils.hasLocalStorage()) { + if (storage.hasLocalStorage()) { registerViewabilityAllBids(bidRequests); } params = { rnd: rnd, e: spaces.str, - ur: utils.getTopWindowUrl() || FILE, + ur: encodeURIComponent(pageUrl || FILE), r: 'pbjs', pbv: '$prebid.version$', ncb: '1', vs: spaces.vs }; - if (pcrs) { params.crs = pcrs; } @@ -58,6 +66,19 @@ export const spec = { if (referrerUrl) { params.fr = referrerUrl; } + + if (bidderRequest && bidderRequest.gdprConsent) { + if (typeof bidderRequest.gdprConsent.gdprApplies !== 'undefined') { + params.gdpr = bidderRequest.gdprConsent.gdprApplies ? '1' : '0'; + if (typeof bidderRequest.gdprConsent.consentString !== 'undefined') { + params.gdprcs = bidderRequest.gdprConsent.consentString; + } + } + } + + if (bidderRequest && bidderRequest.uspConsent) { + params.ccpa = bidderRequest.uspConsent; + } } return { @@ -133,10 +154,6 @@ function getUrlConfig(bidRequests) { }); }); - if (config.sv) { - config.sv = '//' + config.sv; - } - return config; } function isTestRequest(bidRequests) { @@ -152,7 +169,7 @@ function getTestConfig(bidRequests) { bidRequests.forEach(br => isv = isv || br.params.isv); return { t: true, - isv: '//' + (isv || DEFAULT_ISV) + isv: (isv || DEFAULT_ISV) }; } @@ -171,12 +188,16 @@ function getSpacesStruct(bids) { return e; } -function getSpaces(bidRequests) { +function cleanName(name) { + return name.replace(/_|\.|-|\//g, '').replace(/\)\(|\(|\)|:/g, '_').replace(/^_+|_+$/g, ''); +} + +function getSpaces(bidRequests, ml) { 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; + let name = ml ? cleanName(bid.adUnitCode) : getSize(bid, true) + '_' + i; es.map[name] = bid.bidId; return name + ':' + getSize(bid); }).join('+')).join('+'); @@ -186,7 +207,7 @@ function getSpaces(bidRequests) { function getVs(bid) { let s; let vs = ''; - if (utils.hasLocalStorage()) { + if (storage.hasLocalStorage()) { s = getViewabilityData(bid); vs += s.render >= 4 ? s.ratio.toString(16) : 'F'; } else { @@ -196,14 +217,15 @@ function getVs(bid) { } function getViewabilityData(bid) { - let r = utils.getDataFromLocalStorage(STORAGE_RENDER_PREFIX + bid.adUnitCode) || 0; - let v = utils.getDataFromLocalStorage(STORAGE_VIEW_PREFIX + bid.adUnitCode) || 0; + let r = storage.getDataFromLocalStorage(STORAGE_RENDER_PREFIX + bid.adUnitCode) || 0; + let v = storage.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; @@ -231,8 +253,14 @@ function waitForElementsPresent(elements) { }); } }); - const config = {childList: true, subtree: true, characterData: true, attributes: true, attributeOldValue: true}; - observer.observe(document.body, config); + document.addEventListener('DOMContentLoaded', function (event) { + var config = { + childList: true, + subtree: true, + characterData: true + }; + observer.observe(document.body, config); + }); } function registerViewability(div) { @@ -383,9 +411,9 @@ function visibilityHandler(obj) { function registerAuction(storageID) { let value; try { - value = utils.getDataFromLocalStorage(storageID); + value = storage.getDataFromLocalStorage(storageID); value = value ? window.parseInt(value, 10) + 1 : 1; - utils.setDataInLocalStorage(storageID, value); + storage.setDataInLocalStorage(storageID, value); } catch (exc) { return false; } diff --git a/modules/etargetBidAdapter.js b/modules/etargetBidAdapter.js index bdf07742497..5e07561044a 100644 --- a/modules/etargetBidAdapter.js +++ b/modules/etargetBidAdapter.js @@ -1,7 +1,7 @@ 'use strict'; -import {registerBidder} from '../src/adapters/bidderFactory'; -import { BANNER, VIDEO } from '../src/mediaTypes'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; +import { BANNER, VIDEO } from '../src/mediaTypes.js'; const BIDDER_CODE = 'etarget'; const countryMap = { @@ -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/express.js b/modules/express.js index 1249822f587..f4a76daefdf 100644 --- a/modules/express.js +++ b/modules/express.js @@ -1,5 +1,5 @@ -import * as utils from '../src/utils'; +import * as utils from '../src/utils.js'; const MODULE_NAME = 'express'; @@ -61,6 +61,7 @@ $$PREBID_GLOBAL$$.express = function(adUnits = $$PREBID_GLOBAL$$.adUnits) { function defaultSlots(slots) { return Array.isArray(slots) ? slots.slice() + // eslint-disable-next-line no-undef : googletag.pubads().getSlots().slice(); } @@ -116,6 +117,7 @@ $$PREBID_GLOBAL$$.express = function(adUnits = $$PREBID_GLOBAL$$.adUnits) { // if not SRA mode, get only the gpt slot corresponding to sEementId var aGptSlots; if (!bEnabledSRA) { + // eslint-disable-next-line no-undef aGptSlots = googletag.pubads().getSlots().filter(function (oGptSlot) { return oGptSlot.getSlotElementId() === sElementId; }); diff --git a/modules/eywamediaBidAdapter.js b/modules/eywamediaBidAdapter.js deleted file mode 100644 index 543775dc3aa..00000000000 --- 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 55f24ab8906..00000000000 --- 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/feedadBidAdapter.js b/modules/feedadBidAdapter.js index 1e995ee8914..3992f2db5e0 100644 --- a/modules/feedadBidAdapter.js +++ b/modules/feedadBidAdapter.js @@ -1,7 +1,7 @@ -import * as utils from '../src/utils'; -import {registerBidder} from '../src/adapters/bidderFactory'; -import {BANNER, VIDEO} from '../src/mediaTypes'; -import {ajax} from '../src/ajax'; +import * as utils from '../src/utils.js'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; +import {BANNER, VIDEO} from '../src/mediaTypes.js'; +import {ajax} from '../src/ajax.js'; /** * Version of the FeedAd bid adapter diff --git a/modules/fidelityBidAdapter.js b/modules/fidelityBidAdapter.js index f27c71d2712..f16a8ea96be 100644 --- a/modules/fidelityBidAdapter.js +++ b/modules/fidelityBidAdapter.js @@ -1,11 +1,12 @@ -import * as utils from '../src/utils'; -import {registerBidder} from '../src/adapters/bidderFactory'; +import * as utils from '../src/utils.js'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; const BIDDER_CODE = 'fidelity'; const BIDDER_SERVER = 'x.fidelity-media.com'; const FIDELITY_VENDOR_ID = 408; export const spec = { code: BIDDER_CODE, + gvlid: 408, isBidRequestValid: function isBidRequestValid(bid) { return !!(bid && bid.params && bid.params.zoneid); }, @@ -26,6 +27,7 @@ export const spec = { tmax: bidderRequest.timeout, defloc: bidderRequest.refererInfo.referer, referrer: getTopWindowReferrer(), + schain: getSupplyChain(bidRequest.schain), }; setConsentParams(bidderRequest.gdprConsent, bidderRequest.uspConsent, payload); @@ -117,4 +119,25 @@ function setConsentParams(gdprConsent, uspConsent, payload) { } } +function getSupplyChain(schain) { + var supplyChain = ''; + if (schain != null && schain.nodes) { + supplyChain = schain.ver + ',' + schain.complete; + for (let i = 0; i < schain.nodes.length; i++) { + supplyChain += '!'; + supplyChain += (schain.nodes[i].asi) ? encodeURIComponent(schain.nodes[i].asi) : ''; + supplyChain += ','; + supplyChain += (schain.nodes[i].sid) ? encodeURIComponent(schain.nodes[i].sid) : ''; + supplyChain += ','; + supplyChain += (schain.nodes[i].hp) ? encodeURIComponent(schain.nodes[i].hp) : ''; + supplyChain += ','; + supplyChain += (schain.nodes[i].rid) ? encodeURIComponent(schain.nodes[i].rid) : ''; + supplyChain += ','; + supplyChain += (schain.nodes[i].name) ? encodeURIComponent(schain.nodes[i].name) : ''; + supplyChain += ','; + supplyChain += (schain.nodes[i].domain) ? encodeURIComponent(schain.nodes[i].domain) : ''; + } + } + return supplyChain; +} registerBidder(spec); diff --git a/modules/fintezaAnalyticsAdapter.js b/modules/fintezaAnalyticsAdapter.js index a1376c28427..8729035491f 100644 --- a/modules/fintezaAnalyticsAdapter.js +++ b/modules/fintezaAnalyticsAdapter.js @@ -1,9 +1,10 @@ -import { ajax } from '../src/ajax'; -import adapter from '../src/AnalyticsAdapter'; -import adapterManager from '../src/adapterManager'; -import * as utils from '../src/utils'; -import { parse as parseURL } from '../src/url'; +import { ajax } from '../src/ajax.js'; +import adapter from '../src/AnalyticsAdapter.js'; +import adapterManager from '../src/adapterManager.js'; +import * as utils from '../src/utils.js'; +import { getStorageManager } from '../src/storageManager.js'; +const storage = getStorageManager(); const CONSTANTS = require('../src/constants.json'); const ANALYTICS_TYPE = 'endpoint'; @@ -27,7 +28,7 @@ function getPageInfo() { } if (document.referrer) { - pageInfo.referrerDomain = parseURL(document.referrer).hostname; + pageInfo.referrerDomain = utils.parseUrl(document.referrer).hostname; } return pageInfo; @@ -46,8 +47,8 @@ function getUniqId() { let uniq = cookies[ UNIQ_ID_KEY ]; if (!uniq) { try { - if (window.localStorage) { - uniq = window.localStorage.getItem(UNIQ_ID_KEY) || ''; + if (storage.hasLocalStorage()) { + uniq = storage.getDataFromLocalStorage(UNIQ_ID_KEY) || ''; isUniqFromLS = true; } } catch (b) {} @@ -62,7 +63,7 @@ function getUniqId() { expires.setFullYear(expires.getFullYear() + 10); try { - document.cookie = UNIQ_ID_KEY + '=' + uniq + '; path=/; expires=' + expires.toUTCString(); + storage.setCookie(UNIQ_ID_KEY, uniq, expires.toUTCString()); } catch (e) {} } @@ -90,7 +91,7 @@ function initFirstVisit() { now.setFullYear(now.getFullYear() + 20); try { - document.cookie = FIRST_VISIT_DATE + '=' + visitDate + '; path=/; expires=' + now.toUTCString(); + storage.setCookie(FIRST_VISIT_DATE, visitDate, now.toUTCString()); } catch (e) {} } @@ -110,7 +111,7 @@ function parseCookies(cookie) { let param, value; let i, j; - if (!cookie) { + if (!cookie || !storage.cookiesAreEnabled()) { return {}; } @@ -203,7 +204,7 @@ function initSession() { } try { - document.cookie = SESSION_ID + '=' + sessionId + '; path=/; expires=' + expires.toUTCString(); + storage.setCookie(SESSION_ID, sessionId, expires.toUTCString()); } catch (e) {} return { @@ -249,10 +250,10 @@ function saveTrackRequestTime() { const expires = new Date(now + SESSION_DURATION); try { - if (window.localStorage) { - window.localStorage.setItem(TRACK_TIME_KEY, now.toString()); + if (storage.hasLocalStorage()) { + storage.setDataInLocalStorage(TRACK_TIME_KEY, now.toString()); } else { - document.cookie = TRACK_TIME_KEY + '=' + now + '; path=/; expires=' + expires.toUTCString(); + storage.setCookie(TRACK_TIME_KEY, now.toString(), expires.toUTCString()); } } catch (a) {} } @@ -261,9 +262,9 @@ function getTrackRequestLastTime() { let cookie; try { - if (window.localStorage) { + if (storage.hasLocalStorage()) { return parseInt( - window.localStorage.getItem(TRACK_TIME_KEY) || 0, + storage.getDataFromLocalStorage(TRACK_TIME_KEY) || 0, 10, ); } diff --git a/modules/fluctBidAdapter.js b/modules/fluctBidAdapter.js new file mode 100644 index 00000000000..420fe04ddcb --- /dev/null +++ b/modules/fluctBidAdapter.js @@ -0,0 +1,121 @@ +import * as utils from '../src/utils.js'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; + +const BIDDER_CODE = 'fluct'; +const END_POINT = 'https://hb.adingo.jp/prebid'; +const VERSION = '1.2'; +const NET_REVENUE = true; +const TTL = 300; + +export const spec = { + code: BIDDER_CODE, + aliases: ['adingo'], + + /** + * 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 !!(bid.params.groupId && bid.params.tagId); + }, + + /** + * 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 serverRequests = []; + const referer = bidderRequest.refererInfo.referer; + + utils._each(validBidRequests, (request) => { + const data = Object(); + + data.referer = referer; + data.adUnitCode = request.adUnitCode; + data.bidId = request.bidId; + data.transactionId = request.transactionId; + + data.sizes = []; + utils._each(request.sizes, (size) => { + data.sizes.push({ + w: size[0], + h: size[1] + }); + }); + + data.params = request.params; + + serverRequests.push({ + method: 'POST', + url: END_POINT, + options: { + contentType: 'application/json', + withCredentials: true, + customHeaders: { + 'x-fluct-app': 'prebid/fluctBidAdapter', + 'x-fluct-version': VERSION, + 'x-openrtb-version': 2.5 + } + }, + data: data + }); + }); + + return serverRequests; + }, + + /* + * Unpack the respnse from the server into a list of bids. + * + * @param {serverResponse} serverResponse A successful response from the server. + * @return {bid[]} An array of bids which weer nested inside the server. + */ + interpretResponse: (serverResponse, serverRequest) => { + const bidResponses = []; + + const res = serverResponse.body; + if (!utils.isEmpty(res) && !utils.isEmpty(res.seatbid) && !utils.isEmpty(res.seatbid[0].bid)) { + const bid = res.seatbid[0].bid[0]; + const dealId = bid.dealid; + const beaconUrl = bid.burl; + const callImpBeacon = ``; + let data = { + bidderCode: BIDDER_CODE, + requestId: res.id, + currency: res.cur, + cpm: parseFloat(bid.price) || 0, + netRevenue: NET_REVENUE, + width: bid.w, + height: bid.h, + creativeId: bid.crid, + ttl: TTL, + ad: bid.adm + callImpBeacon, + }; + if (!utils.isEmpty(dealId)) { + data.dealId = dealId; + } + bidResponses.push(data); + } + return bidResponses; + }, + + /* + * Register the user sync pixels which should be dropped after the auction. + * + * @params {syncOptions} syncOptions which user syncs are allowed? + * @params {ServerResponse[]} serverResponses List of server's responses. + * @return {UserSync[]} The user syncs which should be dropped. + * + */ + getUserSyncs: (syncOptions, serverResponses) => { + return []; + }, +}; + +registerBidder(spec); diff --git a/modules/fluctBidAdapter.md b/modules/fluctBidAdapter.md new file mode 100644 index 00000000000..a1dc4d6f225 --- /dev/null +++ b/modules/fluctBidAdapter.md @@ -0,0 +1,36 @@ +# Overview + +``` +Module Name: fluct Bid Adapter +Module Type: Bidder Adapter +Maintainer: developer@fluct.jp +``` + +# Description + +Connects to fluct exchange for bids. + +# Test parameters + +``` +var adUnits = [ + { + code: 'test-div', + mediaTypes: { + banner: { + sizes: [[300, 250]], + } + }, + bids: [ + { + bidder: 'fluct', + params: { + tagId: '25405:1000192893', + groupId: '1000105712', + dfpUnitCode: '/62532913/s_fluct.test_hb_prebid_11940', // Optional + } + } + ] + } +] +``` diff --git a/modules/freeWheelAdserverVideo.js b/modules/freeWheelAdserverVideo.js index 03217b1165d..cb4bd938373 100644 --- a/modules/freeWheelAdserverVideo.js +++ b/modules/freeWheelAdserverVideo.js @@ -2,8 +2,8 @@ * This module adds Freewheel support for Video to Prebid. */ -import { registerVideoSupport } from '../src/adServerManager'; -import { getHook, submodule } from '../src/hook'; +import { registerVideoSupport } from '../src/adServerManager.js'; +import { getHook, submodule } from '../src/hook.js'; export const adpodUtils = {}; export function notifyTranslationModule(fn) { diff --git a/modules/freewheel-sspBidAdapter.js b/modules/freewheel-sspBidAdapter.js index 3e52ba2cbe9..34724658631 100644 --- a/modules/freewheel-sspBidAdapter.js +++ b/modules/freewheel-sspBidAdapter.js @@ -1,6 +1,6 @@ -import * as utils from '../src/utils'; -import { registerBidder } from '../src/adapters/bidderFactory'; -// import { config } from '../src/config'; +import * as utils from '../src/utils.js'; +import { BANNER, VIDEO } from '../src/mediaTypes.js'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; const BIDDER_CODE = 'freewheel-ssp'; @@ -11,11 +11,7 @@ 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'; - } + return 'https'; } function isValidUrl(str) { @@ -38,6 +34,20 @@ function getBiggerSize(array) { return result; } +function getBiggerSizeWithLimit(array, minSizeLimit, maxSizeLimit) { + var minSize = minSizeLimit || [0, 0]; + var maxSize = maxSizeLimit || [Number.MAX_VALUE, Number.MAX_VALUE]; + var candidates = []; + + for (var i = 0; i < array.length; i++) { + if (array[i][0] * array[i][1] >= minSize[0] * minSize[1] && array[i][0] * array[i][1] <= maxSize[0] * maxSize[1]) { + candidates.push(array[i]); + } + } + + return getBiggerSize(candidates); +} + /* * read the pricing extension with this format: 1.0000 * @return {object} pricing data in format: {currency: "EUR", price:"1.000"} @@ -204,7 +214,7 @@ var getOutstreamScript = function(bid) { export const spec = { code: BIDDER_CODE, - supportedMediaTypes: ['banner', 'video'], + supportedMediaTypes: [BANNER, VIDEO], aliases: ['stickyadstv'], // former name for freewheel-ssp /** * Determines whether or not the given bid request is valid. @@ -225,62 +235,82 @@ export const spec = { 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.'); - } + let buildRequest = (currentBidRequest, bidderRequest) => { + 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 + }; - 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 && bidderRequest.gdprConsent) { + requestParams._fw_gdpr_consent = bidderRequest.gdprConsent.consentString; - // 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 (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; } - } - if (currentBidRequest.params.gdpr_consented_providers) { - requestParams._fw_gdpr_consented_providers = currentBidRequest.params.gdpr_consented_providers; - } + // Add CCPA consent string + if (bidderRequest && bidderRequest.uspConsent) { + requestParams._fw_us_privacy = bidderRequest.uspConsent; + } - var vastParams = currentBidRequest.params.vastUrlParams; - if (typeof vastParams === 'object') { - for (var key in vastParams) { - if (vastParams.hasOwnProperty(key)) { - requestParams[key] = vastParams[key]; + 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 location = (bidderRequest && bidderRequest.refererInfo) ? bidderRequest.refererInfo.referer : getTopMostWindow().location.href; + 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]; - } + var playerSize = []; + if (currentBidRequest.mediaTypes.video && currentBidRequest.mediaTypes.video.playerSize) { + // If mediaTypes is video, get size from mediaTypes.video.playerSize per http://prebid.org/blog/pbjs-3 + if (utils.isArray(currentBidRequest.mediaTypes.video.playerSize[0])) { + playerSize = currentBidRequest.mediaTypes.video.playerSize[0]; + } else { + playerSize = currentBidRequest.mediaTypes.video.playerSize; + } + } else if (currentBidRequest.mediaTypes.banner.sizes) { + // If mediaTypes is banner, get size from mediaTypes.banner.sizes per http://prebid.org/blog/pbjs-3 + playerSize = getBiggerSizeWithLimit(currentBidRequest.mediaTypes.banner.sizes, currentBidRequest.mediaTypes.banner.minSizeLimit, currentBidRequest.mediaTypes.banner.maxSizeLimit); + } else { + // Backward compatible code, in case size still pass by sizes in bid request + 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 + return { + method: 'GET', + url: FREEWHEEL_ADSSETUP, + data: requestParams, + bidRequest: currentBidRequest + }; }; + + return bidRequests.map(function(currentBidRequest) { + return buildRequest(currentBidRequest, bidderRequest); + }); }, /** @@ -292,7 +322,21 @@ export const spec = { */ interpretResponse: function(serverResponse, request) { var bidrequest = request.bidRequest; - var playerSize = getBiggerSize(bidrequest.sizes); + var playerSize = []; + if (bidrequest.mediaTypes.video && bidrequest.mediaTypes.video.playerSize) { + // If mediaTypes is video, get size from mediaTypes.video.playerSize per http://prebid.org/blog/pbjs-3 + if (utils.isArray(bidrequest.mediaTypes.video.playerSize[0])) { + playerSize = bidrequest.mediaTypes.video.playerSize[0]; + } else { + playerSize = bidrequest.mediaTypes.video.playerSize; + } + } else if (bidrequest.mediaTypes.banner.sizes) { + // If mediaTypes is banner, get size from mediaTypes.banner.sizes per http://prebid.org/blog/pbjs-3 + playerSize = getBiggerSizeWithLimit(bidrequest.mediaTypes.banner.sizes, bidrequest.mediaTypes.banner.minSizeLimit, bidrequest.mediaTypes.banner.maxSizeLimit); + } else { + // Backward compatible code, in case size still pass by sizes in bid request + playerSize = getBiggerSize(bidrequest.sizes); + } if (typeof serverResponse == 'object' && typeof serverResponse.body == 'string') { serverResponse = serverResponse.body; @@ -330,17 +374,12 @@ export const spec = { ttl: 360 }; - var mediaTypes = bidrequest.mediaTypes || {}; - if (mediaTypes.video) { - // bidResponse.vastXml = serverResponse; + if (bidrequest.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); } + bidResponse.ad = formatAdHTML(bidrequest, playerSize); bidResponses.push(bidResponse); } @@ -348,11 +387,13 @@ export const spec = { }, getUserSyncs: function(syncOptions) { - if (syncOptions.pixelEnabled) { + if (syncOptions && syncOptions.pixelEnabled) { return [{ type: 'image', url: USER_SYNC_URL }]; + } else { + return []; } }, diff --git a/modules/freewheel-sspBidAdapter.md b/modules/freewheel-sspBidAdapter.md index 70ab2415279..0086aac6567 100644 --- a/modules/freewheel-sspBidAdapter.md +++ b/modules/freewheel-sspBidAdapter.md @@ -13,15 +13,21 @@ Module that connects to Freewheel ssp's demand sources var adUnits = [ { code: 'test-div', - sizes: [[300, 250]], // a display size + + mediaTypes: { + banner: { + sizes: [[300, 250]], // a display size + } + }, + bids: [ { bidder: "freewheel-ssp", params: { - zoneId : '41852' + zoneId : '277225' } } ] } ]; -``` \ No newline at end of file +``` diff --git a/modules/fyberBidAdapter.js b/modules/fyberBidAdapter.js deleted file mode 100644 index 3586d0775ac..00000000000 --- 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 index 926dae14790..5fd3c56b2c6 100644 --- a/modules/gammaBidAdapter.js +++ b/modules/gammaBidAdapter.js @@ -1,7 +1,7 @@ -import * as utils from '../src/utils'; -import { registerBidder } from '../src/adapters/bidderFactory'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; -const ENDPOINT = 'hb.gammaplatform.com'; +const ENDPOINT = 'https://hb.gammaplatform.com'; +const ENDPOINT_USERSYNC = 'https://cm-supply-web.gammaplatform.com'; const BIDDER_CODE = 'gamma'; export const spec = { @@ -25,13 +25,14 @@ export const spec = { * @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) { + buildRequests: function(bidRequests, bidderRequest) { const serverRequests = []; + const bidderRequestReferer = (bidderRequest && bidderRequest.refererInfo && bidderRequest.refererInfo.referer) || ''; 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()) + url: ENDPOINT + '/adx/request?wid=' + gaxObjParams.params.siteId + '&zid=' + gaxObjParams.params.zoneId + '&hb=pbjs&bidid=' + gaxObjParams.bidId + '&urf=' + encodeURIComponent(bidderRequestReferer) }); } return serverRequests; @@ -60,7 +61,7 @@ export const spec = { if (syncOptions.iframeEnabled) { return [{ type: 'iframe', - url: '//' + ENDPOINT + '/adx/usersync' + url: ENDPOINT_USERSYNC + '/adx/usersync' }]; } } diff --git a/modules/gamoshiBidAdapter.js b/modules/gamoshiBidAdapter.js index 89ffde51889..1316d74e430 100644 --- a/modules/gamoshiBidAdapter.js +++ b/modules/gamoshiBidAdapter.js @@ -1,8 +1,8 @@ -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'; +import * as utils from '../src/utils.js'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; +import {config} from '../src/config.js'; +import {Renderer} from '../src/Renderer.js'; +import {BANNER, VIDEO} from '../src/mediaTypes.js'; const ENDPOINTS = { 'gamoshi': 'https://rtb.gamoshi.io' @@ -62,20 +62,24 @@ export const spec = { let url = config.getConfig('pageUrl') || bidderRequest.refererInfo.referer; const rtbBidRequest = { - 'id': auctionId, - 'site': { - 'domain': helper.getTopWindowDomain(url), - 'page': url, - 'ref': bidderRequest.refererInfo.referer + id: auctionId, + site: { + domain: helper.getTopWindowDomain(url), + page: url, + ref: bidderRequest.refererInfo.referer }, - 'device': { - 'ua': navigator.userAgent + device: { + ua: navigator.userAgent, + dnt: utils.getDNT() ? 1 : 0, + h: screen.height, + w: screen.width, + language: navigator.language }, - 'imp': [], - 'ext': {}, - 'user': { - 'ext': {} - } + imp: [], + ext: {}, + user: {ext: {}}, + source: {ext: {}}, + regs: {ext: {}} }; const gdprConsent = bidderRequest.gdprConsent; @@ -84,37 +88,39 @@ export const spec = { consent_string: gdprConsent.consentString, consent_required: gdprConsent.gdprApplies }; - rtbBidRequest.regs = { - ext: { - gdpr: gdprConsent.gdprApplies === true ? 1 : 0 - } - }; - rtbBidRequest.user = { - ext: { - consent: gdprConsent.consentString - } - } + + utils.deepSetValue(rtbBidRequest, 'regs.ext.gdpr', gdprConsent.gdprApplies === true ? 1 : 0); + utils.deepSetValue(rtbBidRequest, 'user.ext.consent', gdprConsent.consentString); + } + + if (validBidRequests[0].schain) { + utils.deepSetValue(rtbBidRequest, 'source.ext.schain', validBidRequests[0].schain); + } + + if (bidderRequest && bidderRequest.uspConsent) { + utils.deepSetValue(rtbBidRequest, 'regs.ext.us_privacy', bidderRequest.uspConsent); } + 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 + id: transactionId, + instl: params.instl === 1 ? 1 : 0, + tagid: adUnitCode, + bidfloor: params.bidfloor || 0, + bidfloorcur: 'USD', + secure: 1 }; const hasFavoredMediaType = params.favoredMediaType && this.supportedMediaTypes.includes(params.favoredMediaType); - if ((!mediaTypes || mediaTypes.banner)) { + 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() + topframe: utils.inIframe() ? 0 : 1 } }); rtbBidRequest.imp.push(bannerImp); @@ -126,8 +132,6 @@ export const spec = { 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: { @@ -135,6 +139,18 @@ export const spec = { } } }); + + 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; + } + rtbBidRequest.imp.push(videoImp); } } @@ -152,7 +168,12 @@ export const spec = { return; } - return {method: 'POST', url: rtbEndpoint, data: rtbBidRequest, bidRequest}; + return { + method: 'POST', + url: rtbEndpoint, + data: rtbBidRequest, + bidRequest + }; }); }, @@ -195,28 +216,52 @@ export const spec = { return outBids; }, - getUserSyncs: function (syncOptions, serverResponses, gdprConsent) { + getUserSyncs: function (syncOptions, serverResponses, gdprConsent, uspConsent) { const syncs = []; - const gdprApplies = gdprConsent && (typeof gdprConsent.gdprApplies === 'boolean') ? gdprConsent.gdprApplies : false; - const suffix = gdprApplies ? 'gc=' + encodeURIComponent(gdprConsent.consentString) : 'gc=missing'; + let gdprApplies = false; + let consentString = ''; + let uspConsentString = ''; + + if (gdprConsent && (typeof gdprConsent.gdprApplies === 'boolean')) { + gdprApplies = gdprConsent.gdprApplies; + } + let gdpr = gdprApplies ? 1 : 0; + + if (gdprApplies && gdprConsent.consentString) { + consentString = encodeURIComponent(gdprConsent.consentString) + } + + if (uspConsent) { + uspConsentString = encodeURIComponent(uspConsent); + } + + const macroValues = { + gdpr: gdpr, + consent: consentString, + uspConsent: uspConsentString + }; + 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}); - }); + bidResponse.ext['utrk'] + .forEach(pixel => { + const url = replaceMacros(pixel.url, macroValues); + 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}); - }); + bid.ext['utrk'] + .forEach(pixel => { + const url = replaceMacros(pixel.url, macroValues); + syncs.push({type: pixel.type, url}); + }); } }); } @@ -224,13 +269,14 @@ export const spec = { } } }); + 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', + url: (bidRequest.params && bidRequest.params.rendererUrl) || (bid.ext && bid.ext.renderer_url) || 'https://s.gamoshi.io/video/latest/renderer.js', config: rendererOptions, loaded: false, }); @@ -276,4 +322,11 @@ function addExternalUserId(eids, value, source, rtiPartner) { } } +function replaceMacros(url, macros) { + return url + .replace('[GDPR]', macros.gdpr) + .replace('[CONSENT]', macros.consent) + .replace('[US_PRIVACY]', macros.uspConsent); +} + registerBidder(spec); diff --git a/modules/gdprEnforcement.js b/modules/gdprEnforcement.js new file mode 100644 index 00000000000..363d0e396f8 --- /dev/null +++ b/modules/gdprEnforcement.js @@ -0,0 +1,218 @@ +/** + * This module gives publishers extra set of features to enforce individual purposes of TCF v2 + */ + +import * as utils from '../src/utils.js'; +import { config } from '../src/config.js'; +import { hasDeviceAccess } from '../src/utils.js'; +import adapterManager, { gdprDataHandler } from '../src/adapterManager.js'; +import find from 'core-js/library/fn/array/find.js'; +import includes from 'core-js/library/fn/array/includes.js'; +import { registerSyncInner } from '../src/adapters/bidderFactory.js'; +import { getHook } from '../src/hook.js'; +import { validateStorageEnforcement } from '../src/storageManager.js'; + +const purpose1 = 'storage'; + +let addedDeviceAccessHook = false; +let enforcementRules; + +function getGvlid() { + let gvlid; + const bidderCode = config.getCurrentBidder(); + if (bidderCode) { + const bidder = adapterManager.getBidAdapter(bidderCode); + gvlid = bidder.getSpec().gvlid; + } else { + utils.logWarn('Current module not found'); + } + return gvlid; +} + +/** + * This function takes in rules and consentData as input and validates against the consentData provided. If it returns true Prebid will allow the next call else it will log a warning + * @param {Object} rules enforcement rules set in config + * @param {Object} consentData gdpr consent data + * @returns {boolean} + */ +function validateRules(rule, consentData, currentModule, gvlid) { + let isAllowed = false; + if (!rule.vendorExceptions) rule.vendorExceptions = []; + if (rule.enforcePurpose && rule.enforceVendor) { + if ( + includes(rule.vendorExceptions, currentModule) || + ( + utils.deepAccess(consentData, 'vendorData.purpose.consents.1') === true && + utils.deepAccess(consentData, `vendorData.vendor.consents.${gvlid}`) === true + ) + ) { + isAllowed = true; + } + } else if (rule.enforcePurpose === false && rule.enforceVendor === true) { + if ( + includes(rule.vendorExceptions, currentModule) || + ( + utils.deepAccess(consentData, `vendorData.vendor.consents.${gvlid}`) === true + ) + ) { + isAllowed = true; + } + } else if (rule.enforcePurpose === false && rule.enforceVendor === false) { + if ( + !includes(rule.vendorExceptions, currentModule) || + ( + (utils.deepAccess(consentData, 'vendorData.purpose.consents.1') === true) && + (utils.deepAccess(consentData, `vendorData.vendor.consents.${gvlid}`) === true) + ) + ) { + isAllowed = true; + } + } else if (rule.enforcePurpose === true && rule.enforceVendor === false) { + if ( + (utils.deepAccess(consentData, 'vendorData.purpose.consents.1') === true) && + ( + !includes(rule.vendorExceptions, currentModule) || + (utils.deepAccess(consentData, `vendorData.vendor.consents.${gvlid}`) === true) + ) + ) { + isAllowed = true; + } + } + return isAllowed; +} + +/** + * This hook checks whether module has permission to access device or not. Device access include cookie and local storage + * @param {Function} fn reference to original function (used by hook logic) + * @param {Number=} gvlid gvlid of the module + * @param {string=} moduleName name of the module + */ +export function deviceAccessHook(fn, gvlid, moduleName, result) { + result = Object.assign({}, { + hasEnforcementHook: true + }); + if (!hasDeviceAccess()) { + utils.logWarn('Device access is disabled by Publisher'); + result.valid = false; + fn.call(this, gvlid, moduleName, result); + } else { + const consentData = gdprDataHandler.getConsentData(); + if (consentData && consentData.gdprApplies) { + if (consentData.apiVersion === 2) { + if (!gvlid) { + gvlid = getGvlid(); + } + const curModule = moduleName || config.getCurrentBidder(); + const purpose1Rule = find(enforcementRules, hasPurpose1); + let isAllowed = validateRules(purpose1Rule, consentData, curModule, gvlid); + if (isAllowed) { + result.valid = true; + fn.call(this, gvlid, moduleName, result); + } else { + utils.logWarn(`User denied Permission for Device access for ${curModule}`); + result.valid = false; + fn.call(this, gvlid, moduleName, result); + } + } else { + utils.logInfo('Enforcing TCF2 only'); + result.valid = true; + fn.call(this, gvlid, moduleName, result); + } + } else { + result.valid = true; + fn.call(this, gvlid, moduleName, result); + } + } +} + +/** + * This hook checks if a bidder has consent for user sync or not + * @param {Function} fn reference to original function (used by hook logic) + * @param {...any} args args + */ +export function userSyncHook(fn, ...args) { + const consentData = gdprDataHandler.getConsentData(); + if (consentData && consentData.gdprApplies) { + if (consentData.apiVersion === 2) { + const gvlid = getGvlid(); + const curBidder = config.getCurrentBidder(); + if (gvlid) { + const purpose1Rule = find(enforcementRules, hasPurpose1); + let isAllowed = validateRules(purpose1Rule, consentData, curBidder, gvlid); + if (isAllowed) { + fn.call(this, ...args); + } else { + utils.logWarn(`User sync not allowed for ${curBidder}`); + } + } else { + utils.logWarn(`User sync not allowed for ${curBidder}`); + } + } else { + utils.logInfo('Enforcing TCF2 only'); + fn.call(this, ...args); + } + } else { + fn.call(this, ...args); + } +} + +/** + * This hook checks if user id module is given consent or not + * @param {Function} fn reference to original function (used by hook logic) + * @param {Submodule[]} submodules Array of user id submodules + * @param {Object} consentData GDPR consent data + */ +export function userIdHook(fn, submodules, consentData) { + if (consentData && consentData.gdprApplies) { + if (consentData.apiVersion === 2) { + let userIdModules = submodules.map((submodule) => { + const gvlid = submodule.submodule.gvlid; + const moduleName = submodule.submodule.name; + if (gvlid) { + const purpose1Rule = find(enforcementRules, hasPurpose1); + let isAllowed = validateRules(purpose1Rule, consentData, moduleName, gvlid); + if (isAllowed) { + return submodule; + } else { + utils.logWarn(`User denied permission to fetch user id for ${moduleName} User id module`); + } + } else { + utils.logWarn(`User denied permission to fetch user id for ${moduleName} User id module`); + } + return undefined; + }).filter(module => module) + fn.call(this, userIdModules, consentData); + } else { + utils.logInfo('Enforcing TCF2 only'); + fn.call(this, submodules, consentData); + } + } else { + fn.call(this, submodules, consentData); + } +} + +const hasPurpose1 = (rule) => { return rule.purpose === purpose1 } + +/** + * A configuration function that initializes some module variables, as well as add hooks + * @param {Object} config GDPR enforcement config object + */ +export function setEnforcementConfig(config) { + const rules = utils.deepAccess(config, 'gdpr.rules'); + if (!rules) { + utils.logWarn('GDPR enforcement rules not defined, exiting enforcement module'); + return; + } + + enforcementRules = rules; + const hasDefinedPurpose1 = find(enforcementRules, hasPurpose1); + if (hasDefinedPurpose1 && !addedDeviceAccessHook) { + addedDeviceAccessHook = true; + validateStorageEnforcement.before(deviceAccessHook, 49); + registerSyncInner.before(userSyncHook, 48); + // Using getHook as user id and gdprEnforcement are both optional modules. Using import will auto include the file in build + getHook('validateGdprEnforcement').before(userIdHook, 47); + } +} + +config.getConfig('consentManagement', config => setEnforcementConfig(config.consentManagement)); diff --git a/modules/getintentBidAdapter.js b/modules/getintentBidAdapter.js index bc2ed093665..134dd0b4fc9 100644 --- a/modules/getintentBidAdapter.js +++ b/modules/getintentBidAdapter.js @@ -1,5 +1,5 @@ -import { registerBidder } from '../src/adapters/bidderFactory'; -import { isInteger } from '../src/utils'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { isInteger } from '../src/utils.js'; const BIDDER_CODE = 'getintent'; const IS_NET_REVENUE = true; @@ -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 e2693392578..00000000000 --- 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 ` - - - - `; } -/** - * Returns iframe document in a browser agnostic way - * @param {Object} iframe reference - * @return {Object} iframe `document` reference - */ -export function getIframeDocument(iframe) { - if (!iframe) { - return; - } - - let doc; - try { - if (iframe.contentWindow) { - doc = iframe.contentWindow.document; - } else if (iframe.contentDocument.document) { - doc = iframe.contentDocument.document; - } else { - doc = iframe.contentDocument; - } - } catch (e) { - internal.logError('Cannot get iframe document', e); - } - - return doc; -} - export function getValueString(param, val, defaultValue) { if (val === undefined || val === null) { return defaultValue; @@ -875,16 +689,6 @@ export function adUnitsFilter(filter, bid) { return includes(filter, bid && bid.adUnitCode); } -/** - * Check if parent iframe of passed document supports content rendering via 'srcdoc' property - * @param {HTMLDocument} doc document to check support of 'srcdoc' - */ -export function isSrcdocSupported(doc) { - // Firefox is excluded due to https://bugzilla.mozilla.org/show_bug.cgi?id=1265961 - return doc.defaultView && doc.defaultView.frameElement && - 'srcdoc' in doc.defaultView.frameElement && !/firefox/i.test(navigator.userAgent); -} - export function deepClone(obj) { return clone(obj); } @@ -898,7 +702,7 @@ export function inIframe() { } export function isSafariBrowser() { - return /^((?!chrome|android).)*safari/i.test(navigator.userAgent); + return /^((?!chrome|android|crios|fxios).)*safari/i.test(navigator.userAgent); } export function replaceAuctionPrice(str, cpm) { @@ -910,37 +714,20 @@ export function timestamp() { return new Date().getTime(); } -export function checkCookieSupport() { - if (window.navigator.cookieEnabled || !!document.cookie.length) { - return true; - } -} -export function cookiesAreEnabled() { - if (internal.checkCookieSupport()) { - return true; - } - window.document.cookie = 'prebid.cookieTest'; - return window.document.cookie.indexOf('prebid.cookieTest') != -1; -} - -export function getCookie(name) { - let m = window.document.cookie.match('(^|;)\\s*' + name + '\\s*=\\s*([^;]*)\\s*(;|$)'); - return m ? decodeURIComponent(m[2]) : null; -} - -export function setCookie(key, value, expires, sameSite) { - document.cookie = `${key}=${encodeURIComponent(value)}${(expires !== '') ? `; expires=${expires}` : ''}; path=/${sameSite ? `; SameSite=${sameSite}` : ''}`; +/** + * When the deviceAccess flag config option is false, no cookies should be read or set + * @returns {boolean} + */ +export function hasDeviceAccess() { + return config.getConfig('deviceAccess') !== false; } /** - * @returns {boolean} + * @returns {(boolean|undefined)} */ -export function localStorageIsEnabled () { - try { - localStorage.setItem('prebid.cookieTest', '1'); - return localStorage.getItem('prebid.cookieTest') === '1'; - } catch (error) { - return false; +export function checkCookieSupport() { + if (window.navigator.cookieEnabled || !!document.cookie.length) { + return true; } } @@ -983,19 +770,6 @@ export function groupBy(xs, key) { }, {}); } -/** - * Returns content for a friendly iframe to execute a URL in script tag - * @param {string} url URL to be executed in a script tag in a friendly iframe - * and are macros left to be replaced if required - */ -export function createContentToExecuteExtScriptInFriendlyFrame(url) { - if (!url) { - return ''; - } - - return ``; -} - /** * Build an object consisting of only defined parameters to avoid creating an * object with defined keys and undefined values. @@ -1098,6 +872,24 @@ export function isSlotMatchingAdUnitCode(adUnitCode) { return (slot) => compareCodeAndSlot(slot, adUnitCode); } +/** + * @summary Uses the adUnit's code in order to find a matching gptSlot on the page + */ +export function getGptSlotInfoForAdUnitCode(adUnitCode) { + let matchingSlot; + if (isGptPubadsDefined()) { + // find the first matching gpt slot on the page + matchingSlot = find(window.googletag.pubads().getSlots(), isSlotMatchingAdUnitCode(adUnitCode)); + } + if (matchingSlot) { + return { + gptSlot: matchingSlot.getAdUnitPath(), + divId: matchingSlot.getSlotElementId() + } + } + return {}; +}; + /** * Constructs warning message for when unsupported bidders are dropped from an adunit * @param {Object} adUnit ad unit from which the bidder is being dropped @@ -1114,18 +906,6 @@ export function unsupportedBidderMessage(adUnit, bidder) { `; } -/** - * Delete property from object - * @param {Object} object - * @param {string} prop - * @return {Object} object - */ -export function deletePropertyFromObject(object, prop) { - let result = Object.assign({}, object); - delete result[prop]; - return result; -} - /** * Checks input is integer or not * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isInteger @@ -1262,32 +1042,6 @@ export function convertTypes(types, params) { return params; } -export function setDataInLocalStorage(key, value) { - if (hasLocalStorage()) { - window.localStorage.setItem(key, value); - } -} - -export function getDataFromLocalStorage(key) { - if (hasLocalStorage()) { - return window.localStorage.getItem(key); - } -} - -export function removeDataFromLocalStorage(key) { - if (hasLocalStorage()) { - window.localStorage.removeItem(key); - } -} - -export function hasLocalStorage() { - try { - return !!window.localStorage; - } catch (e) { - logError('Local storage api disabled'); - } -} - export function isArrayOfNums(val, size) { return (isArray(val)) && ((size) ? val.length === size : true) && (val.every(v => isInteger(v))); } @@ -1350,3 +1104,93 @@ export function compareOn(property) { return 0; } } + +export function parseQS(query) { + return !query ? {} : query + .replace(/^\?/, '') + .split('&') + .reduce((acc, criteria) => { + let [k, v] = criteria.split('='); + if (/\[\]$/.test(k)) { + k = k.replace('[]', ''); + acc[k] = acc[k] || []; + acc[k].push(v); + } else { + acc[k] = v || ''; + } + return acc; + }, {}); +} + +export function formatQS(query) { + return Object + .keys(query) + .map(k => Array.isArray(query[k]) + ? query[k].map(v => `${k}[]=${v}`).join('&') + : `${k}=${query[k]}`) + .join('&'); +} + +export function parseUrl(url, options) { + let parsed = document.createElement('a'); + if (options && 'noDecodeWholeURL' in options && options.noDecodeWholeURL) { + parsed.href = url; + } else { + parsed.href = decodeURIComponent(url); + } + // in window.location 'search' is string, not object + let qsAsString = (options && 'decodeSearchAsString' in options && options.decodeSearchAsString); + return { + href: parsed.href, + protocol: (parsed.protocol || '').replace(/:$/, ''), + hostname: parsed.hostname, + port: +parsed.port, + pathname: parsed.pathname.replace(/^(?!\/)/, '/'), + search: (qsAsString) ? parsed.search : internal.parseQS(parsed.search || ''), + hash: (parsed.hash || '').replace(/^#/, ''), + host: parsed.host || window.location.host + }; +} + +export function buildUrl(obj) { + return (obj.protocol || 'http') + '://' + + (obj.host || + obj.hostname + (obj.port ? `:${obj.port}` : '')) + + (obj.pathname || '') + + (obj.search ? `?${internal.formatQS(obj.search || '')}` : '') + + (obj.hash ? `#${obj.hash}` : ''); +} + +/** + * This function compares two objects for checking their equivalence. + * @param {Object} obj1 + * @param {Object} obj2 + * @returns {boolean} + */ +export function deepEqual(obj1, obj2) { + return deepequal(obj1, obj2); +} + +export function mergeDeep(target, ...sources) { + if (!sources.length) return target; + const source = sources.shift(); + + if (isPlainObject(target) && isPlainObject(source)) { + for (const key in source) { + if (isPlainObject(source[key])) { + if (!target[key]) Object.assign(target, { [key]: {} }); + mergeDeep(target[key], source[key]); + } else if (isArray(source[key])) { + if (!target[key]) { + Object.assign(target, { [key]: source[key] }); + } else if (isArray(target[key])) { + target[key] = target[key].concat(source[key]); + } + } else { + Object.assign(target, { [key]: source[key] }); + } + } + } + + return mergeDeep(target, ...sources); +} diff --git a/src/video.js b/src/video.js index 57f44a76764..c3deb73ad4d 100644 --- a/src/video.js +++ b/src/video.js @@ -1,8 +1,8 @@ -import adapterManager from './adapterManager'; -import { getBidRequest, deepAccess, logError } from './utils'; -import { config } from '../src/config'; -import includes from 'core-js/library/fn/array/includes'; -import { hook } from './hook'; +import adapterManager from './adapterManager.js'; +import { getBidRequest, deepAccess, logError } from './utils.js'; +import { config } from '../src/config.js'; +import includes from 'core-js/library/fn/array/includes.js'; +import { hook } from './hook.js'; const VIDEO_MEDIA_TYPE = 'video'; export const OUTSTREAM = 'outstream'; diff --git a/src/videoCache.js b/src/videoCache.js index 4a715cb1fe3..c2557c7945e 100644 --- a/src/videoCache.js +++ b/src/videoCache.js @@ -9,8 +9,8 @@ * This trickery helps integrate with ad servers, which set character limits on request params. */ -import { ajax } from './ajax'; -import { config } from '../src/config'; +import { ajax } from './ajax.js'; +import { config } from '../src/config.js'; /** * @typedef {object} CacheableUrlBid @@ -59,8 +59,11 @@ function wrapURI(uri, impUrl) { * @param {CacheableBid} bid */ function toStorageRequest(bid) { - const vastValue = bid.vastXml ? bid.vastXml : wrapURI(bid.vastUrl, bid.vastImpUrl); - + let vastValue = bid.vastXml ? bid.vastXml : wrapURI(bid.vastUrl, bid.vastImpUrl); + /* istanbul ignore next */ + if (window && window.PWT) { + vastValue = window.PWT.UpdateVastWithTracker(bid, vastValue); + } let payload = { type: 'xml', value: vastValue, diff --git a/test/.eslintrc.js b/test/.eslintrc.js index 4cd5a854ac4..842bccd99b1 100644 --- a/test/.eslintrc.js +++ b/test/.eslintrc.js @@ -35,6 +35,6 @@ module.exports = { "no-unused-vars": "off", "no-use-before-define": "off", "no-useless-escape": "off", - "one-var": "off", + "one-var": "off" } }; diff --git a/test/mock-server/expectations/request-response-pairs/currency/index.js b/test/mock-server/expectations/request-response-pairs/currency/index.js new file mode 100644 index 00000000000..1f809476afa --- /dev/null +++ b/test/mock-server/expectations/request-response-pairs/currency/index.js @@ -0,0 +1,175 @@ +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 + * + */ + +/** + * 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 + }, { + 'sizes': [{ + 'width': 1, + 'height': 1 + }], + 'ad_types': ['native'], + 'id': 13232354, + 'allow_smaller_sizes': true, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'native': { + 'layouts': [{ + 'title': { + 'required': true + }, + 'description': { + 'required': true + }, + 'main_image': { + 'required': true + }, + 'sponsored_by': { + 'required': true + }, + 'icon': { + 'required': false + } + }] + } + }], + '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': '232f6ceccb3749', + 'tag_id': 13144370, + 'auction_id': '4842409943576641356', + 'nobid': false, + 'no_ad_url': 'http://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2Ftest%2Fpages%2Fmodules%2Fcurrency.html%3Fpbjs_debug%3Dtrue&e=wqT_3QK7CKA7BAAAAwDWAAUBCNvV-_AFEMz-0f3_xeyZQxjCs_b6q5D9_0oqNgkAAAkCABEJBywAABkAAACA61HgPyEREgApEQkAMREb8GkwsqKiBjjtSEDtSEgAUABYnPFbYABotc95eACAAQGKAQCSAQNVU0SYAawCoAHYBKgBAbABALgBAcABAMgBAtABANgBAOABAPABAIoCO3VmKCdhJywgMjUyOTg4NSwgMTU3OTA4NDUwNyk7AR0scicsIDk4NDkzNTgxNh4A8NCSArUCIVpqeldtZ2l1c0s0S0VJM0oteTRZQUNDYzhWc3dBRGdBUUFSSTdVaFFzcUtpQmxnQVlNSUdhQUJ3RG5qd0U0QUJUSWdCOEJPUUFRQ1lBUUNnQVFHb0FRT3dBUUM1QVNtTGlJTUFBT0Ffd1FFcGk0aURBQURnUDhrQmxiMDhGYV9INERfWkFRQUFBQUFBQVBBXzRBRUE5UUVBQUFBQW1BSUFvQUlBdFFJQUFBQUF2UUlBQUFBQTRBSUE2QUlBLUFJQWdBTUJtQU1CcUFPdQHEiHVnTUpVMGxPTXpvME56TTE0QU80R1lnRUFKQUVBSmdFQWNFCV0FAQhESkIFCAkBGDJBUUE4UVEJDQEBLFBnRUFJZ0ZfeVNwQhEXNFBBX5oCiQEhblE4cUxBNjkBJG5QRmJJQVFvQUQRZBBEZ1B6bzKRABBRTGdaUx1NAFURDAxBQUFXHQwAWR0MAGEdDABjHQzwQGVBQS7CAi9odHRwOi8vcHJlYmlkLm9yZy9kZXYtZG9jcy9nZXR0aW5nLXN0YXJ0ZWQuaHRtbNgCAOACrZhI6gJLDTpIdGVzdC5sb2NhbGhvc3Q6OTk5OQUUWC9wYWdlcy9tb2R1bGVzL2N1cnJlbmN5BUbwQD9wYmpzX2RlYnVnPXRydWWAAwCIAwGQAwCYAxegAwGqAwDAA6wCyAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzDbDwXpgEAKIECzEwLjc1Ljc0LjY5qATikAGyBBIIBBAEGKwCIPoBKAEoAjAAOAK4BADABADIBADSBA45MzI1I1NJTjM6NDczNdoEAggA4AQB8ASNyfsuiAUBmAUAoAX_____BQMYAcAFAMkFAAUBFPA_0gUJCQULfAAAANgFAeAFAfAFmfQh-gUECAAQAJAGAJgGALgGAMEGASEwAADwv9AG9S_aBhYKEAkRGQFQEAAYAOAGAfIGAggAgAcBiAcAoAcB&s=16a5ea7c8d5eb050a368495961803753dd6086c2', + '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': 98493581, + 'media_type_id': 1, + 'media_subtype_id': 1, + 'cpm': 0.500000, + 'cpm_publisher_currency': 0.500000, + 'publisher_currency_code': '$', + 'brand_category_id': 53, + 'client_initiated_ad_counting': true, + 'rtb': { + 'banner': { + 'content': "
", + 'width': 300, + 'height': 600 + }, + 'trackers': [{ + 'impression_urls': ['http://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2Ftest%2Fpages%2Fmodules%2Fcurrency.html%3Fpbjs_debug%3Dtrue&e=wqT_3QLDCKBDBAAAAwDWAAUBCNvV-_AFEMz-0f3_xeyZQxjCs_b6q5D9_0oqNgkAAAECCOA_EQEHNAAA4D8ZAAAAgOtR4D8hERIAKREJADERG6gwsqKiBjjtSEDtSEgCUI3J-y5YnPFbYABotc95eJ64BYABAYoBA1VTRJIBAQbwUpgBrAKgAdgEqAEBsAEAuAEBwAEEyAEC0AEA2AEA4AEA8AEAigI7dWYoJ2EnLCAyNTI5ODg1LCAxNTc5MDg0NTA3KTt1ZigncicsIDk4NDkzNTgxNh4A8NCSArUCIVpqeldtZ2l1c0s0S0VJM0oteTRZQUNDYzhWc3dBRGdBUUFSSTdVaFFzcUtpQmxnQVlNSUdhQUJ3RG5qd0U0QUJUSWdCOEJPUUFRQ1lBUUNnQVFHb0FRT3dBUUM1QVNtTGlJTUFBT0Ffd1FFcGk0aURBQURnUDhrQmxiMDhGYV9INERfWkFRQUFBQUFBQVBBXzRBRUE5UUVBQUFBQW1BSUFvQUlBdFFJQUFBQUF2UUlBQUFBQTRBSUE2QUlBLUFJQWdBTUJtQU1CcUFPdQHEiHVnTUpVMGxPTXpvME56TTE0QU80R1lnRUFKQUVBSmdFQWNFCV0FAQhESkIFCAkBGDJBUUE4UVEJDQEBLFBnRUFJZ0ZfeVNwQhEXNFBBX5oCiQEhblE4cUxBNjkBJG5QRmJJQVFvQUQRZBBEZ1B6bzKRABBRTGdaUx1NAFURDAxBQUFXHQwAWR0MAGEdDABjHQzwQGVBQS7CAi9odHRwOi8vcHJlYmlkLm9yZy9kZXYtZG9jcy9nZXR0aW5nLXN0YXJ0ZWQuaHRtbNgCAOACrZhI6gJLDTpIdGVzdC5sb2NhbGhvc3Q6OTk5OQUUWC9wYWdlcy9tb2R1bGVzL2N1cnJlbmN5BUbwQD9wYmpzX2RlYnVnPXRydWWAAwCIAwGQAwCYAxegAwGqAwDAA6wCyAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzDbDwXpgEAKIECzEwLjc1Ljc0LjY5qATikAGyBBIIBBAEGKwCIPoBKAEoAjAAOAK4BADABADIBADSBA45MzI1I1NJTjM6NDczNdoEAggB4AQB8ASNyfsuiAUBmAUAoAX_____BQMYAcAFAMkFAAUBFPA_0gUJCQULfAAAANgFAeAFAfAFmfQh-gUECAAQAJAGAJgGALgGAMEGASEwAADwP9AG9S_aBhYKEAkRGQFQEAAYAOAGAfIGAggAgAcBiAcAoAcB&s=9c378bb4ca21a7509f69955fb4e6fe72035190c6'], + 'video_events': {} + }] + } + }] + }, { + 'uuid': '3867e6fdb23eb6', + 'tag_id': 13232354, + 'auction_id': '8100967561168057198', + 'nobid': false, + 'no_ad_url': 'http://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2Ftest%2Fpages%2Fmodules%2Fcurrency.html%3Fpbjs_debug%3Dtrue&e=wqT_3QKECKAEBAAAAwDWAAUBCNvV-_AFEO7mieO34pq2cBjCs_b6q5D9_0oqNgkAAAkCABEJBwgAABkJCQgkQCEJCQgAACkRCQAxCQnwaSRAMOLRpwY47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEBwAEAyAEC0AEA2AEA4AEA8AEAigI7dWYoJ2EnLCAyNTI5ODg1LCAxNTc5MDg0NTA3KTsBHSxyJywgOTc0OTQyMDQ2HgDwmpICtQIhMVR6c3lRajgtTHdLRUx6SnZpNFlBQ0NjOFZzd0FEZ0FRQVJJN1VoUTR0R25CbGdBWU1JR2FBQndBSGdBZ0FGTWlBSHdFNUFCQUpnQkFLQUJBYWdCQTdBQkFMa0I4NjFxcEFBQUpFREJBZk90YXFRQUFDUkF5UUc5QzZTMEtFampQOWtCQUFBQUFBQUE4RF9nQVFEMUFRAQ8sQ1lBZ0NnQWdDMUFnBRAAOQkI8EBEZ0FnRG9BZ0Q0QWdDQUF3R1lBd0dvQV96NHZBcTZBd2xUU1U0ek9qUTNNelhnQTdnWmlBUUFrQVFBbUFRQndRUQFNCQEITWtFCQkBARhEWUJBRHhCAQsNASwtQVFBaUFYX0pLa0YNEzxBOEQ4LpoCiQEhZUE4dE1BNjkBJG5QRmJJQVFvQUQVWFhrUURvSlUwbE9Nem8wTnpNMVFMZ1pTUQ1PDFBBX1URDAxBQUFXHQwAWR0MAGEdDABjHQygZUFBLtgCAOACrZhI6gJLaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkFFPDXL3BhZ2VzL21vZHVsZXMvY3VycmVuY3kuaHRtbD9wYmpzX2RlYnVnPXRydWWAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My9wcmViaWSYBACiBAsxMC43NS43NC42OagE4pABsgQOCAAQARgAIAAoADAAOAK4BADABADIBADSBA45MzI1I1NJTjM6NDczNdoEAggA4AQB8AS8yb4uiAUBmAUAoAX___________8BwAUAyQUAAAAAAADwP9IFCQkAaVZ0ANgFAeAFAfAFmfQh-gUECAAQAJAGAZgGALgGAMEGCSQo8L_QBvUv2gYWChAJERkBUBAAGADgBgzyBgIIAIAHAYgHAKAHQQ..&s=428486554947609aac96ed5569d9bb2dd2be5502', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'native', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 97494204, + 'media_type_id': 12, + 'media_subtype_id': 65, + 'cpm': 10.000000, + 'cpm_publisher_currency': 10.000000, + 'publisher_currency_code': '$', + 'brand_category_id': 53, + 'client_initiated_ad_counting': true, + 'viewability': { + 'config': '' + }, + 'rtb': { + 'native': { + 'title': 'This is a Prebid Native Creative', + 'desc': 'This is a Prebid Native Creative. There are many like it, but this one is mine.', + 'sponsored': 'Prebid.org', + 'icon': { + 'url': 'http://vcdn.adnxs.com/p/creative-image/1a/3e/e9/5b/1a3ee95b-06cd-4260-98c7-0258627c9197.png', + 'width': 127, + 'height': 83, + 'prevent_crop': false + }, + 'main_img': { + 'url': 'http://vcdn.adnxs.com/p/creative-image/f8/7f/0f/13/f87f0f13-230c-4f05-8087-db9216e393de.jpg', + 'width': 989, + 'height': 742, + 'prevent_crop': false + }, + 'link': { + 'url': 'http://prebid.org/dev-docs/show-native-ads.html', + 'click_trackers': ['http://sin3-ib.adnxs.com/click?AAAAAAAAJEAAAAAAAAAkQAAAAAAAACRAAAAAAAAAJEAAAAAAAAAkQG5zYnwTa2xwwpldv4L0_0rb6h5eAAAAAOLoyQBtJAAAbSQAAAIAAAC8pM8FnPgWAAAAAABVU0QAVVNEAAEAAQBNXQAAAAABAQQCAAAAALoAYBc26wAAAAA./bcr=AAAAAAAA8D8=/cnd=%21eA8tMAj8-LwKELzJvi4YnPFbIAQoADEAAAAAAAAkQDoJU0lOMzo0NzM1QLgZSQAAAAAAAPA_UQAAAAAAAAAAWQAAAAAAAAAAYQAAAAAAAAAAaQAAAAAAAAAAcQAAAAAAAAAAeAA./cca=OTMyNSNTSU4zOjQ3MzU=/bn=89118/'] + }, + 'impression_trackers': ['http://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2Ftest%2Fpages%2Fmodules%2Fcurrency.html%3Fpbjs_debug%3Dtrue&e=wqT_3QKMCKAMBAAAAwDWAAUBCNvV-_AFEO7mieO34pq2cBjCs_b6q5D9_0oqNgkAAAECCCRAEQEHEAAAJEAZEQkAIREJACkRCQAxEQmoMOLRpwY47UhA7UhIAlC8yb4uWJzxW2AAaM26dXieuAWAAQGKAQNVU0SSAQEG8FKYAQGgAQGoAQGwAQC4AQHAAQTIAQLQAQDYAQDgAQDwAQCKAjt1ZignYScsIDI1Mjk4ODUsIDE1NzkwODQ1MDcpO3VmKCdyJywgOTc0OTQyMDQsIC4eAPCakgK1AiExVHpzeVFqOC1Md0tFTHpKdmk0WUFDQ2M4VnN3QURnQVFBUkk3VWhRNHRHbkJsZ0FZTUlHYUFCd0FIZ0FnQUZNaUFId0U1QUJBSmdCQUtBQkFhZ0JBN0FCQUxrQjg2MXFwQUFBSkVEQkFmT3RhcVFBQUNSQXlRRzlDNlMwS0VqalA5a0JBQUFBQUFBQThEX2dBUUQxQVEBDyxDWUFnQ2dBZ0MxQWcFEAA5CQjwQERnQWdEb0FnRDRBZ0NBQXdHWUF3R29BX3o0dkFxNkF3bFRTVTR6T2pRM016WGdBN2daaUFRQWtBUUFtQVFCd1FRAU0JAQhNa0UJCQEBGERZQkFEeEIBCw0BLC1BUUFpQVhfSktrRg0TPEE4RDgumgKJASFlQTh0TUE2OQEkblBGYklBUW9BRBVYWGtRRG9KVTBsT016bzBOek0xUUxnWlNRDU8MUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDKBlQUEu2AIA4AKtmEjqAktodHRwOi8vdGVzdC5sb2NhbGhvc3Q6OTk5OQUU8NcvcGFnZXMvbW9kdWxlcy9jdXJyZW5jeS5odG1sP3BianNfZGVidWc9dHJ1ZYADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIECzEwLjc1Ljc0LjY5qATikAGyBA4IABABGAAgACgAMAA4ArgEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzM12gQCCAHgBAHwBLzJvi6IBQGYBQCgBf___________wHABQDJBQAAAAAAAPA_0gUJCQBpXnQA2AUB4AUB8AWZ9CH6BQQIABAAkAYBmAYAuAYAwQYJJCjwP9AG9S_aBhYKEAkRGQFQEAAYAOAGDPIGAggAgAcBiAcAoAdB&s=d6c58ebc137658c5dd258579c2575ad499e7a7b4'], + 'id': 97494204 + } + } + }] + }] + } + } + } +} diff --git a/test/mock-server/expectations/request-response-pairs/gdpr/index.js b/test/mock-server/expectations/request-response-pairs/gdpr/index.js new file mode 100644 index 00000000000..646559f2a7f --- /dev/null +++ b/test/mock-server/expectations/request-response-pairs/gdpr/index.js @@ -0,0 +1,94 @@ +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 + * + */ + +/** + * 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': '27c4cea6dfcad4', + 'tag_id': 13144370, + 'auction_id': '6784868202366971885', + 'nobid': false, + 'no_ad_url': 'http://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Fgpt%2Fgdpr_hello_world.html%3Fpbjs_debug%3Dtrue&e=wqT_3QL0CWz0BAAAAwDWAAUBCKKt0fAFEO3ftM_qtayUXhj_EQEQASo2CQANAQARDQgoABkAAACA61HgPyEREgApEQkAMREb8GkwsqKiBjjtSEDtSEgAUABYnPFbYABotc95eACAAQGKAQCSAQNVU0SYAawCoAH6AagBAbABALgBAcABAMgBAtABANgBAOABAPABAIoCO3VmKCdhJywgMjUyOTg4NSwgMTU3ODM5MTIwMik7AR0scicsIDk2ODQ2MDM1Nh4A9A4BkgLJAiF0ajlmS2dpdXNLNEtFTk9CbHk0WUFDQ2M4VnN3QURnQVFBUkk3VWhRc3FLaUJsZ0FZUF9fX184UGFBQndBWGdCZ0FFQmlBRUJrQUVCbUFFQm9BRUJxQUVEc0FFQXVRRXBpNGlEQUFEZ1A4RUJLWXVJZ3dBQTREX0pBZWxBS28zZEV1OF8yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBTUFDQWNnQ0FkQUNBZGdDQWVBQ0FPZ0NBUGdDQUlBREFaZ0RBYWdEcnJDdUNyb0RDVk5KVGpNNk5EY3pPZUFEX0JpSUJBQ1FCQUNZQkFIQkJBQUFBQQmDCHlRUQkJAQEYTmdFQVBFRQELCQEwRDRCQUNJQllNbHFRVQkTREFEd1B3Li6aAokBIWZnOFhHUTZNASRuUEZiSUFRb0FEEUhYRGdQem9KVTBsT016bzBOek01UVB3WVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M8EBlQUEuwgIvaHR0cDovL3ByZWJpZC5vcmcvZGV2LWRvY3MvZ2V0dGluZy1zdGFydGVkLmh0bWzYAgDgAq2YSOoCWA068IF0ZXN0LmxvY2FsaG9zdDo5OTk5L2ludGVncmF0aW9uRXhhbXBsZXMvZ3B0L2dkcHJfaGVsbG9fd29ybGQuaHRtbD9wYmpzX2RlYnVnPXRydWWAAwGIAwGQAwCYAxegAwGqAwDAA6wCyAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzDb3wW5gEAKIECzEwLjc1Ljc0LjY5qAS_NrIEEggEEAQYrAIg-gEoASgCMAA4ArgEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzM52gQCCADgBAHwBNOBly6IBQGYBQCgBf__bcwUAcAFAMkFaakU8D_SBQkJCQyIAADYBQHgBQHwBQH6BQQIABAAkAYAmAYAsgaWAUJPc3kwUXkBBixYaUFBQUJBRU5DMi0hswh0RjdhJQxfX185AQXwcV9fOXV6X092X3ZfZl9fMzNlOF9fOXZfbF83Xy1fX191Xy0zM2Q0dV8xdmY5OXlmbTEtN2V0cjN0cF84N3VlczJfWHVyX183OV9fM3ozXzlweFA3OGs4OXI3MzM3RXdfdi1fdi1iN0pDT05fQbgGAcEGAAW-KPC_0Ab1L9oGFgoQBRAdAVAQABgA4AYB8gYCCACABwGIBwCgBwE.&s=896d8d25ed5c73ed4b49adebaa58ba23ed6afa43', + '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, + '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%2Fgdpr_hello_world.html%3Fpbjs_debug%3Dtrue&e=wqT_3QL8CWz8BAAAAwDWAAUBCKKt0fAFEO3ftM_qtayUXhj_EQEQASo2CQAFAQjgPxEFCDAA4D8ZAAAAgOtR4D8hERIAKREJADERG6gwsqKiBjjtSEDtSEgCUNOBly5YnPFbYABotc95eMu4BYABAYoBA1VTRJIBAQbwUpgBrAKgAfoBqAEBsAEAuAEBwAEEyAEC0AEA2AEA4AEA8AEAigI7dWYoJ2EnLCAyNTI5ODg1LCAxNTc4MzkxMjAyKTt1ZigncicsIDk2ODQ2MDM1Nh4A9A4BkgLJAiF0ajlmS2dpdXNLNEtFTk9CbHk0WUFDQ2M4VnN3QURnQVFBUkk3VWhRc3FLaUJsZ0FZUF9fX184UGFBQndBWGdCZ0FFQmlBRUJrQUVCbUFFQm9BRUJxQUVEc0FFQXVRRXBpNGlEQUFEZ1A4RUJLWXVJZ3dBQTREX0pBZWxBS28zZEV1OF8yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBTUFDQWNnQ0FkQUNBZGdDQWVBQ0FPZ0NBUGdDQUlBREFaZ0RBYWdEcnJDdUNyb0RDVk5KVGpNNk5EY3pPZUFEX0JpSUJBQ1FCQUNZQkFIQkJBQUFBQQmDCHlRUQkJAQEYTmdFQVBFRQELCQEwRDRCQUNJQllNbHFRVQkTREFEd1B3Li6aAokBIWZnOFhHUTZNASRuUEZiSUFRb0FEEUhYRGdQem9KVTBsT016bzBOek01UVB3WVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M8EBlQUEuwgIvaHR0cDovL3ByZWJpZC5vcmcvZGV2LWRvY3MvZ2V0dGluZy1zdGFydGVkLmh0bWzYAgDgAq2YSOoCWA068IF0ZXN0LmxvY2FsaG9zdDo5OTk5L2ludGVncmF0aW9uRXhhbXBsZXMvZ3B0L2dkcHJfaGVsbG9fd29ybGQuaHRtbD9wYmpzX2RlYnVnPXRydWWAAwGIAwGQAwCYAxegAwGqAwDAA6wCyAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzDb3wW5gEAKIECzEwLjc1Ljc0LjY5qAS_NrIEEggEEAQYrAIg-gEoASgCMAA4ArgEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzM52gQCCAHgBAHwBNOBly6IBQGYBQCgBf__bdQUAcAFAMkFabEU8D_SBQkJCQyIAADYBQHgBQHwBQH6BQQIABAAkAYAmAYAsgaWAUJPc3kwUXkBBixYaUFBQUJBRU5DMi0hswh0RjdhJQxfX185AQXwcV9fOXV6X092X3ZfZl9fMzNlOF9fOXZfbF83Xy1fX191Xy0zM2Q0dV8xdmY5OXlmbTEtN2V0cjN0cF84N3VlczJfWHVyX183OV9fM3ozXzlweFA3OGs4OXI3MzM3RXdfdi1fdi1iN0pDT05fQbgGAcEGAAW-KPA_0Ab1L9oGFgoQBRAdAVAQABgA4AYB8gYCCACABwGIBwCgBwE.&s=1ad011df80b035fdd957f6ae84e46bdeebae9f83'], + 'video_events': {} + }] + } + }] + }] + } + } + } +} diff --git a/test/mock-server/expectations/request-response-pairs/instream/index.js b/test/mock-server/expectations/request-response-pairs/instream/index.js new file mode 100644 index 00000000000..5164e56e093 --- /dev/null +++ b/test/mock-server/expectations/request-response-pairs/instream/index.js @@ -0,0 +1,94 @@ +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 + * + */ + +/** + * 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': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 13232361, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': {} + }], + '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': '206465a8c326a5', + 'tag_id': 13232361, + 'auction_id': '1398509384102899505', + 'nobid': false, + 'no_ad_url': 'http://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2Ftest%2Fpages%2Finstream.html&e=wqT_3QKxCKAxBAAAAwDWAAUBCKXQzPAFELHeg_SAnKC0ExjCs_b6q5D9_0oqNgkAAAkCABEJBywAABkAAADgehQUQCEREgApEQkAMREb8Hkw6dGnBjjtSEDtSEgAUABYnPFbYABozbp1eACAAQGKAQCSAQNVU0SYAQGgAQGoAQGwAQC4AQPAAQDIAQLQAQDYAQDgAQDwAQCKAjt1ZignYScsIDI1Mjk4ODUsIDE1NzgzMTM3NjUpO3VmKCdyJywgOTc1MTc3NzEsIC4eAPD1kgK1AiF5andtb2dpMi1Md0tFTXVCd0M0WUFDQ2M4VnN3QURnQVFBUkk3VWhRNmRHbkJsZ0FZTUlHYUFCd0tIZ0dnQUU4aUFFR2tBRUFtQUVBb0FFQnFBRURzQUVBdVFIenJXcWtBQUFVUU1FQjg2MXFwQUFBRkVESkFmZjUwcVFyNGVvXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHR2aThDcm9EQ1ZOSlRqTTZORGN6T09BRC1SaUlCQUNRQkFDWUJBSEJCBUUJAQh5UVEJCQEBFE5nRUFQRRGNAZAsNEJBQ0lCWUlscVFVAREBFDx3UHcuLpoCiQEhTGc5WkRRNjkBJG5QRmJJQVFvQUQVSFRVUURvSlUwbE9Nem8wTnpNNFFQa1lTEXgMUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDPBSZUFBLsICP2h0dHA6Ly9wcmViaWQub3JnL2Rldi1kb2NzL3Nob3ctdmlkZW8td2l0aC1hLWRmcC12aWRlby10YWcuaHRtbNgCAOACrZhI6gIzaHQFSkh0ZXN0LmxvY2FsaG9zdDo5OTk5BRQ4L3BhZ2VzL2luc3RyZWFtBT7IgAMAiAMBkAMAmAMXoAMBqgMAwAPgqAHIAwDYAwDgAwDoAwD4AwGABACSBA0vdXQvdjMvCanwXpgEAKIECzEwLjc1Ljc0LjY5qAS0LLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzM42gQCCADgBADwBMuBwC6IBQGYBQCgBf______AQMUAcAFAMkFaX8U8D_SBQkJCQx4AADYBQHgBQHwBcOVC_oFBAgAEACQBgGYBgC4BgDBBgklKPC_0Ab1L9oGFgoQCREZAVAQABgA4AYE8gYCCACABwGIBwCgB0A.&s=6805157848bdfdf973d0dbafff4bb9b4c4ce7e60', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'http://sin3-ib.adnxs.com/vast_track/v2?info=aAAAAAMArgAFAQklKBNeAAAAABEx74AO4IBoExklKBNeAAAAACDLgcAuKAAw7Ug47UhA0-hISLuv1AFQ6dGnBljDlQtiAi0taAFwAXgAgAEBiAEBkAGABZgB4AOgAQCoAcuBwC6wAQE.&s=07e6e5f2f03cc92e899c3ddbf4e2988e966caaa2&event_type=1', + 'usersync_url': 'http%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 97517771, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 5.000000, + 'cpm_publisher_currency': 5.000000, + 'publisher_currency_code': '$', + 'brand_category_id': 36, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 30000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'http://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2Ftest%2Fpages%2Finstream.html&e=wqT_3QKNCaCNBAAAAwDWAAUBCKXQzPAFELHeg_SAnKC0ExjCs_b6q5D9_0oqNgkAAAECCBRAEQEHNAAAFEAZAAAA4HoUFEAhERIAKREJADERG6gw6dGnBjjtSEDtSEgCUMuBwC5YnPFbYABozbp1eJG4BYABAYoBA1VTRJIBAQbwUpgBAaABAagBAbABALgBA8ABBMgBAtABANgBAOABAPABAIoCO3VmKCdhJywgMjUyOTg4NSwgMTU3ODMxMzc2NSk7dWYoJ3InLCA5NzUxNzc3MSwgLh4A8PWSArUCIXlqd21vZ2kyLUx3S0VNdUJ3QzRZQUNDYzhWc3dBRGdBUUFSSTdVaFE2ZEduQmxnQVlNSUdhQUJ3S0hnR2dBRThpQUVHa0FFQW1BRUFvQUVCcUFFRHNBRUF1UUh6cldxa0FBQVVRTUVCODYxcXBBQUFGRURKQWZmNTBxUXI0ZW9fMlFFQUFBQUFBQUR3UC1BQkFQVUJBQUFBQUpnQ0FLQUNBTFVDQUFBQUFMMENBQUFBQU9BQ0FPZ0NBUGdDQUlBREFaZ0RBYWdEdHZpOENyb0RDVk5KVGpNNk5EY3pPT0FELVJpSUJBQ1FCQUNZQkFIQkIFRQkBCHlRUQkJAQEUTmdFQVBFEY0BkCw0QkFDSUJZSWxxUVUBEQEUPHdQdy4umgKJASFMZzlaRFE2OQEkblBGYklBUW9BRBVIVFVRRG9KVTBsT016bzBOek00UVBrWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M8FJlQUEuwgI_aHR0cDovL3ByZWJpZC5vcmcvZGV2LWRvY3Mvc2hvdy12aWRlby13aXRoLWEtZGZwLXZpZGVvLXRhZy5odG1s2AIA4AKtmEjqAjNodAVKSHRlc3QubG9jYWxob3N0Ojk5OTkFFDgvcGFnZXMvaW5zdHJlYW0FPmjyAhMKD0NVU1RPTV9NT0RFTF9JRBIA8gIaChYyFgAgTEVBRl9OQU1FAR0IHgoaNh0ACEFTVAE-4ElGSUVEEgCAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92Mw398F6YBACiBAsxMC43NS43NC42OagEtCyyBBIIARACGIAFIOADKAEoAjAAOAO4BADABADIBADSBA45MzI1I1NJTjM6NDczONoEAggB4AQA8ATLgcAuiAUBmAUAoAX______wEDFAHABQDJBWnbFPA_0gUJCQkMeAAA2AUB4AUB8AXDlQv6BQQIABAAkAYBmAYAuAYAwQYJJSjwP9AG9S_aBhYKEAkRGQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=68b9d39d60a72307a201e479000a8c7be5508188' + } + } + }] + }] + } + } + } +} diff --git a/test/mock-server/expectations/request-response-pairs/longform/ad_server_translation_request_1.js b/test/mock-server/expectations/request-response-pairs/longform/ad_server_translation_request_1.js new file mode 100644 index 00000000000..d92e64c6075 --- /dev/null +++ b/test/mock-server/expectations/request-response-pairs/longform/ad_server_translation_request_1.js @@ -0,0 +1,577 @@ +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 + * + */ + +/** + * 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': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'minduration': 15, + 'maxduration': 15 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'minduration': 15, + 'maxduration': 15 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'minduration': 15, + 'maxduration': 15 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'minduration': 15, + 'maxduration': 15 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'minduration': 15, + 'maxduration': 15 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'minduration': 15, + 'maxduration': 15 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'minduration': 15, + 'maxduration': 15 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'minduration': 15, + 'maxduration': 15 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'minduration': 15, + 'maxduration': 15 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'minduration': 15, + 'maxduration': 15 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'minduration': 30, + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'minduration': 30, + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'minduration': 30, + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'minduration': 30, + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'minduration': 30, + 'maxduration': 30 + } + }], + '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': '201bba5bb8827', + 'tag_id': 15394006, + 'auction_id': '7360998998672342781', + 'nobid': false, + 'no_ad_url': 'http://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_custom_adserver_translation.html&e=wqT_3QKiCKAiBAAAAwDWAAUBCN73l_AFEP39-97ssuGTZhiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3NDUwNDYyKTsBHTByJywgMTQ5NDE5NjAyNh8A8P2SArkCIVNqMmZTQWlua184UEVOTHNuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCdXVZQ2tBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFaQmtTcHl1c2Q4XzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHA1UF9EN29EQ1ZOSlRqTTZORGN6TS1BRHJoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJmMGtxUVUJE0RBRHdQdy4umgKJASFOZzhKRnc2PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOek16UUs0WVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M8GVlQUEu2AIA4AKtmEjqAmBodHRwOi8vdGVzdC5sb2NhbGhvc3Q6OTk5OS9pbnRlZ3JhdGlvbkV4YW1wbGVzL2xvbmdmb3JtL2Jhc2ljX3dfY3VzdG9tX2Fkc2VydmVyX3RyYW5zbGEBNfC2Lmh0bWyAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My9wcmViaWSYBACiBAsxMC43NS43NC42OagEksYEsgQSCAEQAhiABSDgAygBKAIwADgDuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ3MzPaBAIIAOAEAPAE0uyfR4gFAZgFAKAF____________AcAFAMkFAAAAAAAA8D_SBQkJAAAAZXZw2AUB4AUB8AXZugb6BQQIABAAkAYBmAYAuAYAwQYFIiwA8L_QBvUv2gYWChAJERkBUBAAGADgBgTyBgIIAIAHAYgHAKAHQA..&s=c92cbcde5c8bf8e053f86493dd4c4698da0392de', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'http://sin3-ib.adnxs.com/vast_track/v2?info=aAAAAAMArgAFAQne-wVeAAAAABH9_t7LloUnZhne-wVeAAAAACDS7J9HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1jZugZiAi0taAFwAXgAgAEBiAEBkAGABZgB4AOgAQCoAdLsn0ewAQE.&s=8e35c1264cd1b4f1d89f929c3a4a334cf6a68eca&event_type=1', + 'usersync_url': 'http%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149419602, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 24, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 15000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'http://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_custom_adserver_translation.html&e=wqT_3QL-COh-BAAAAwDWAAUBCN73l_AFEP39-97ssuGTZhiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQ0uyfR1ic8VtgAGjNunV40rgFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3NDUwNDYyKTt1ZigncicsIDE0OTQxOTYwMiwgMTUZH_D9kgK5AiFTajJmU0FpbmtfOFBFTkxzbjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQnV1WUNrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBWkJrU3B5dXNkOF8yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwNVBfRDdvRENWTkpUak02TkRjek0tQURyaGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCZjBrcVFVCRNEQUR3UHcuLpoCiQEhTmc4SkZ3Nj0BJG5QRmJJQVFvQUQVSFR1UURvSlUwbE9Nem8wTnpNelFLNFlTEXgMUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDPBlZUFBLtgCAOACrZhI6gJgaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193X2N1c3RvbV9hZHNlcnZlcl90cmFuc2xhATV8Lmh0bWzyAhMKD0NVU1RPTV9NT0RFTF9JRBIA8gIaChYyFgAgTEVBRl9OQU1FAR0IHgoaNh0ACEFTVAE-8J9JRklFRBIAgAMAiAMBkAMAmAMXoAMBqgMAwAPgqAHIAwDYAwDgAwDoAwD4AwGABACSBA0vdXQvdjMvcHJlYmlkmAQAogQLMTAuNzUuNzQuNjmoBJLGBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzMz2gQCCAHgBADwBNLsn0eIBQGYBQCgBf______AQUUAcAFAMkFacMU8D_SBQkJCQx4AADYBQHgBQHwBdm6BvoFBAgAEACQBgGYBgC4BgDBBgklKPA_0Ab1L9oGFgoQCREZAVAQABgA4AYE8gYCCACABwGIBwCgB0A.&s=ca640dffaea7bfcf2b0f2e11d8877821189b74bb' + } + } + }] + }, { + 'uuid': '201bba5bb8827', + 'tag_id': 15394006, + 'auction_id': '1919339751435064934', + 'nobid': false, + 'no_ad_url': 'http://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_custom_adserver_translation.html&e=wqT_3QKiCKAiBAAAAwDWAAUBCN73l_AFEOasy7zbqrfRGhiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3NDUwNDYyKTsBHTByJywgMTQ5NDE4MTIzNh8A8P2SArkCIU1EMUZJQWlua184UEVJdmhuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCdXVZQ2tBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFRclZ0ZGpIUGVBXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHA1UF9EN29EQ1ZOSlRqTTZORGN6TS1BRHJoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJmMGtxUVUJE0RBRHdQdy4umgKJASE1QTdmLVE2PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOek16UUs0WVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M8GVlQUEu2AIA4AKtmEjqAmBodHRwOi8vdGVzdC5sb2NhbGhvc3Q6OTk5OS9pbnRlZ3JhdGlvbkV4YW1wbGVzL2xvbmdmb3JtL2Jhc2ljX3dfY3VzdG9tX2Fkc2VydmVyX3RyYW5zbGEBNfC2Lmh0bWyAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My9wcmViaWSYBACiBAsxMC43NS43NC42OagEksYEsgQSCAEQAhiABSDgAygBKAIwADgDuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ3MzPaBAIIAOAEAPAEi-GfR4gFAZgFAKAF____________AcAFAMkFAAAAAAAA8D_SBQkJAAAAZXZw2AUB4AUB8AXa1gL6BQQIABAAkAYBmAYAuAYAwQYFIiwA8L_QBvUv2gYWChAJERkBUBAAGADgBgTyBgIIAIAHAYgHAKAHQA..&s=c3130de64bc0b8df258e603dfb96f78550ab0c3c', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'http://sin3-ib.adnxs.com/vast_track/v2?info=aAAAAAMArgAFAQne-wVeAAAAABFm1pK3Vd2iGhne-wVeAAAAACCL4Z9HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1ja1gJiAi0taAFwAXgAgAEBiAEBkAGABZgB4AOgAQCoAYvhn0ewAQE.&s=2c3cee10303d9b93531bed443c0781d905270598&event_type=1', + 'usersync_url': 'http%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149418123, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 12, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 15000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'http://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_custom_adserver_translation.html&e=wqT_3QL-COh-BAAAAwDWAAUBCN73l_AFEOasy7zbqrfRGhiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQi-GfR1ic8VtgAGjNunV40rgFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3NDUwNDYyKTt1ZigncicsIDE0OTQxODEyMywgMTUZH_D9kgK5AiFNRDFGSUFpbmtfOFBFSXZobjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQnV1WUNrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBUXJWdGRqSFBlQV8yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwNVBfRDdvRENWTkpUak02TkRjek0tQURyaGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCZjBrcVFVCRNEQUR3UHcuLpoCiQEhNUE3Zi1RNj0BJG5QRmJJQVFvQUQVSFR1UURvSlUwbE9Nem8wTnpNelFLNFlTEXgMUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDPBlZUFBLtgCAOACrZhI6gJgaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193X2N1c3RvbV9hZHNlcnZlcl90cmFuc2xhATV8Lmh0bWzyAhMKD0NVU1RPTV9NT0RFTF9JRBIA8gIaChYyFgAgTEVBRl9OQU1FAR0IHgoaNh0ACEFTVAE-8J9JRklFRBIAgAMAiAMBkAMAmAMXoAMBqgMAwAPgqAHIAwDYAwDgAwDoAwD4AwGABACSBA0vdXQvdjMvcHJlYmlkmAQAogQLMTAuNzUuNzQuNjmoBJLGBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzMz2gQCCAHgBADwBIvhn0eIBQGYBQCgBf______AQUUAcAFAMkFacMU8D_SBQkJCQx4AADYBQHgBQHwBdrWAvoFBAgAEACQBgGYBgC4BgDBBgklKPA_0Ab1L9oGFgoQCREZAVAQABgA4AYE8gYCCACABwGIBwCgB0A.&s=996a3937245f03e5eefb0cb69917d2d8d7f60424' + } + } + }] + }, { + 'uuid': '201bba5bb8827', + 'tag_id': 15394006, + 'auction_id': '3257875652791896280', + 'nobid': true, + 'ad_profile_id': 1182765 + }, { + 'uuid': '201bba5bb8827', + 'tag_id': 15394006, + 'auction_id': '5756905673624319729', + 'nobid': true, + 'ad_profile_id': 1182765 + }, { + 'uuid': '201bba5bb8827', + 'tag_id': 15394006, + 'auction_id': '4205438746002589111', + 'nobid': true, + 'ad_profile_id': 1182765 + }, { + 'uuid': '201bba5bb8827', + 'tag_id': 15394006, + 'auction_id': '204849530930208960', + 'nobid': true, + 'ad_profile_id': 1182765 + }, { + 'uuid': '201bba5bb8827', + 'tag_id': 15394006, + 'auction_id': '3482944224379652843', + 'nobid': true, + 'ad_profile_id': 1182765 + }, { + 'uuid': '201bba5bb8827', + 'tag_id': 15394006, + 'auction_id': '2123689132466331410', + 'nobid': true, + 'ad_profile_id': 1182765 + }, { + 'uuid': '201bba5bb8827', + 'tag_id': 15394006, + 'auction_id': '6150444453316813936', + 'nobid': true, + 'ad_profile_id': 1182765 + }, { + 'uuid': '201bba5bb8827', + 'tag_id': 15394006, + 'auction_id': '2810956382376737966', + 'nobid': true, + 'ad_profile_id': 1182765 + }, { + 'uuid': '201bba5bb8827', + 'tag_id': 15394006, + 'auction_id': '7164199537578897638', + 'nobid': false, + 'no_ad_url': 'http://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_custom_adserver_translation.html&e=wqT_3QKhCKAhBAAAAwDWAAUBCN73l_AFEObhocvZsJa2Yxiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3NDUwNDYyKTsBHTByJywgMTQ5NDE4NjcxNh8A8P2SArkCIXNENXVfQWlta184UEVLX2xuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCdXVZQ2tBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFYSEZfdmZOei1NXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHBwUF9EN29EQ1ZOSlRqTTZORGN6TS1BRHJoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJmMGtxUVUJE0RBRHdQdy4umgKJASFDd19DQnc2PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOek16UUs0WVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M8GVlQUEu2AIA4AKtmEjqAmBodHRwOi8vdGVzdC5sb2NhbGhvc3Q6OTk5OS9pbnRlZ3JhdGlvbkV4YW1wbGVzL2xvbmdmb3JtL2Jhc2ljX3dfY3VzdG9tX2Fkc2VydmVyX3RyYW5zbGEBNfC2Lmh0bWyAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My9wcmViaWSYBACiBAsxMC43NS43NC42OagEksYEsgQSCAEQAhiABSDgAygBKAIwADgDuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ3MzPaBAIIAOAEAPAEr-WfR4gFAZgFAKAF____________AcAFAMkFAAAAAAAA8D_SBQkJAAAAZXZs2AUB4AUB8AXgWPoFBAgAEACQBgGYBgC4BgDBBgUhLADwv9AG9S_aBhYKEAkRGQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=2b9ed1e2e7f27fea52cbdc64cb700195bbd14d75', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'http://sin3-ib.adnxs.com/vast_track/v2?info=ZwAAAAMArgAFAQne-wVeAAAAABHmcGiZhVlsYxne-wVeAAAAACCv5Z9HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1jgWGICLS1oAXABeACAAQGIAQGQAYAFmAHgA6ABAKgBr-WfR7ABAQ..&s=8ba7f141449cb45f8b6e12361a62d8d68aa9c812&event_type=1', + 'usersync_url': 'http%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149418671, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 30, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 30000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'http://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_custom_adserver_translation.html&e=wqT_3QL9COh9BAAAAwDWAAUBCN73l_AFEObhocvZsJa2Yxiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQr-WfR1ic8VtgAGjNunV40rgFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3NDUwNDYyKTt1ZigncicsIDE0OTQxODY3MSwgMTUZH_D9kgK5AiFzRDV1X0FpbWtfOFBFS19sbjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQnV1WUNrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBWEhGX3ZmTnotTV8yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwcFBfRDdvRENWTkpUak02TkRjek0tQURyaGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCZjBrcVFVCRNEQUR3UHcuLpoCiQEhQ3dfQ0J3Nj0BJG5QRmJJQVFvQUQVSFR1UURvSlUwbE9Nem8wTnpNelFLNFlTEXgMUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDPBlZUFBLtgCAOACrZhI6gJgaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193X2N1c3RvbV9hZHNlcnZlcl90cmFuc2xhATV8Lmh0bWzyAhMKD0NVU1RPTV9NT0RFTF9JRBIA8gIaChYyFgAgTEVBRl9OQU1FAR0IHgoaNh0ACEFTVAE-8J9JRklFRBIAgAMAiAMBkAMAmAMXoAMBqgMAwAPgqAHIAwDYAwDgAwDoAwD4AwGABACSBA0vdXQvdjMvcHJlYmlkmAQAogQLMTAuNzUuNzQuNjmoBJLGBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzMz2gQCCAHgBADwBK_ln0eIBQGYBQCgBf______AQUUAcAFAMkFacMU8D_SBQkJCQx0AADYBQHgBQHwBeBY-gUECAAQAJAGAZgGALgGAMEGCSQo8D_QBvUv2gYWChAJERkBUBAAGADgBgTyBgIIAIAHAYgHAKAHQA..&s=527640949733fba32740156d743d421eb1fe2863' + } + } + }] + }, { + 'uuid': '201bba5bb8827', + 'tag_id': 15394006, + 'auction_id': '8404712946290777461', + 'nobid': false, + 'no_ad_url': 'http://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_custom_adserver_translation.html&e=wqT_3QKiCKAiBAAAAwDWAAUBCN73l_AFEPW6p5bQvOLRdBiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3NDUwNDYyKTsBHTByJywgMTQ5NDE3OTUxNh8A8P2SArkCIWp6MkdiZ2lta184UEVOX2ZuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCdXVZQ2tBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFaQ0RhTlBDYk9NXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHBwUF9EN29EQ1ZOSlRqTTZORGN6TS1BRHJoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJmMGtxUVUJE0BBRHdQdy4umgKJASFOUS0yRjo9ASRuUEZiSUFRb0FEFUhUdVFEb0pVMGxPTXpvME56TXpRSzRZUxF4DFBBX1URDAxBQUFXHQwAWR0MAGEdDABjHQzwZWVBQS7YAgDgAq2YSOoCYGh0dHA6Ly90ZXN0LmxvY2FsaG9zdDo5OTk5L2ludGVncmF0aW9uRXhhbXBsZXMvbG9uZ2Zvcm0vYmFzaWNfd19jdXN0b21fYWRzZXJ2ZXJfdHJhbnNsYQE18LYuaHRtbIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIECzEwLjc1Ljc0LjY5qASSxgSyBBIIARACGIAFIOADKAEoAjAAOAO4BADABADIBADSBA45MzI1I1NJTjM6NDczM9oEAggA4AQA8ATf359HiAUBmAUAoAX___________8BwAUAyQUAAAAAAADwP9IFCQkAAABldnDYBQHgBQHwBay8FPoFBAgAEACQBgGYBgC4BgDBBgUiLADwv9AG9S_aBhYKEAkRGQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=ed84428f432d6e743bcad6f7862aed957bece82b', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'http://sin3-ib.adnxs.com/vast_track/v2?info=aAAAAAMArgAFAQne-wVeAAAAABF13ckC5YmjdBne-wVeAAAAACDf359HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1isvBRiAi0taAFwAXgAgAEBiAEBkAGABZgB4AOgAQCoAd_fn0ewAQE.&s=7024b063fcacac27e184ed097ad5878c4dd4dc1d&event_type=1', + 'usersync_url': 'http%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149417951, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 33, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 30000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'http://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_custom_adserver_translation.html&e=wqT_3QL-COh-BAAAAwDWAAUBCN73l_AFEPW6p5bQvOLRdBiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQ39-fR1ic8VtgAGjNunV40rgFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3NDUwNDYyKTt1ZigncicsIDE0OTQxNzk1MSwgMTUZH_D9kgK5AiFqejJHYmdpbWtfOFBFTl9mbjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQnV1WUNrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBWkNEYU5QQ2JPTV8yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwcFBfRDdvRENWTkpUak02TkRjek0tQURyaGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCZjBrcVFVCRNAQUR3UHcuLpoCiQEhTlEtMkY6PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOek16UUs0WVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M8GVlQUEu2AIA4AKtmEjqAmBodHRwOi8vdGVzdC5sb2NhbGhvc3Q6OTk5OS9pbnRlZ3JhdGlvbkV4YW1wbGVzL2xvbmdmb3JtL2Jhc2ljX3dfY3VzdG9tX2Fkc2VydmVyX3RyYW5zbGEBNXwuaHRtbPICEwoPQ1VTVE9NX01PREVMX0lEEgDyAhoKFjIWACBMRUFGX05BTUUBHQgeCho2HQAIQVNUAT7wn0lGSUVEEgCAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My9wcmViaWSYBACiBAsxMC43NS43NC42OagEksYEsgQSCAEQAhiABSDgAygBKAIwADgDuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ3MzPaBAIIAeAEAPAE39-fR4gFAZgFAKAF______8BBRQBwAUAyQVpwxTwP9IFCQkJDHgAANgFAeAFAfAFrLwU-gUECAAQAJAGAZgGALgGAMEGCSUo8D_QBvUv2gYWChAJERkBUBAAGADgBgTyBgIIAIAHAYgHAKAHQA..&s=aefe9625d8e866e048a156abdf26d7c626e6a398' + } + } + }] + }, { + 'uuid': '201bba5bb8827', + 'tag_id': 15394006, + 'auction_id': '4063389973481762703', + 'nobid': false, + 'no_ad_url': 'http://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_custom_adserver_translation.html&e=wqT_3QKiCKAiBAAAAwDWAAUBCN73l_AFEI_fjorv9IOyOBiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3NDUwNDYyKTsBHTByJywgMTQ5NDE3NjY5Nh8A8P2SArkCIV96eHRIQWlsa184UEVNWGRuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCdXVZQ2tBRUFtQUVBb0FFQnFBRURzQUVBdVFIenJXcWtBQUFrUU1FQjg2MXFwQUFBSkVESkFSVExWM2x4c2VJXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHBaUF9EN29EQ1ZOSlRqTTZORGN6TS1BRHJoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJmMGtxUVUJE0RBRHdQdy4umgKJASFEZy1VQ1E2PQEkblBGYklBUW9BRBVIVGtRRG9KVTBsT016bzBOek16UUs0WVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M8GVlQUEu2AIA4AKtmEjqAmBodHRwOi8vdGVzdC5sb2NhbGhvc3Q6OTk5OS9pbnRlZ3JhdGlvbkV4YW1wbGVzL2xvbmdmb3JtL2Jhc2ljX3dfY3VzdG9tX2Fkc2VydmVyX3RyYW5zbGEBNfC2Lmh0bWyAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My9wcmViaWSYBACiBAsxMC43NS43NC42OagEksYEsgQSCAEQAhiABSDgAygBKAIwADgDuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ3MzPaBAIIAOAEAPAExd2fR4gFAZgFAKAF____________AcAFAMkFAAAAAAAA8D_SBQkJAAAAZXZw2AUB4AUB8AXC8hf6BQQIABAAkAYBmAYAuAYAwQYFIiwA8L_QBvUv2gYWChAJERkBUBAAGADgBgTyBgIIAIAHAYgHAKAHQA..&s=2fb33b5204f9b75c58d89487725a9d55139f9ff4', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'http://sin3-ib.adnxs.com/vast_track/v2?info=aAAAAAMArgAFAQne-wVeAAAAABGPr0Pxpg9kOBne-wVeAAAAACDF3Z9HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1jC8hdiAi0taAFwAXgAgAEBiAEBkAGABZgB4AOgAQCoAcXdn0ewAQE.&s=f9ec8d0b81c1cf4eefc58a7990f4a0a78440725f&event_type=1', + 'usersync_url': 'http%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149417669, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 10.000000, + 'cpm_publisher_currency': 10.000000, + 'publisher_currency_code': '$', + 'brand_category_id': 4, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 30000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'http://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_custom_adserver_translation.html&e=wqT_3QL-CKB-BAAAAwDWAAUBCN73l_AFEI_fjorv9IOyOBiq5MnUovf28WEqNgkAAAECCCRAEQEHEAAAJEAZCQkI4D8hCQkIJEApEQkAMQkJsOA_MNbJqwc47UhA7UhIAlDF3Z9HWJzxW2AAaM26dXjSuAWAAQGKAQNVU0SSAQEG8FWYAQGgAQGoAQGwAQC4AQPAAQTIAQLQAQDYAQDgAQDwAQCKAjx1ZignYScsIDI1Mjk4ODUsIDE1Nzc0NTA0NjIpO3VmKCdyJywgMTQ5NDE3NjY5LCAxNRkf8P2SArkCIV96eHRIQWlsa184UEVNWGRuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCdXVZQ2tBRUFtQUVBb0FFQnFBRURzQUVBdVFIenJXcWtBQUFrUU1FQjg2MXFwQUFBSkVESkFSVExWM2x4c2VJXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHBaUF9EN29EQ1ZOSlRqTTZORGN6TS1BRHJoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJmMGtxUVUJE0RBRHdQdy4umgKJASFEZy1VQ1E2PQEkblBGYklBUW9BRBVIVGtRRG9KVTBsT016bzBOek16UUs0WVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M8GVlQUEu2AIA4AKtmEjqAmBodHRwOi8vdGVzdC5sb2NhbGhvc3Q6OTk5OS9pbnRlZ3JhdGlvbkV4YW1wbGVzL2xvbmdmb3JtL2Jhc2ljX3dfY3VzdG9tX2Fkc2VydmVyX3RyYW5zbGEBNXwuaHRtbPICEwoPQ1VTVE9NX01PREVMX0lEEgDyAhoKFjIWACBMRUFGX05BTUUBHQgeCho2HQAIQVNUAT7wn0lGSUVEEgCAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My9wcmViaWSYBACiBAsxMC43NS43NC42OagEksYEsgQSCAEQAhiABSDgAygBKAIwADgDuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ3MzPaBAIIAeAEAPAExd2fR4gFAZgFAKAF______8BBRQBwAUAyQVpwxTwP9IFCQkJDHgAANgFAeAFAfAFwvIX-gUECAAQAJAGAZgGALgGAMEGCSUo8D_QBvUv2gYWChAJERkBUBAAGADgBgTyBgIIAIAHAYgHAKAHQA..&s=6b79542e3cee0319d8cb83d1daf127c3aeea9b28' + } + } + }] + }, { + 'uuid': '201bba5bb8827', + 'tag_id': 15394006, + 'auction_id': '5097385192927446024', + 'nobid': true, + 'ad_profile_id': 1182765 + }, { + 'uuid': '201bba5bb8827', + 'tag_id': 15394006, + 'auction_id': '2612757136292876686', + 'nobid': true, + 'ad_profile_id': 1182765 + }] + } + } + } +} diff --git a/test/mock-server/expectations/request-response-pairs/longform/ad_server_translation_request_2.js b/test/mock-server/expectations/request-response-pairs/longform/ad_server_translation_request_2.js new file mode 100644 index 00000000000..ea77d211826 --- /dev/null +++ b/test/mock-server/expectations/request-response-pairs/longform/ad_server_translation_request_2.js @@ -0,0 +1,289 @@ +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 + * + */ + +/** + * 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': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'minduration': 30, + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'minduration': 30, + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'minduration': 30, + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'minduration': 30, + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'minduration': 30, + 'maxduration': 30 + } + }], + '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': '285a2f41615348', + 'tag_id': 15394006, + 'auction_id': '2837696487158070058', + 'nobid': false, + 'no_ad_url': 'http://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_custom_adserver_translation.html&e=wqT_3QKiCKAiBAAAAwDWAAUBCNSDmPAFEKr2uMu5veGwJxiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3NDUxOTg4KTsBHTByJywgMTQ5NDE3OTUxNh8A8P2SArkCIV9EemhKUWlta184UEVOX2ZuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCN3VZQ2tBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFTbnRDdFVIdU9BXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHBwUF9EN29EQ1ZOSlRqTTZORGN6TmVBRHJoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJmOGtxUVUJE0RBRHdQdy4umgKJASFOdzh1Rnc2PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOek0xUUs0WVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M8GVlQUEu2AIA4AKtmEjqAmBodHRwOi8vdGVzdC5sb2NhbGhvc3Q6OTk5OS9pbnRlZ3JhdGlvbkV4YW1wbGVzL2xvbmdmb3JtL2Jhc2ljX3dfY3VzdG9tX2Fkc2VydmVyX3RyYW5zbGEBNfDtLmh0bWyAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My9wcmViaWSYBACiBAsxMC43NS43NC42OagEq8YEsgQSCAEQAhiABSDgAygBKAIwADgDuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ3MzXaBAIIAOAEAPAE39-fR4gFAZgFAKAF____________AcAFAMkFAAAAAAAA8D_SBQkJAAAAAAAAAADYBQHgBQHwBay8FPoFBAgAEACQBgGYBgC4BgDBBgAAAAAAAPC_0Ab1L9oGFgoQAAAAAAU3DQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=3414eb9e83df14945d2dbfb00e17fb3f2bad2e33', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'http://sin3-ib.adnxs.com/vast_track/v2?info=aAAAAAMArgAFAQnUAQZeAAAAABEqO26Z64VhJxnUAQZeAAAAACDf359HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1isvBRiAi0taAFwAXgAgAEBiAEBkAGABZgB4AOgAQCoAd_fn0ewAQE.&s=e5a720a9884e1df845be9c33658ab69f4c56981e&event_type=1', + 'usersync_url': 'http%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149417951, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 33, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 30000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'http://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_custom_adserver_translation.html&e=wqT_3QL-COh-BAAAAwDWAAUBCNSDmPAFEKr2uMu5veGwJxiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQ39-fR1ic8VtgAGjNunV41rgFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3NDUxOTg4KTt1ZigncicsIDE0OTQxNzk1MSwgMTUZH_D9kgK5AiFfRHpoSlFpbWtfOFBFTl9mbjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQjd1WUNrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBU250Q3RVSHVPQV8yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwcFBfRDdvRENWTkpUak02TkRjek5lQURyaGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCZjhrcVFVCRNEQUR3UHcuLpoCiQEhTnc4dUZ3Nj0BJG5QRmJJQVFvQUQVSFR1UURvSlUwbE9Nem8wTnpNMVFLNFlTEXgMUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDPBlZUFBLtgCAOACrZhI6gJgaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193X2N1c3RvbV9hZHNlcnZlcl90cmFuc2xhATV8Lmh0bWzyAhMKD0NVU1RPTV9NT0RFTF9JRBIA8gIaChYyFgAgTEVBRl9OQU1FAR0IHgoaNh0ACEFTVAE-8J9JRklFRBIAgAMAiAMBkAMAmAMXoAMBqgMAwAPgqAHIAwDYAwDgAwDoAwD4AwGABACSBA0vdXQvdjMvcHJlYmlkmAQAogQLMTAuNzUuNzQuNjmoBKvGBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzM12gQCCAHgBADwBN_fn0eIBQGYBQCgBf______AQUUAcAFAMkFacMU8D_SBQkJCQx4AADYBQHgBQHwBay8FPoFBAgAEACQBgGYBgC4BgDBBgklKPA_0Ab1L9oGFgoQCREZAVAQABgA4AYE8gYCCACABwGIBwCgB0A.&s=99418325b8f5ec79e22c1a9aedd73f03de616c2d' + } + } + }] + }, { + 'uuid': '285a2f41615348', + 'tag_id': 15394006, + 'auction_id': '8688113570839045503', + 'nobid': false, + 'no_ad_url': 'http://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_custom_adserver_translation.html&e=wqT_3QKhCKAhBAAAAwDWAAUBCNSDmPAFEP_K8rCtqJjJeBiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3NDUxOTg4KTsBHTByJywgMTQ5NDE4OTQ4Nh8A8P2SArkCIUN6d3Rud2lta184UEVNVG5uMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCN3VZQ2tBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFWUzRZeVVvR09JXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHBwUF9EN29EQ1ZOSlRqTTZORGN6TmVBRHJoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJmOGtxUVUJE0RBRHdQdy4umgKJASFKQTlsRUE2PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOek0xUUs0WVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M8GVlQUEu2AIA4AKtmEjqAmBodHRwOi8vdGVzdC5sb2NhbGhvc3Q6OTk5OS9pbnRlZ3JhdGlvbkV4YW1wbGVzL2xvbmdmb3JtL2Jhc2ljX3dfY3VzdG9tX2Fkc2VydmVyX3RyYW5zbGEBNfDXLmh0bWyAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My9wcmViaWSYBACiBAsxMC43NS43NC42OagEq8YEsgQSCAEQAhiABSDgAygBKAIwADgDuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ3MzXaBAIIAOAEAPAExOefR4gFAZgFAKAF____________AcAFAMkFAAAAAAAA8D_SBQkJAAAAAAAAAADYBQHgBQHwBZk9-gUECAAQAJAGAZgGALgGAMEGBSEsAPC_0Ab1L9oGFgoQCREZAVAQABgA4AYE8gYCCACABwGIBwCgB0A.&s=2e7c9d18300402e2e183667711728f7743b70a2b', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'http://sin3-ib.adnxs.com/vast_track/v2?info=ZwAAAAMArgAFAQnUAQZeAAAAABF_pRzWQmGSeBnUAQZeAAAAACDE559HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1iZPWICLS1oAXABeACAAQGIAQGQAYAFmAHgA6ABAKgBxOefR7ABAQ..&s=febf12010c66ac7247f571f03c33175ca9036b32&event_type=1', + 'usersync_url': 'http%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149418948, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 1, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 30000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'http://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_custom_adserver_translation.html&e=wqT_3QL9COh9BAAAAwDWAAUBCNSDmPAFEP_K8rCtqJjJeBiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQxOefR1ic8VtgAGjNunV41rgFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3NDUxOTg4KTt1ZigncicsIDE0OTQxODk0OCwgMTUZH_D9kgK5AiFDend0bndpbWtfOFBFTVRubjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQjd1WUNrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBVlM0WXlVb0dPSV8yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwcFBfRDdvRENWTkpUak02TkRjek5lQURyaGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCZjhrcVFVCRNEQUR3UHcuLpoCiQEhSkE5bEVBNj0BJG5QRmJJQVFvQUQVSFR1UURvSlUwbE9Nem8wTnpNMVFLNFlTEXgMUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDPBlZUFBLtgCAOACrZhI6gJgaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193X2N1c3RvbV9hZHNlcnZlcl90cmFuc2xhATV8Lmh0bWzyAhMKD0NVU1RPTV9NT0RFTF9JRBIA8gIaChYyFgAgTEVBRl9OQU1FAR0IHgoaNh0ACEFTVAE-8J9JRklFRBIAgAMAiAMBkAMAmAMXoAMBqgMAwAPgqAHIAwDYAwDgAwDoAwD4AwGABACSBA0vdXQvdjMvcHJlYmlkmAQAogQLMTAuNzUuNzQuNjmoBKvGBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzM12gQCCAHgBADwBMTnn0eIBQGYBQCgBf______AQUUAcAFAMkFacMU8D_SBQkJCQx0AADYBQHgBQHwBZk9-gUECAAQAJAGAZgGALgGAMEGCSQo8D_QBvUv2gYWChAJERkBUBAAGADgBgTyBgIIAIAHAYgHAKAHQA..&s=92aa9e9c89384c435ab9c7fa62b963d8fc087ef7' + } + } + }] + }, { + 'uuid': '285a2f41615348', + 'tag_id': 15394006, + 'auction_id': '4162295099171231907', + 'nobid': false, + 'no_ad_url': 'http://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_custom_adserver_translation.html&e=wqT_3QKhCKAhBAAAAwDWAAUBCNSDmPAFEKOxzaPwqtzhORiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3NDUxOTg4KTsBHTByJywgMTQ5NDE4NjcxNh8A8P2SArkCIWREMGtXZ2lta184UEVLX2xuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCN3VZQ2tBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFhSFRjUzNjWS1VXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHBwUF9EN29EQ1ZOSlRqTTZORGN6TmVBRHJoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJmOGtxUVUJE0RBRHdQdy4umgKJASFEUTg2Q0E2PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOek0xUUs0WVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M8GVlQUEu2AIA4AKtmEjqAmBodHRwOi8vdGVzdC5sb2NhbGhvc3Q6OTk5OS9pbnRlZ3JhdGlvbkV4YW1wbGVzL2xvbmdmb3JtL2Jhc2ljX3dfY3VzdG9tX2Fkc2VydmVyX3RyYW5zbGEBNfDXLmh0bWyAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My9wcmViaWSYBACiBAsxMC43NS43NC42OagEq8YEsgQSCAEQAhiABSDgAygBKAIwADgDuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ3MzXaBAIIAOAEAPAEr-WfR4gFAZgFAKAF____________AcAFAMkFAAAAAAAA8D_SBQkJAAAAAAAAAADYBQHgBQHwBeBY-gUECAAQAJAGAZgGALgGAMEGBSEsAPC_0Ab1L9oGFgoQCREZAVAQABgA4AYE8gYCCACABwGIBwCgB0A.&s=95047e919846faea401c778106fb33dae0c95b02', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'http://sin3-ib.adnxs.com/vast_track/v2?info=ZwAAAAMArgAFAQnUAQZeAAAAABGjWHMEV3HDORnUAQZeAAAAACCv5Z9HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1jgWGICLS1oAXABeACAAQGIAQGQAYAFmAHgA6ABAKgBr-WfR7ABAQ..&s=50350aadc603f4bb6c59888515d60e9182da0eb8&event_type=1', + 'usersync_url': 'http%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149418671, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 30, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 30000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'http://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_custom_adserver_translation.html&e=wqT_3QL9COh9BAAAAwDWAAUBCNSDmPAFEKOxzaPwqtzhORiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQr-WfR1ic8VtgAGjNunV41rgFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3NDUxOTg4KTt1ZigncicsIDE0OTQxODY3MSwgMTUZH_D9kgK5AiFkRDBrV2dpbWtfOFBFS19sbjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQjd1WUNrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBYUhUY1MzY1ktVV8yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwcFBfRDdvRENWTkpUak02TkRjek5lQURyaGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCZjhrcVFVCRNEQUR3UHcuLpoCiQEhRFE4NkNBNj0BJG5QRmJJQVFvQUQVSFR1UURvSlUwbE9Nem8wTnpNMVFLNFlTEXgMUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDPBlZUFBLtgCAOACrZhI6gJgaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193X2N1c3RvbV9hZHNlcnZlcl90cmFuc2xhATV8Lmh0bWzyAhMKD0NVU1RPTV9NT0RFTF9JRBIA8gIaChYyFgAgTEVBRl9OQU1FAR0IHgoaNh0ACEFTVAE-8J9JRklFRBIAgAMAiAMBkAMAmAMXoAMBqgMAwAPgqAHIAwDYAwDgAwDoAwD4AwGABACSBA0vdXQvdjMvcHJlYmlkmAQAogQLMTAuNzUuNzQuNjmoBKvGBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzM12gQCCAHgBADwBK_ln0eIBQGYBQCgBf______AQUUAcAFAMkFacMU8D_SBQkJCQx0AADYBQHgBQHwBeBY-gUECAAQAJAGAZgGALgGAMEGCSQo8D_QBvUv2gYWChAJERkBUBAAGADgBgTyBgIIAIAHAYgHAKAHQA..&s=82c42e6aa09e7c842254552ae524791fa3693bbb' + } + } + }] + }, { + 'uuid': '285a2f41615348', + 'tag_id': 15394006, + 'auction_id': '1076114531988487576', + 'nobid': false, + 'no_ad_url': 'http://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_custom_adserver_translation.html&e=wqT_3QKiCKAiBAAAAwDWAAUBCNSDmPAFEJj7vIbyjsj3Dhiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3NDUxOTg4KTsBHTByJywgMTQ5NDE3NjY5Nh8A8P2SArkCIVRqMWVUZ2lsa184UEVNWGRuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCN3VZQ2tBRUFtQUVBb0FFQnFBRURzQUVBdVFIenJXcWtBQUFrUU1FQjg2MXFwQUFBSkVESkFZOUNHX2M3MHRvXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHBaUF9EN29EQ1ZOSlRqTTZORGN6TmVBRHJoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJmOGtxUVUJE0BBRHdQdy4umgKJASFFQThNQzo9ASRuUEZiSUFRb0FEFUhUa1FEb0pVMGxPTXpvME56TTFRSzRZUxF4DFBBX1URDAxBQUFXHQwAWR0MAGEdDABjHQzwZWVBQS7YAgDgAq2YSOoCYGh0dHA6Ly90ZXN0LmxvY2FsaG9zdDo5OTk5L2ludGVncmF0aW9uRXhhbXBsZXMvbG9uZ2Zvcm0vYmFzaWNfd19jdXN0b21fYWRzZXJ2ZXJfdHJhbnNsYQE18O0uaHRtbIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIECzEwLjc1Ljc0LjY5qASrxgSyBBIIARACGIAFIOADKAEoAjAAOAO4BADABADIBADSBA45MzI1I1NJTjM6NDczNdoEAggA4AQA8ATF3Z9HiAUBmAUAoAX___________8BwAUAyQUAAAAAAADwP9IFCQkAAAAAAAAAANgFAeAFAfAFwvIX-gUECAAQAJAGAZgGALgGAMEGAAAAAAAA8L_QBvUv2gYWChAAAAAABTcNAVAQABgA4AYE8gYCCACABwGIBwCgB0A.&s=c49afba7ca4b5193f7da37b17e1fbfbee2328f61', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'http://sin3-ib.adnxs.com/vast_track/v2?info=aAAAAAMArgAFAQnUAQZeAAAAABGYPc8gdyDvDhnUAQZeAAAAACDF3Z9HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1jC8hdiAi0taAFwAXgAgAEBiAEBkAGABZgB4AOgAQCoAcXdn0ewAQE.&s=47618eb9096567900e84fd1c6aff09d753b2fe91&event_type=1', + 'usersync_url': 'http%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149417669, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 10.000000, + 'cpm_publisher_currency': 10.000000, + 'publisher_currency_code': '$', + 'brand_category_id': 4, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 30000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'http://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_custom_adserver_translation.html&e=wqT_3QL-CKB-BAAAAwDWAAUBCNSDmPAFEJj7vIbyjsj3Dhiq5MnUovf28WEqNgkAAAECCCRAEQEHEAAAJEAZCQkI4D8hCQkIJEApEQkAMQkJsOA_MNbJqwc47UhA7UhIAlDF3Z9HWJzxW2AAaM26dXjWuAWAAQGKAQNVU0SSAQEG8FWYAQGgAQGoAQGwAQC4AQPAAQTIAQLQAQDYAQDgAQDwAQCKAjx1ZignYScsIDI1Mjk4ODUsIDE1Nzc0NTE5ODgpO3VmKCdyJywgMTQ5NDE3NjY5LCAxNRkf8P2SArkCIVRqMWVUZ2lsa184UEVNWGRuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCN3VZQ2tBRUFtQUVBb0FFQnFBRURzQUVBdVFIenJXcWtBQUFrUU1FQjg2MXFwQUFBSkVESkFZOUNHX2M3MHRvXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHBaUF9EN29EQ1ZOSlRqTTZORGN6TmVBRHJoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJmOGtxUVUJE0BBRHdQdy4umgKJASFFQThNQzo9ASRuUEZiSUFRb0FEFUhUa1FEb0pVMGxPTXpvME56TTFRSzRZUxF4DFBBX1URDAxBQUFXHQwAWR0MAGEdDABjHQzwZWVBQS7YAgDgAq2YSOoCYGh0dHA6Ly90ZXN0LmxvY2FsaG9zdDo5OTk5L2ludGVncmF0aW9uRXhhbXBsZXMvbG9uZ2Zvcm0vYmFzaWNfd19jdXN0b21fYWRzZXJ2ZXJfdHJhbnNsYQE1fC5odG1s8gITCg9DVVNUT01fTU9ERUxfSUQSAPICGgoWMhYAIExFQUZfTkFNRQEdCB4KGjYdAAhBU1QBPvCfSUZJRUQSAIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIECzEwLjc1Ljc0LjY5qASrxgSyBBIIARACGIAFIOADKAEoAjAAOAO4BADABADIBADSBA45MzI1I1NJTjM6NDczNdoEAggB4AQA8ATF3Z9HiAUBmAUAoAX______wEFFAHABQDJBWnDFPA_0gUJCQkMeAAA2AUB4AUB8AXC8hf6BQQIABAAkAYBmAYAuAYAwQYJJSjwP9AG9S_aBhYKEAkRGQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=72d1ec3db5baaa29c1b0e5f07c012db606675fe5' + } + } + }] + }, { + 'uuid': '285a2f41615348', + 'tag_id': 15394006, + 'auction_id': '7495588537924508785', + 'nobid': true, + 'ad_profile_id': 1182765 + }] + } + } + } +} diff --git a/test/mock-server/expectations/request-response-pairs/longform/basic_w_requireExactDuration_request_1.js b/test/mock-server/expectations/request-response-pairs/longform/basic_w_requireExactDuration_request_1.js new file mode 100644 index 00000000000..0c58bd6fb3e --- /dev/null +++ b/test/mock-server/expectations/request-response-pairs/longform/basic_w_requireExactDuration_request_1.js @@ -0,0 +1,606 @@ +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 + * + */ + +/** + * 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': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'minduration': 15, + 'maxduration': 15 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'minduration': 15, + 'maxduration': 15 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'minduration': 15, + 'maxduration': 15 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'minduration': 15, + 'maxduration': 15 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'minduration': 15, + 'maxduration': 15 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'minduration': 15, + 'maxduration': 15 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'minduration': 15, + 'maxduration': 15 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'minduration': 15, + 'maxduration': 15 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'minduration': 15, + 'maxduration': 15 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'minduration': 15, + 'maxduration': 15 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'minduration': 30, + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'minduration': 30, + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'minduration': 30, + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'minduration': 30, + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'minduration': 30, + 'maxduration': 30 + } + }], + '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': '25593f19ac7ed2', + 'tag_id': 15394006, + 'auction_id': '4424969993715088689', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_requireExactDuration.html&e=wqT_3QKdCKAdBAAAAwDWAAUBCM2Op_AFELH6mcm82Km0PRiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5MTQ5KTsBHTByJywgMTQ5NDE5NjAyNh8A8P2SArkCIWhUNEwzZ2lua184UEVOTHNuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCbktjRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFjek5XT196NC1VXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHA1UF9EN29EQ1ZOSlRqTTZORGN6TS1BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJmMGtxUVUJE0RBRHdQdy4umgKJASFTZy1SR3c2PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOek16UU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M8F5lQUEu2AIA4AKtmEjqAllodHRwOi8vdGVzdC5sb2NhbGhvc3Q6OTk5OS9pbnRlZ3JhdGlvbkV4YW1wbGVzL2xvbmdmb3JtL2Jhc2ljX3dfcmVxdWlyZUV4YWN0RHVyYQEu8J8uaHRtbIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIEDTIwMi41OS4yMzEuNDeoBMLmBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzMz2gQCCADgBADwBNLsn0eIBQGYBQCgBf______AQUUAcAFAMkFaWIU8D_SBQkJCQx4AADYBQHgBQHwBdm6BvoFBAgAEACQBgGYBgC4BgDBBgklKPC_0Ab1L9oGFgoQCREZAVAQABgA4AYE8gYCCACABwGIBwCgB0A.&s=3d8c006f4f85ecffd49c500554c3852b9079ff2b', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=aAAAAAMArgAFAQlNxwleAAAAABExfSbJw6ZoPRlNxwleAAAAACDS7J9HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1jZugZiAklOaAFwAXgAgAEBiAEBkAGABZgB4AOgAQCoAdLsn0ewAQE.&s=e2c6cedf67a96613ea8851673ebcfdd25a19435c&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149419602, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 24, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 15000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_requireExactDuration.html&e=wqT_3QL5COh5BAAAAwDWAAUBCM2Op_AFELH6mcm82Km0PRiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQ0uyfR1ic8VtgAGjNunV4lbgFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5MTQ5KTt1ZigncicsIDE0OTQxOTYwMiwgMTUZH_D9kgK5AiFoVDRMM2dpbmtfOFBFTkxzbjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQm5LY0RrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBY3pOV09fejQtVV8yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwNVBfRDdvRENWTkpUak02TkRjek0tQUR3aGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCZjBrcVFVCRNEQUR3UHcuLpoCiQEhU2ctUkd3Nj0BJG5QRmJJQVFvQUQVSFR1UURvSlUwbE9Nem8wTnpNelFNSVlTEXgMUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDPBeZUFBLtgCAOACrZhI6gJZaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193X3JlcXVpcmVFeGFjdER1cmEBLnwuaHRtbPICEwoPQ1VTVE9NX01PREVMX0lEEgDyAhoKFjIWACBMRUFGX05BTUUBHQgeCho2HQAIQVNUAT7wkElGSUVEEgCAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My9wcmViaWSYBACiBA0yMDIuNTkuMjMxLjQ3qATC5gSyBBIIARACGIAFIOADKAEoAjAAOAO4BADABADIBADSBA45MzI1I1NJTjM6NDczM9oEAggB4AQA8ARhjSCIBQGYBQCgBf8RARQBwAUAyQVpvhTwP9IFCQkJDHgAANgFAeAFAfAF2boG-gUECAAQAJAGAZgGALgGAMEGCSUo8D_QBvUv2gYWChAJERkBUBAAGADgBgTyBgIIAIAHAYgHAKAHQA..&s=de23f822f483b6e85615d4297d872262310c240d' + } + } + }] + }, { + 'uuid': '25593f19ac7ed2', + 'tag_id': 15394006, + 'auction_id': '2013100091803497646', + 'nobid': true, + 'ad_profile_id': 1182765 + }, { + 'uuid': '25593f19ac7ed2', + 'tag_id': 15394006, + 'auction_id': '2659371493620557151', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_requireExactDuration.html&e=wqT_3QKdCKAdBAAAAwDWAAUBCM2Op_AFEN_KtpiJif_zJBiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5MTQ5KTsBHTByJywgMTQ5NDE4MTIzNh8A8P2SArkCIWR6eUJxQWlua184UEVJdmhuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCbktjRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFWSHZpWGF0Q09zXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHA1UF9EN29EQ1ZOSlRqTTZORGN6TS1BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJmMGtxUVUJE0RBRHdQdy4umgKJASEtQTVuX2c2PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOek16UU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M8F5lQUEu2AIA4AKtmEjqAllodHRwOi8vdGVzdC5sb2NhbGhvc3Q6OTk5OS9pbnRlZ3JhdGlvbkV4YW1wbGVzL2xvbmdmb3JtL2Jhc2ljX3dfcmVxdWlyZUV4YWN0RHVyYQEu8J8uaHRtbIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIEDTIwMi41OS4yMzEuNDeoBMLmBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzMz2gQCCADgBADwBIvhn0eIBQGYBQCgBf______AQUUAcAFAMkFaWIU8D_SBQkJCQx4AADYBQHgBQHwBdrWAvoFBAgAEACQBgGYBgC4BgDBBgklKPC_0Ab1L9oGFgoQCREZAVAQABgA4AYE8gYCCACABwGIBwCgB0A.&s=eafba287adec58427d1679f43a84ebb19223c4e7', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=aAAAAAMArgAFAQlNxwleAAAAABFfpQ2TSPznJBlNxwleAAAAACCL4Z9HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1ja1gJiAklOaAFwAXgAgAEBiAEBkAGABZgB4AOgAQCoAYvhn0ewAQE.&s=b335b2c79378c1699d54cf9ffe097958bd989a0b&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149418123, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 12, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 15000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_requireExactDuration.html&e=wqT_3QL5COh5BAAAAwDWAAUBCM2Op_AFEN_KtpiJif_zJBiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQi-GfR1ic8VtgAGjNunV4lbgFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5MTQ5KTt1ZigncicsIDE0OTQxODEyMywgMTUZH_D9kgK5AiFkenlCcUFpbmtfOFBFSXZobjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQm5LY0RrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBVkh2aVhhdENPc18yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwNVBfRDdvRENWTkpUak02TkRjek0tQUR3aGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCZjBrcVFVCRNEQUR3UHcuLpoCiQEhLUE1bl9nNj0BJG5QRmJJQVFvQUQVSFR1UURvSlUwbE9Nem8wTnpNelFNSVlTEXgMUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDPBeZUFBLtgCAOACrZhI6gJZaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193X3JlcXVpcmVFeGFjdER1cmEBLnwuaHRtbPICEwoPQ1VTVE9NX01PREVMX0lEEgDyAhoKFjIWACBMRUFGX05BTUUBHQgeCho2HQAIQVNUAT7wkElGSUVEEgCAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My9wcmViaWSYBACiBA0yMDIuNTkuMjMxLjQ3qATC5gSyBBIIARACGIAFIOADKAEoAjAAOAO4BADABADIBADSBA45MzI1I1NJTjM6NDczM9oEAggB4AQA8ARhjSCIBQGYBQCgBf8RARQBwAUAyQVpvhTwP9IFCQkJDHgAANgFAeAFAfAF2tYC-gUECAAQAJAGAZgGALgGAMEGCSUo8D_QBvUv2gYWChAJERkBUBAAGADgBgTyBgIIAIAHAYgHAKAHQA..&s=66b9e769da1e1d68b202605fc178fc172046e9c5' + } + } + }] + }, { + 'uuid': '25593f19ac7ed2', + 'tag_id': 15394006, + 'auction_id': '5424637592449788792', + 'nobid': true, + 'ad_profile_id': 1182765 + }, { + 'uuid': '25593f19ac7ed2', + 'tag_id': 15394006, + 'auction_id': '3470330348822422583', + 'nobid': true, + 'ad_profile_id': 1182765 + }, { + 'uuid': '25593f19ac7ed2', + 'tag_id': 15394006, + 'auction_id': '4415549097692431196', + 'nobid': true, + 'ad_profile_id': 1182765 + }, { + 'uuid': '25593f19ac7ed2', + 'tag_id': 15394006, + 'auction_id': '1628359298176905427', + 'nobid': true, + 'ad_profile_id': 1182765 + }, { + 'uuid': '25593f19ac7ed2', + 'tag_id': 15394006, + 'auction_id': '1949183409076770477', + 'nobid': true, + 'ad_profile_id': 1182765 + }, { + 'uuid': '25593f19ac7ed2', + 'tag_id': 15394006, + 'auction_id': '4707958683377993236', + 'nobid': true, + 'ad_profile_id': 1182765 + }, { + 'uuid': '25593f19ac7ed2', + 'tag_id': 15394006, + 'auction_id': '2499032734231846767', + 'nobid': true, + 'ad_profile_id': 1182765 + }, { + 'uuid': '25593f19ac7ed2', + 'tag_id': 15394006, + 'auction_id': '1295788165766409083', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_requireExactDuration.html&e=wqT_3QKcCKAcBAAAAwDWAAUBCM2Op_AFEPvWpeWKj-T9ERiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5MTQ5KTsBHTByJywgMTQ5NDE4OTQ4Nh8A8P2SArkCITR6eVM5d2lta184UEVNVG5uMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCbktjRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFlS0tONGIwQS00XzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHBwUF9EN29EQ1ZOSlRqTTZORGN6TS1BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJmMGtxUVUJE0RBRHdQdy4umgKJASFOZzkxRkE2PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOek16UU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M8F5lQUEu2AIA4AKtmEjqAllodHRwOi8vdGVzdC5sb2NhbGhvc3Q6OTk5OS9pbnRlZ3JhdGlvbkV4YW1wbGVzL2xvbmdmb3JtL2Jhc2ljX3dfcmVxdWlyZUV4YWN0RHVyYQEu8J8uaHRtbIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIEDTIwMi41OS4yMzEuNDeoBMLmBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzMz2gQCCADgBADwBMTnn0eIBQGYBQCgBf______AQUUAcAFAMkFaWIU8D_SBQkJCQx0AADYBQHgBQHwBZk9-gUECAAQAJAGAZgGALgGAMEGCSQo8L_QBvUv2gYWChAJERkBUBAAGADgBgTyBgIIAIAHAYgHAKAHQA..&s=3cb170cdf53cd6a6bfec0676659daeb6170895e3', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=ZwAAAAMArgAFAQlNxwleAAAAABF7a6mseJD7ERlNxwleAAAAACDE559HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1iZPWICSU5oAXABeACAAQGIAQGQAYAFmAHgA6ABAKgBxOefR7ABAQ..&s=45f5cce314725120ec769afaacbb7aa92d32e674&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149418948, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 1, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 30000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_requireExactDuration.html&e=wqT_3QL4COh4BAAAAwDWAAUBCM2Op_AFEPvWpeWKj-T9ERiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQxOefR1ic8VtgAGjNunV4lbgFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5MTQ5KTt1ZigncicsIDE0OTQxODk0OCwgMTUZH_D9kgK5AiE0enlTOXdpbWtfOFBFTVRubjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQm5LY0RrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBZUtLTjRiMEEtNF8yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwcFBfRDdvRENWTkpUak02TkRjek0tQUR3aGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCZjBrcVFVCRNEQUR3UHcuLpoCiQEhTmc5MUZBNj0BJG5QRmJJQVFvQUQVSFR1UURvSlUwbE9Nem8wTnpNelFNSVlTEXgMUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDPBeZUFBLtgCAOACrZhI6gJZaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193X3JlcXVpcmVFeGFjdER1cmEBLnwuaHRtbPICEwoPQ1VTVE9NX01PREVMX0lEEgDyAhoKFjIWACBMRUFGX05BTUUBHQgeCho2HQAIQVNUAT7w7UlGSUVEEgCAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My9wcmViaWSYBACiBA0yMDIuNTkuMjMxLjQ3qATC5gSyBBIIARACGIAFIOADKAEoAjAAOAO4BADABADIBADSBA45MzI1I1NJTjM6NDczM9oEAggB4AQA8ATE559HiAUBmAUAoAX___________8BwAUAyQUAAAAAAADwP9IFCQkAAAAAAAAAANgFAeAFAfAFmT36BQQIABAAkAYBmAYAuAYAwQYAAAAAAADwP9AG9S_aBhYKEACJABUBUBAAGADgBgTyBgIIAIAHAYgHAKAHQA..&s=5c9f03b9c5c6cc2bf070d8cdc6c9af4b06595879' + } + } + }] + }, { + 'uuid': '25593f19ac7ed2', + 'tag_id': 15394006, + 'auction_id': '702761892273189154', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_requireExactDuration.html&e=wqT_3QKcCKAcBAAAAwDWAAUBCM2Op_AFEKLi_7T7xq3gCRiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5MTQ5KTsBHTByJywgMTQ5NDE4NDg2Nh8A8P2SArkCITdUeVNDd2lva184UEVQYmpuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCbktjRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFHSTh5N21BQUFzUU1FQmlQTXU1Z0FBTEVESkFYQTM4QzJIcnVFXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHFKUF9EN29EQ1ZOSlRqTTZORGN6TS1BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJmMGtxUVUJE0RBRHdQdy4umgKJASFaQThESlE2PQEkblBGYklBUW9BRBVIVHNRRG9KVTBsT016bzBOek16UU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M8F5lQUEu2AIA4AKtmEjqAllodHRwOi8vdGVzdC5sb2NhbGhvc3Q6OTk5OS9pbnRlZ3JhdGlvbkV4YW1wbGVzL2xvbmdmb3JtL2Jhc2ljX3dfcmVxdWlyZUV4YWN0RHVyYQEu8J8uaHRtbIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIEDTIwMi41OS4yMzEuNDeoBMLmBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzMz2gQCCADgBADwBPbjn0eIBQGYBQCgBf______AQUUAcAFAMkFaWIU8D_SBQkJCQx0AADYBQHgBQHwBf0F-gUECAAQAJAGAZgGALgGAMEGCSQo8L_QBvUv2gYWChAJERkBUBAAGADgBgTyBgIIAIAHAYgHAKAHQA..&s=f459a78a1b20c9643b90d7491f22593d79cff253', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=ZwAAAAMArgAFAQlNxwleAAAAABEi8Z-2N7bACRlNxwleAAAAACD2459HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1j9BWICSU5oAXABeACAAQGIAQGQAYAFmAHgA6ABAKgB9uOfR7ABAQ..&s=83289d261bced5258930a1ce2464260a96565241&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149418486, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 14.000010, + 'cpm_publisher_currency': 14.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 30, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 30000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_requireExactDuration.html&e=wqT_3QL4COh4BAAAAwDWAAUBCM2Op_AFEKLi_7T7xq3gCRiq5MnUovf28WEqNgmOWItPAQAsQBGOWItPAQAsQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQ9uOfR1ic8VtgAGjNunV4lbgFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5MTQ5KTt1ZigncicsIDE0OTQxODQ4NiwgMTUZH_D9kgK5AiE3VHlTQ3dpb2tfOFBFUGJqbjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQm5LY0RrQUVBbUFFQW9BRUJxQUVEc0FFQXVRR0k4eTdtQUFBc1FNRUJpUE11NWdBQUxFREpBWEEzOEMySHJ1RV8yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RxSlBfRDdvRENWTkpUak02TkRjek0tQUR3aGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCZjBrcVFVCRNEQUR3UHcuLpoCiQEhWkE4REpRNj0BJG5QRmJJQVFvQUQVSFRzUURvSlUwbE9Nem8wTnpNelFNSVlTEXgMUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDPBeZUFBLtgCAOACrZhI6gJZaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193X3JlcXVpcmVFeGFjdER1cmEBLnwuaHRtbPICEwoPQ1VTVE9NX01PREVMX0lEEgDyAhoKFjIWACBMRUFGX05BTUUBHQgeCho2HQAIQVNUAT7w7UlGSUVEEgCAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My9wcmViaWSYBACiBA0yMDIuNTkuMjMxLjQ3qATC5gSyBBIIARACGIAFIOADKAEoAjAAOAO4BADABADIBADSBA45MzI1I1NJTjM6NDczM9oEAggB4AQA8AT2459HiAUBmAUAoAX___________8BwAUAyQUAAAAAAADwP9IFCQkAAAAAAAAAANgFAeAFAfAF_QX6BQQIABAAkAYBmAYAuAYAwQYAAAAAAADwP9AG9S_aBhYKEACJABUBUBAAGADgBgTyBgIIAIAHAYgHAKAHQA..&s=16a432c0a05db78fa40fefc7967796ff2a2e8444' + } + } + }] + }, { + 'uuid': '25593f19ac7ed2', + 'tag_id': 15394006, + 'auction_id': '8192047453391406704', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_requireExactDuration.html&e=wqT_3QKdCKAdBAAAAwDWAAUBCM2Op_AFEPCMp9SW-P_XcRiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5MTQ5KTsBHTByJywgMTQ5NDE3OTUxNh8A8P2SArkCIXhUdGdYZ2lHa184UEVOX2ZuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCbktjRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFFajRyM1ZBQUFxUU1FQkktSzkxUUFBS2tESkFSR0FWSjZORXVNXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRGhwUF9EN29EQ1ZOSlRqTTZORGN6TS1BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJmMGtxUVUJE0BBRHdQdy4umgKJASFKUThlRDo9ASRuUEZiSUFRb0FEFUhUcVFEb0pVMGxPTXpvME56TXpRTUlZUxF4DFBBX1URDAxBQUFXHQwAWR0MAGEdDABjHQzwXmVBQS7YAgDgAq2YSOoCWWh0dHA6Ly90ZXN0LmxvY2FsaG9zdDo5OTk5L2ludGVncmF0aW9uRXhhbXBsZXMvbG9uZ2Zvcm0vYmFzaWNfd19yZXF1aXJlRXhhY3REdXJhAS7wny5odG1sgAMAiAMBkAMAmAMXoAMBqgMAwAPgqAHIAwDYAwDgAwDoAwD4AwGABACSBA0vdXQvdjMvcHJlYmlkmAQAogQNMjAyLjU5LjIzMS40N6gEwuYEsgQSCAEQAhiABSDgAygBKAIwADgDuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ3MzPaBAIIAOAEAPAE39-fR4gFAZgFAKAF______8BBRQBwAUAyQVpYhTwP9IFCQkJDHgAANgFAeAFAfAFrLwU-gUECAAQAJAGAZgGALgGAMEGCSUo8L_QBvUv2gYWChAJERkBUBAAGADgBgTyBgIIAIAHAYgHAKAHQA..&s=8bf90e0756a9265ab6ac029e883e14803447a7fb', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=aAAAAAMArgAFAQlNxwleAAAAABFwxolqwf-vcRlNxwleAAAAACDf359HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1isvBRiAklOaAFwAXgAgAEBiAEBkAGABZgB4AOgAQCoAd_fn0ewAQE.&s=cf9ea0df7655a5c6150a527399cb2852c61ec14a&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149417951, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 13.000010, + 'cpm_publisher_currency': 13.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 33, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 30000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_requireExactDuration.html&e=wqT_3QL5COh5BAAAAwDWAAUBCM2Op_AFEPCMp9SW-P_XcRiq5MnUovf28WEqNgmOWItPAQAqQBGOWItPAQAqQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQ39-fR1ic8VtgAGjNunV4lbgFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5MTQ5KTt1ZigncicsIDE0OTQxNzk1MSwgMTUZH_D9kgK5AiF4VHRnWGdpR2tfOFBFTl9mbjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQm5LY0RrQUVBbUFFQW9BRUJxQUVEc0FFQXVRRWo0cjNWQUFBcVFNRUJJLUs5MVFBQUtrREpBUkdBVko2TkV1TV8yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RocFBfRDdvRENWTkpUak02TkRjek0tQUR3aGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCZjBrcVFVCRNAQUR3UHcuLpoCiQEhSlE4ZUQ6PQEkblBGYklBUW9BRBVIVHFRRG9KVTBsT016bzBOek16UU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M8F5lQUEu2AIA4AKtmEjqAllodHRwOi8vdGVzdC5sb2NhbGhvc3Q6OTk5OS9pbnRlZ3JhdGlvbkV4YW1wbGVzL2xvbmdmb3JtL2Jhc2ljX3dfcmVxdWlyZUV4YWN0RHVyYQEufC5odG1s8gITCg9DVVNUT01fTU9ERUxfSUQSAPICGgoWMhYAIExFQUZfTkFNRQEdCB4KGjYdAAhBU1QBPvCQSUZJRUQSAIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIEDTIwMi41OS4yMzEuNDeoBMLmBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzMz2gQCCAHgBADwBGGNIIgFAZgFAKAF_xEBFAHABQDJBWm-FPA_0gUJCQkMeAAA2AUB4AUB8AWsvBT6BQQIABAAkAYBmAYAuAYAwQYJJSjwP9AG9S_aBhYKEAkRGQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=cefb5f476892ed335cd8b0fc20fabf7650b1d2e3' + } + } + }] + }, { + 'uuid': '25593f19ac7ed2', + 'tag_id': 15394006, + 'auction_id': '9041697983972949142', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_requireExactDuration.html&e=wqT_3QKdCKAdBAAAAwDWAAUBCM2Op_AFEJb5yqiVjaS9fRiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5MTQ5KTsBHTByJywgMTQ5NDE3NjY5Nh8A8P2SArkCIURUMkpEd2lsa184UEVNWGRuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCbktjRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIenJXcWtBQUFrUU1FQjg2MXFwQUFBSkVESkFYeHdUOEhkUmVzXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHBaUF9EN29EQ1ZOSlRqTTZORGN6TS1BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJmMGtxUVUJE0RBRHdQdy4umgKJASFJZzhjRGc2PQEkblBGYklBUW9BRBVIVGtRRG9KVTBsT016bzBOek16UU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M8F5lQUEu2AIA4AKtmEjqAllodHRwOi8vdGVzdC5sb2NhbGhvc3Q6OTk5OS9pbnRlZ3JhdGlvbkV4YW1wbGVzL2xvbmdmb3JtL2Jhc2ljX3dfcmVxdWlyZUV4YWN0RHVyYQEu8J8uaHRtbIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIEDTIwMi41OS4yMzEuNDeoBMLmBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzMz2gQCCADgBADwBMXdn0eIBQGYBQCgBf______AQUUAcAFAMkFaWIU8D_SBQkJCQx4AADYBQHgBQHwBcLyF_oFBAgAEACQBgGYBgC4BgDBBgklKPC_0Ab1L9oGFgoQCREZAVAQABgA4AYE8gYCCACABwGIBwCgB0A.&s=308ea3c3363b379ef62dbb6c7a91d1d91d9ee47a', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=aAAAAAMArgAFAQlNxwleAAAAABGWvBJVaZB6fRlNxwleAAAAACDF3Z9HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1jC8hdiAklOaAFwAXgAgAEBiAEBkAGABZgB4AOgAQCoAcXdn0ewAQE.&s=70a33aa1a57d812d9da5c321e898197836ed16f8&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149417669, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 10.000000, + 'cpm_publisher_currency': 10.000000, + 'publisher_currency_code': '$', + 'brand_category_id': 4, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 30000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_requireExactDuration.html&e=wqT_3QL5CKB5BAAAAwDWAAUBCM2Op_AFEJb5yqiVjaS9fRiq5MnUovf28WEqNgkAAAECCCRAEQEHEAAAJEAZCQkI4D8hCQkIJEApEQkAMQkJsOA_MNbJqwc47UhA7UhIAlDF3Z9HWJzxW2AAaM26dXiVuAWAAQGKAQNVU0SSAQEG8FWYAQGgAQGoAQGwAQC4AQPAAQTIAQLQAQDYAQDgAQDwAQCKAjx1ZignYScsIDI1Mjk4ODUsIDE1Nzc2OTkxNDkpO3VmKCdyJywgMTQ5NDE3NjY5LCAxNRkf8P2SArkCIURUMkpEd2lsa184UEVNWGRuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCbktjRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIenJXcWtBQUFrUU1FQjg2MXFwQUFBSkVESkFYeHdUOEhkUmVzXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHBaUF9EN29EQ1ZOSlRqTTZORGN6TS1BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJmMGtxUVUJE0RBRHdQdy4umgKJASFJZzhjRGc2PQEkblBGYklBUW9BRBVIVGtRRG9KVTBsT016bzBOek16UU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M8F5lQUEu2AIA4AKtmEjqAllodHRwOi8vdGVzdC5sb2NhbGhvc3Q6OTk5OS9pbnRlZ3JhdGlvbkV4YW1wbGVzL2xvbmdmb3JtL2Jhc2ljX3dfcmVxdWlyZUV4YWN0RHVyYQEufC5odG1s8gITCg9DVVNUT01fTU9ERUxfSUQSAPICGgoWMhYAIExFQUZfTkFNRQEdCB4KGjYdAAhBU1QBPvDeSUZJRUQSAIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIEDTIwMi41OS4yMzEuNDeoBMLmBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzMz2gQCCAHgBADwBMXdn0eIBQGYBQCgBf___________wHABQDJBQAAAAAAAPA_0gUJCQAAAAAAAAAA2AUB4AUB8AXC8hf6BQQIABAAkAYBmAYAuAYAwQYAAGHxKPA_0Ab1L9oGFgoQAQ8uAQBQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=ee15793b41a9d22ffad9bd46878a47821d6044fa' + } + } + }] + }, { + 'uuid': '25593f19ac7ed2', + 'tag_id': 15394006, + 'auction_id': '356000177781223639', + 'nobid': true, + 'ad_profile_id': 1182765 + }] + } + } + } +} diff --git a/test/mock-server/expectations/request-response-pairs/longform/basic_w_requireExactDuration_request_2.js b/test/mock-server/expectations/request-response-pairs/longform/basic_w_requireExactDuration_request_2.js new file mode 100644 index 00000000000..38331688a9b --- /dev/null +++ b/test/mock-server/expectations/request-response-pairs/longform/basic_w_requireExactDuration_request_2.js @@ -0,0 +1,288 @@ +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 + * + */ + +/** + * 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': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'minduration': 30, + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'minduration': 30, + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'minduration': 30, + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'minduration': 30, + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'minduration': 30, + 'maxduration': 30 + } + }], + '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': '25593f19ac7ed2', + 'tag_id': 15394006, + 'auction_id': '198494455120718841', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_requireExactDuration.html&e=wqT_3QKcCKAcBAAAAwDWAAUBCM2Op_AFEPnX6_r7tMzgAhiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5MTQ5KTsBHTByJywgMTQ5NDE4NjcxNh8A8P2SArkCIXpUMDRwQWlta184UEVLX2xuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCbktjRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFhejg2NVNoMGVJXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHBwUF9EN29EQ1ZOSlRqTTZORGMwTi1BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJZc2xxUVUJE0RBRHdQdy4umgKJASFKQTkzRFE2PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOelEzUU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M8F5lQUEu2AIA4AKtmEjqAllodHRwOi8vdGVzdC5sb2NhbGhvc3Q6OTk5OS9pbnRlZ3JhdGlvbkV4YW1wbGVzL2xvbmdmb3JtL2Jhc2ljX3dfcmVxdWlyZUV4YWN0RHVyYQEu8J8uaHRtbIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIEDTIwMi41OS4yMzEuNDeoBMLmBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzQ32gQCCADgBADwBK_ln0eIBQGYBQCgBf______AQUUAcAFAMkFaWIU8D_SBQkJCQx0AADYBQHgBQHwBeBY-gUECAAQAJAGAZgGALgGAMEGCSQo8L_QBvUv2gYWChAJERkBUBAAGADgBgTyBgIIAIAHAYgHAKAHQA..&s=645b6e0a37eb3a315bc3208365bd4fc03e1ecd18', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=ZwAAAAMArgAFAQlNxwleAAAAABH561q_pzHBAhlNxwleAAAAACCv5Z9HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1jgWGICSU5oAXABeACAAQGIAQGQAYAFmAHgA6ABAKgBr-WfR7ABAQ..&s=35a21bf0bef1ca2c138e37a2e025ad523b5a1db2&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149418671, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 30, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 30000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_requireExactDuration.html&e=wqT_3QL4COh4BAAAAwDWAAUBCM2Op_AFEPnX6_r7tMzgAhiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQr-WfR1ic8VtgAGjNunV4xbgFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5MTQ5KTt1ZigncicsIDE0OTQxODY3MSwgMTUZH_D9kgK5AiF6VDA0cEFpbWtfOFBFS19sbjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQm5LY0RrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBYXo4NjVTaDBlSV8yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwcFBfRDdvRENWTkpUak02TkRjME4tQUR3aGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCWXNscVFVCRNEQUR3UHcuLpoCiQEhSkE5M0RRNj0BJG5QRmJJQVFvQUQVSFR1UURvSlUwbE9Nem8wTnpRM1FNSVlTEXgMUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDPBeZUFBLtgCAOACrZhI6gJZaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193X3JlcXVpcmVFeGFjdER1cmEBLnwuaHRtbPICEwoPQ1VTVE9NX01PREVMX0lEEgDyAhoKFjIWACBMRUFGX05BTUUBHQgeCho2HQAIQVNUAT7wkElGSUVEEgCAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My9wcmViaWSYBACiBA0yMDIuNTkuMjMxLjQ3qATC5gSyBBIIARACGIAFIOADKAEoAjAAOAO4BADABADIBADSBA45MzI1I1NJTjM6NDc0N9oEAggB4AQA8ARhjSCIBQGYBQCgBf8RARQBwAUAyQVpvhTwP9IFCQkJDHQAANgFAeAFAfAF4Fj6BQQIABAAkAYBmAYAuAYAwQYJJCjwP9AG9S_aBhYKEAkRGQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=cf3130989b2b4fe5271240d65055b85d1192b78a' + } + } + }] + }, { + 'uuid': '25593f19ac7ed2', + 'tag_id': 15394006, + 'auction_id': '998265386177420565', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_requireExactDuration.html&e=wqT_3QKdCKAdBAAAAwDWAAUBCM2Op_AFEJW6sbXGoqPtDRiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5MTQ5KTsBHTByJywgMTQ5NDE3OTUxNh8A8P2SArkCIVdqM1Jid2lHa184UEVOX2ZuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCbktjRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFFajRyM1ZBQUFxUU1FQkktSzkxUUFBS2tESkFmcXpCNjduMU9rXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRGhwUF9EN29EQ1ZOSlRqTTZORGMwTi1BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJZc2xxUVUJE0BBRHdQdy4umgKJASFLZzlMRDo9ASRuUEZiSUFRb0FEFUhUcVFEb0pVMGxPTXpvME56UTNRTUlZUxF4DFBBX1URDAxBQUFXHQwAWR0MAGEdDABjHQzwXmVBQS7YAgDgAq2YSOoCWWh0dHA6Ly90ZXN0LmxvY2FsaG9zdDo5OTk5L2ludGVncmF0aW9uRXhhbXBsZXMvbG9uZ2Zvcm0vYmFzaWNfd19yZXF1aXJlRXhhY3REdXJhAS7wny5odG1sgAMAiAMBkAMAmAMXoAMBqgMAwAPgqAHIAwDYAwDgAwDoAwD4AwGABACSBA0vdXQvdjMvcHJlYmlkmAQAogQNMjAyLjU5LjIzMS40N6gEwuYEsgQSCAEQAhiABSDgAygBKAIwADgDuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ3NDfaBAIIAOAEAPAE39-fR4gFAZgFAKAF______8BBRQBwAUAyQVpYhTwP9IFCQkJDHgAANgFAeAFAfAFrLwU-gUECAAQAJAGAZgGALgGAMEGCSUo8L_QBvUv2gYWChAJERkBUBAAGADgBgTyBgIIAIAHAYgHAKAHQA..&s=33f01ddfb15bc84d7bf134a168aeb9d9de76fa57', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=aAAAAAMArgAFAQlNxwleAAAAABEVXaxmFI3aDRlNxwleAAAAACDf359HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1isvBRiAklOaAFwAXgAgAEBiAEBkAGABZgB4AOgAQCoAd_fn0ewAQE.&s=023640de7c18a0d0e80b2456144b89a351455cda&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149417951, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 13.000010, + 'cpm_publisher_currency': 13.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 33, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 30000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_requireExactDuration.html&e=wqT_3QL5COh5BAAAAwDWAAUBCM2Op_AFEJW6sbXGoqPtDRiq5MnUovf28WEqNgmOWItPAQAqQBGOWItPAQAqQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQ39-fR1ic8VtgAGjNunV4xbgFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5MTQ5KTt1ZigncicsIDE0OTQxNzk1MSwgMTUZH_D9kgK5AiFXajNSYndpR2tfOFBFTl9mbjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQm5LY0RrQUVBbUFFQW9BRUJxQUVEc0FFQXVRRWo0cjNWQUFBcVFNRUJJLUs5MVFBQUtrREpBZnF6QjY3bjFPa18yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RocFBfRDdvRENWTkpUak02TkRjME4tQUR3aGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCWXNscVFVCRNAQUR3UHcuLpoCiQEhS2c5TEQ6PQEkblBGYklBUW9BRBVIVHFRRG9KVTBsT016bzBOelEzUU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M8F5lQUEu2AIA4AKtmEjqAllodHRwOi8vdGVzdC5sb2NhbGhvc3Q6OTk5OS9pbnRlZ3JhdGlvbkV4YW1wbGVzL2xvbmdmb3JtL2Jhc2ljX3dfcmVxdWlyZUV4YWN0RHVyYQEufC5odG1s8gITCg9DVVNUT01fTU9ERUxfSUQSAPICGgoWMhYAIExFQUZfTkFNRQEdCB4KGjYdAAhBU1QBPvCQSUZJRUQSAIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIEDTIwMi41OS4yMzEuNDeoBMLmBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzQ32gQCCAHgBADwBGGNIIgFAZgFAKAF_xEBFAHABQDJBWm-FPA_0gUJCQkMeAAA2AUB4AUB8AWsvBT6BQQIABAAkAYBmAYAuAYAwQYJJSjwP9AG9S_aBhYKEAkRGQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=515ab42a7fdcad8fcf34e4fb98b1e076a75006a9' + } + } + }] + }, { + 'uuid': '25593f19ac7ed2', + 'tag_id': 15394006, + 'auction_id': '8884527464400177295', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_requireExactDuration.html&e=wqT_3QKcCKAcBAAAAwDWAAUBCM2Op_AFEI-RmcaB1Yumexiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5MTQ5KTsBHTByJywgMTQ5NDE4OTQ4Nh8A8P2SArkCITVqcmtHUWlta184UEVNVG5uMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCbktjRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFYb0paejlaR09NXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHBwUF9EN29EQ1ZOSlRqTTZORGMwTi1BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJZc2xxUVUJE0BBRHdQdy4umgKJASFPdy1pRjo9ASRuUEZiSUFRb0FEFUhUdVFEb0pVMGxPTXpvME56UTNRTUlZUxF4DFBBX1URDAxBQUFXHQwAWR0MAGEdDABjHQzwXmVBQS7YAgDgAq2YSOoCWWh0dHA6Ly90ZXN0LmxvY2FsaG9zdDo5OTk5L2ludGVncmF0aW9uRXhhbXBsZXMvbG9uZ2Zvcm0vYmFzaWNfd19yZXF1aXJlRXhhY3REdXJhAS7wny5odG1sgAMAiAMBkAMAmAMXoAMBqgMAwAPgqAHIAwDYAwDgAwDoAwD4AwGABACSBA0vdXQvdjMvcHJlYmlkmAQAogQNMjAyLjU5LjIzMS40N6gEwuYEsgQSCAEQAhiABSDgAygBKAIwADgDuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ3NDfaBAIIAOAEAPAExOefR4gFAZgFAKAF______8BBRQBwAUAyQVpYhTwP9IFCQkJDHQAANgFAeAFAfAFmT36BQQIABAAkAYBmAYAuAYAwQYJJCjwv9AG9S_aBhYKEAkRGQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=dc7d874e52ac39980ec1070a7769632be56a2f00', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=ZwAAAAMArgAFAQlNxwleAAAAABGPSMYYqC5MexlNxwleAAAAACDE559HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1iZPWICSU5oAXABeACAAQGIAQGQAYAFmAHgA6ABAKgBxOefR7ABAQ..&s=9fd739e9f0a6054296f9bb5168c49a89a425795c&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149418948, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 1, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 30000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_requireExactDuration.html&e=wqT_3QL4COh4BAAAAwDWAAUBCM2Op_AFEI-RmcaB1Yumexiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQxOefR1ic8VtgAGjNunV4xbgFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5MTQ5KTt1ZigncicsIDE0OTQxODk0OCwgMTUZH_D9kgK5AiE1anJrR1FpbWtfOFBFTVRubjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQm5LY0RrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBWG9KWno5WkdPTV8yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwcFBfRDdvRENWTkpUak02TkRjME4tQUR3aGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCWXNscVFVCRNAQUR3UHcuLpoCiQEhT3ctaUY6PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOelEzUU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M8F5lQUEu2AIA4AKtmEjqAllodHRwOi8vdGVzdC5sb2NhbGhvc3Q6OTk5OS9pbnRlZ3JhdGlvbkV4YW1wbGVzL2xvbmdmb3JtL2Jhc2ljX3dfcmVxdWlyZUV4YWN0RHVyYQEufC5odG1s8gITCg9DVVNUT01fTU9ERUxfSUQSAPICGgoWMhYAIExFQUZfTkFNRQEdCB4KGjYdAAhBU1QBPvDtSUZJRUQSAIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIEDTIwMi41OS4yMzEuNDeoBMLmBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzQ32gQCCAHgBADwBMTnn0eIBQGYBQCgBf___________wHABQDJBQAAAAAAAPA_0gUJCQAAAAAAAAAA2AUB4AUB8AWZPfoFBAgAEACQBgGYBgC4BgDBBgAAAAAAAPA_0Ab1L9oGFgoQAIkAFQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=1f8ea8f07f781fe149beb0d65dd25ad725a12f3b' + } + } + }] + }, { + 'uuid': '25593f19ac7ed2', + 'tag_id': 15394006, + 'auction_id': '1279521442385130931', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_requireExactDuration.html&e=wqT_3QKdCKAdBAAAAwDWAAUBCM2Op_AFELPr8f6Pv_HgERiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5MTQ5KTsBHTByJywgMTQ5NDE3NjY5Nh8A8P2SArkCIW9EeDJEQWlsa184UEVNWGRuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCbktjRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIenJXcWtBQUFrUU1FQjg2MXFwQUFBSkVESkFkb01fcFZkVGVVXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHBaUF9EN29EQ1ZOSlRqTTZORGMwTi1BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJZc2xxUVUJE0RBRHdQdy4umgKJASFKdzlKRHc2PQEkblBGYklBUW9BRBVIVGtRRG9KVTBsT016bzBOelEzUU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M8F5lQUEu2AIA4AKtmEjqAllodHRwOi8vdGVzdC5sb2NhbGhvc3Q6OTk5OS9pbnRlZ3JhdGlvbkV4YW1wbGVzL2xvbmdmb3JtL2Jhc2ljX3dfcmVxdWlyZUV4YWN0RHVyYQEu8J8uaHRtbIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIEDTIwMi41OS4yMzEuNDeoBMLmBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzQ32gQCCADgBADwBMXdn0eIBQGYBQCgBf______AQUUAcAFAMkFaWIU8D_SBQkJCQx4AADYBQHgBQHwBcLyF_oFBAgAEACQBgGYBgC4BgDBBgklKPC_0Ab1L9oGFgoQCREZAVAQABgA4AYE8gYCCACABwGIBwCgB0A.&s=4b14660ae659b3d301ec6c40f0f096bb88db145b', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=aAAAAAMArgAFAQlNxwleAAAAABGzddz_-MXBERlNxwleAAAAACDF3Z9HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1jC8hdiAklOaAFwAXgAgAEBiAEBkAGABZgB4AOgAQCoAcXdn0ewAQE.&s=5f277bcab624f05c9d3a3a9c111961f3f33ccca2&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149417669, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 10.000000, + 'cpm_publisher_currency': 10.000000, + 'publisher_currency_code': '$', + 'brand_category_id': 4, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 30000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_requireExactDuration.html&e=wqT_3QL5CKB5BAAAAwDWAAUBCM2Op_AFELPr8f6Pv_HgERiq5MnUovf28WEqNgkAAAECCCRAEQEHEAAAJEAZCQkI4D8hCQkIJEApEQkAMQkJsOA_MNbJqwc47UhA7UhIAlDF3Z9HWJzxW2AAaM26dXjFuAWAAQGKAQNVU0SSAQEG8FWYAQGgAQGoAQGwAQC4AQPAAQTIAQLQAQDYAQDgAQDwAQCKAjx1ZignYScsIDI1Mjk4ODUsIDE1Nzc2OTkxNDkpO3VmKCdyJywgMTQ5NDE3NjY5LCAxNRkf8P2SArkCIW9EeDJEQWlsa184UEVNWGRuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCbktjRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIenJXcWtBQUFrUU1FQjg2MXFwQUFBSkVESkFkb01fcFZkVGVVXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHBaUF9EN29EQ1ZOSlRqTTZORGMwTi1BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJZc2xxUVUJE0RBRHdQdy4umgKJASFKdzlKRHc2PQEkblBGYklBUW9BRBVIVGtRRG9KVTBsT016bzBOelEzUU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M8F5lQUEu2AIA4AKtmEjqAllodHRwOi8vdGVzdC5sb2NhbGhvc3Q6OTk5OS9pbnRlZ3JhdGlvbkV4YW1wbGVzL2xvbmdmb3JtL2Jhc2ljX3dfcmVxdWlyZUV4YWN0RHVyYQEufC5odG1s8gITCg9DVVNUT01fTU9ERUxfSUQSAPICGgoWMhYAIExFQUZfTkFNRQEdCB4KGjYdAAhBU1QBPvDeSUZJRUQSAIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIEDTIwMi41OS4yMzEuNDeoBMLmBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzQ32gQCCAHgBADwBMXdn0eIBQGYBQCgBf___________wHABQDJBQAAAAAAAPA_0gUJCQAAAAAAAAAA2AUB4AUB8AXC8hf6BQQIABAAkAYBmAYAuAYAwQYAAGHxKPA_0Ab1L9oGFgoQAQ8uAQBQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=7bb7b75e4769a1260eaed2c79752ee542b4d28ce' + } + } + }] + }, { + 'uuid': '25593f19ac7ed2', + 'tag_id': 15394006, + 'auction_id': '7664937561033023835', + 'nobid': true, + 'ad_profile_id': 1182765 + }] + } + } + } +} diff --git a/test/mock-server/expectations/request-response-pairs/longform/basic_wo_brandCategoryExclusion_request_1.js b/test/mock-server/expectations/request-response-pairs/longform/basic_wo_brandCategoryExclusion_request_1.js new file mode 100644 index 00000000000..ee1a19d21b2 --- /dev/null +++ b/test/mock-server/expectations/request-response-pairs/longform/basic_wo_brandCategoryExclusion_request_1.js @@ -0,0 +1,852 @@ +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 + * + */ + +/** + * 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': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }], + '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': '2c52d7d1f2f703', + 'tag_id': 15394006, + 'auction_id': '6316075342634007031', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_brandCategoryExclusion.html&e=wqT_3QKgCKAgBAAAAwDWAAUBCLeSp_AFEPfztqL2oc3TVxiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5NjM5KTsBHTByJywgMTQ5NDE4MTIzNh8A8P2SArkCIV96eWNLZ2lua184UEVJdmhuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCcktjRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFZYkYwSW1fZGU0XzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHA1UF9EN29EQ1ZOSlRqTTZORGMxTU9BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJZNGxxUVUJE0BBRHdQdy4umgKJASE5dzR0Xzo9ASRuUEZiSUFRb0FEFUhUdVFEb0pVMGxPTXpvME56VXdRTUlZUxF4DFBBX1URDAxBQUFXHQwAWR0MAGEdDABjHQz0UwFlQUEu2AIA4AKtmEjqAlxodHRwOi8vdGVzdC5sb2NhbGhvc3Q6OTk5OS9pbnRlZ3JhdGlvbkV4YW1wbGVzL2xvbmdmb3JtL2Jhc2ljX3dvX2JyYW5kQ2F0ZWdvcnlFeGNsdXNpb24uaHRtbIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIEDTIwMi41OS4yMzEuNDeoBMvmBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzUw2gQCCADgBADwBIvhn0eIBQGYBQCgBf___________wHABQDJBQAAAAAAAPA_0gUJCQAAAAAAAAAA2AUB4AUB8AXa1gL6BQQIABAAkAYBmAYAuAYAwQYAAAAAAADwv9AG9S_aBhYKEAAAaakRAVAQABgA4AYE8gYCCACABwGIBwCgB0A.&s=bb81a081c756fd493253bf765c06ff46888f009a', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=aAAAAAMArgAFAQk3yQleAAAAABH3uU1kDzWnVxk3yQleAAAAACCL4Z9HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1ja1gJiAklOaAFwAXgAgAEBiAEBkAGABZgB4AOgAQCoAYvhn0ewAQE.&s=a3da30186f69a5ce2edcfc14fa3a31b92ee70060&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149418123, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 12, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 15000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_brandCategoryExclusion.html&e=wqT_3QL8COh8BAAAAwDWAAUBCLeSp_AFEPfztqL2oc3TVxiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQi-GfR1ic8VtgAGjNunV4ybgFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5NjM5KTt1ZigncicsIDE0OTQxODEyMywgMTUZH_D9kgK5AiFfenljS2dpbmtfOFBFSXZobjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQnJLY0RrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBWWJGMEltX2RlNF8yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwNVBfRDdvRENWTkpUak02TkRjMU1PQUR3aGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCWTRscVFVCRNAQUR3UHcuLpoCiQEhOXc0dF86PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOelV3UU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M8ItlQUEu2AIA4AKtmEjqAlxodHRwOi8vdGVzdC5sb2NhbGhvc3Q6OTk5OS9pbnRlZ3JhdGlvbkV4YW1wbGVzL2xvbmdmb3JtL2Jhc2ljX3dvX2JyYW5kQ2F0ZWdvcnlFeGNsdXNpb24uaHRtbPICEwoPQ1VTVE9NX01PREVMX0lEEgDyAhoKFkNVU1RPTQ0WQExFQUZfTkFNRRIA8gIeChpDMh0ACEFTVAEo8JBJRklFRBIAgAMAiAMBkAMAmAMXoAMBqgMAwAPgqAHIAwDYAwDgAwDoAwD4AwGABACSBA0vdXQvdjMvcHJlYmlkmAQAogQNMjAyLjU5LjIzMS40N6gEy-YEsgQSCAEQAhiABSDgAygBKAIwADgDuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ3NTDaBAIIAeAEAPAEYZAgiAUBmAUAoAX_EQEUAcAFAMkFacEU8D_SBQkJCQx4AADYBQHgBQHwBdrWAvoFBAgAEACQBgGYBgC4BgDBBgklKPA_0Ab1L9oGFgoQCREZAVAQABgA4AYE8gYCCACABwGIBwCgB0A.&s=62b9db151b3739399e0970c74fafc4bb61486510' + } + } + }] + }, { + 'uuid': '2c52d7d1f2f703', + 'tag_id': 15394006, + 'auction_id': '8259815099516488747', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_brandCategoryExclusion.html&e=wqT_3QKfCKAfBAAAAwDWAAUBCLeSp_AFEKuY2qihwrDQchiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5NjM5KTsBHTByJywgMTQ5NDE4OTQ4Nh8A8P2SArkCIW1UeUFCd2lta184UEVNVG5uMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCcktjRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFYNml4eGFGdE8wXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHBwUF9EN29EQ1ZOSlRqTTZORGMxTU9BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJZNGxxUVUJE0RBRHdQdy4umgKJASFOUTg3RkE2PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOelV3UU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M9FMBZUFBLtgCAOACrZhI6gJcaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193b19icmFuZENhdGVnb3J5RXhjbHVzaW9uLmh0bWyAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My9wcmViaWSYBACiBA0yMDIuNTkuMjMxLjQ3qATL5gSyBBIIARACGIAFIOADKAEoAjAAOAO4BADABADIBADSBA45MzI1I1NJTjM6NDc1MNoEAggA4AQA8ATE559HiAUBmAUAoAX___________8BwAUAyQUAAAAAAADwP9IFCQkAAAAAAAAAANgFAeAFAfAFmT36BQQIABAAkAYBmAYAuAYAwQYAAAAAAADwv9AG9S_aBhYKEAAAAGmpDQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=8a55db8e788616ef057647b49c0560296fdacb65', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=ZwAAAAMArgAFAQk3yQleAAAAABErjBYVEsKgchk3yQleAAAAACDE559HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1iZPWICSU5oAXABeACAAQGIAQGQAYAFmAHgA6ABAKgBxOefR7ABAQ..&s=75d46be63f76fd4062f354a56c692855da366148&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149418948, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 1, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 30000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_brandCategoryExclusion.html&e=wqT_3QL7COh7BAAAAwDWAAUBCLeSp_AFEKuY2qihwrDQchiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQxOefR1ic8VtgAGjNunV4ybgFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5NjM5KTt1ZigncicsIDE0OTQxODk0OCwgMTUZH_D9kgK5AiFtVHlBQndpbWtfOFBFTVRubjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQnJLY0RrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBWDZpeHhhRnRPMF8yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwcFBfRDdvRENWTkpUak02TkRjMU1PQUR3aGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCWTRscVFVCRNEQUR3UHcuLpoCiQEhTlE4N0ZBNj0BJG5QRmJJQVFvQUQVSFR1UURvSlUwbE9Nem8wTnpVd1FNSVlTEXgMUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDPCLZUFBLtgCAOACrZhI6gJcaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193b19icmFuZENhdGVnb3J5RXhjbHVzaW9uLmh0bWzyAhMKD0NVU1RPTV9NT0RFTF9JRBIA8gIaChZDVVNUT00NFkBMRUFGX05BTUUSAPICHgoaQzIdAAhBU1QBKPDtSUZJRUQSAIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIEDTIwMi41OS4yMzEuNDeoBMvmBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzUw2gQCCAHgBADwBMTnn0eIBQGYBQCgBf___________wHABQDJBQAAAAAAAPA_0gUJCQAAAAAAAAAA2AUB4AUB8AWZPfoFBAgAEACQBgGYBgC4BgDBBgAAAAAAAPA_0Ab1L9oGFgoQAIkDFQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=59e0ab1f626c2e4dc5c4f6e6837b77559cf502b4' + } + } + }] + }, { + 'uuid': '2c52d7d1f2f703', + 'tag_id': 15394006, + 'auction_id': '7960926407704980889', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_brandCategoryExclusion.html&e=wqT_3QKgCKAgBAAAAwDWAAUBCLeSp_AFEJnboLK5jLm9bhiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5NjM5KTsBHTByJywgMTQ5NDE3OTUxNh8A8P2SArkCIUZEeFl4QWlta184UEVOX2ZuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCcktjRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFhSUpVQVhXMC1JXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHBwUF9EN29EQ1ZOSlRqTTZORGMxTU9BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJZNGxxUVUJE0RBRHdQdy4umgKJASFTQThFR3c2PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOelV3UU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M9FMBZUFBLtgCAOACrZhI6gJcaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193b19icmFuZENhdGVnb3J5RXhjbHVzaW9uLmh0bWyAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My9wcmViaWSYBACiBA0yMDIuNTkuMjMxLjQ3qATL5gSyBBIIARACGIAFIOADKAEoAjAAOAO4BADABADIBADSBA45MzI1I1NJTjM6NDc1MNoEAggA4AQA8ATf359HiAUBmAUAoAX___________8BwAUAyQUAAAAAAADwP9IFCQkAAAAAAAAAANgFAeAFAfAFrLwU-gUECAAQAJAGAZgGALgGAMEGAAAAAAAA8L_QBvUv2gYWChAAAGmpEQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=8d00bc7576c3cc19fe8b3fb4aa42966583741dfa', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=aAAAAAMArgAFAQk3yQleAAAAABGZLUiWY-R6bhk3yQleAAAAACDf359HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1isvBRiAklOaAFwAXgAgAEBiAEBkAGABZgB4AOgAQCoAd_fn0ewAQE.&s=c813392cbb81d43466d5d949b9bebc2305e6fe7d&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149417951, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 33, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 30000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_brandCategoryExclusion.html&e=wqT_3QL8COh8BAAAAwDWAAUBCLeSp_AFEJnboLK5jLm9bhiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQ39-fR1ic8VtgAGjNunV4ybgFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5NjM5KTt1ZigncicsIDE0OTQxNzk1MSwgMTUZH_D9kgK5AiFGRHhZeEFpbWtfOFBFTl9mbjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQnJLY0RrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBYUlKVUFYVzAtSV8yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwcFBfRDdvRENWTkpUak02TkRjMU1PQUR3aGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCWTRscVFVCRNEQUR3UHcuLpoCiQEhU0E4RUd3Nj0BJG5QRmJJQVFvQUQVSFR1UURvSlUwbE9Nem8wTnpVd1FNSVlTEXgMUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDPCLZUFBLtgCAOACrZhI6gJcaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193b19icmFuZENhdGVnb3J5RXhjbHVzaW9uLmh0bWzyAhMKD0NVU1RPTV9NT0RFTF9JRBIA8gIaChZDVVNUT00NFkBMRUFGX05BTUUSAPICHgoaQzIdAAhBU1QBKPCQSUZJRUQSAIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIEDTIwMi41OS4yMzEuNDeoBMvmBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzUw2gQCCAHgBADwBGGQIIgFAZgFAKAF_xEBFAHABQDJBWnBFPA_0gUJCQkMeAAA2AUB4AUB8AWsvBT6BQQIABAAkAYBmAYAuAYAwQYJJSjwP9AG9S_aBhYKEAkRGQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=284760a6e2d4f226b639d29237e9c1aa25ca49a9' + } + } + }] + }, { + 'uuid': '2c52d7d1f2f703', + 'tag_id': 15394006, + 'auction_id': '7561862402601574638', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_brandCategoryExclusion.html&e=wqT_3QKgCKAgBAAAAwDWAAUBCLeSp_AFEO7By9umucj4aBiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5NjM5KTsBHTByJywgMTQ5NDE5NjAyNh8A8P2SArkCITREcWpId2lua184UEVOTHNuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCcktjRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFTSVA1dzg5RGVRXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHA1UF9EN29EQ1ZOSlRqTTZORGMxTU9BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJZNGxxUVUJE0BBRHdQdy4umgKJASFTUTlYRzo9ASRuUEZiSUFRb0FEFUhUdVFEb0pVMGxPTXpvME56VXdRTUlZUxF4DFBBX1URDAxBQUFXHQwAWR0MAGEdDABjHQz0UwFlQUEu2AIA4AKtmEjqAlxodHRwOi8vdGVzdC5sb2NhbGhvc3Q6OTk5OS9pbnRlZ3JhdGlvbkV4YW1wbGVzL2xvbmdmb3JtL2Jhc2ljX3dvX2JyYW5kQ2F0ZWdvcnlFeGNsdXNpb24uaHRtbIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIEDTIwMi41OS4yMzEuNDeoBMvmBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzUw2gQCCADgBADwBNLsn0eIBQGYBQCgBf___________wHABQDJBQAAAAAAAPA_0gUJCQAAAAAAAAAA2AUB4AUB8AXZugb6BQQIABAAkAYBmAYAuAYAwQYAAAAAAADwv9AG9S_aBhYKEAAAaakRAVAQABgA4AYE8gYCCACABwGIBwCgB0A.&s=917e8af2ed1c82091f487b6abd78de47b99e9e46', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=aAAAAAMArgAFAQk3yQleAAAAABHu4HJryiHxaBk3yQleAAAAACDS7J9HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1jZugZiAklOaAFwAXgAgAEBiAEBkAGABZgB4AOgAQCoAdLsn0ewAQE.&s=ff73768bfb14e9ae603064fc91e95b60c8d872e2&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149419602, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 24, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 15000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_brandCategoryExclusion.html&e=wqT_3QL8COh8BAAAAwDWAAUBCLeSp_AFEO7By9umucj4aBiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQ0uyfR1ic8VtgAGjNunV4ybgFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5NjM5KTt1ZigncicsIDE0OTQxOTYwMiwgMTUZH_D9kgK5AiE0RHFqSHdpbmtfOFBFTkxzbjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQnJLY0RrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBU0lQNXc4OURlUV8yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwNVBfRDdvRENWTkpUak02TkRjMU1PQUR3aGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCWTRscVFVCRNAQUR3UHcuLpoCiQEhU1E5WEc6PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOelV3UU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M8ItlQUEu2AIA4AKtmEjqAlxodHRwOi8vdGVzdC5sb2NhbGhvc3Q6OTk5OS9pbnRlZ3JhdGlvbkV4YW1wbGVzL2xvbmdmb3JtL2Jhc2ljX3dvX2JyYW5kQ2F0ZWdvcnlFeGNsdXNpb24uaHRtbPICEwoPQ1VTVE9NX01PREVMX0lEEgDyAhoKFkNVU1RPTQ0WQExFQUZfTkFNRRIA8gIeChpDMh0ACEFTVAEo8JBJRklFRBIAgAMAiAMBkAMAmAMXoAMBqgMAwAPgqAHIAwDYAwDgAwDoAwD4AwGABACSBA0vdXQvdjMvcHJlYmlkmAQAogQNMjAyLjU5LjIzMS40N6gEy-YEsgQSCAEQAhiABSDgAygBKAIwADgDuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ3NTDaBAIIAeAEAPAEYZAgiAUBmAUAoAX_EQEUAcAFAMkFacEU8D_SBQkJCQx4AADYBQHgBQHwBdm6BvoFBAgAEACQBgGYBgC4BgDBBgklKPA_0Ab1L9oGFgoQCREZAVAQABgA4AYE8gYCCACABwGIBwCgB0A.&s=84c66b632a2930d28092e00985ee154ba2e97288' + } + } + }] + }, { + 'uuid': '2c52d7d1f2f703', + 'tag_id': 15394006, + 'auction_id': '6577796711489765634', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_brandCategoryExclusion.html&e=wqT_3QKgCKAgBAAAAwDWAAUBCLeSp_AFEIKC0sii6MGkWxiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5NjM5KTsBHTByJywgMTQ5NDE4MTIzNh8A8P2SArkCIVBUem53UWlua184UEVJdmhuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCcktjRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFlaE5hMWl1Y3V3XzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHA1UF9EN29EQ1ZOSlRqTTZORGMxTU9BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJZNGxxUVUJE0RBRHdQdy4umgKJASE5dzR0X2c2PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOelV3UU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M9FMBZUFBLtgCAOACrZhI6gJcaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193b19icmFuZENhdGVnb3J5RXhjbHVzaW9uLmh0bWyAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My9wcmViaWSYBACiBA0yMDIuNTkuMjMxLjQ3qATL5gSyBBIIARACGIAFIOADKAEoAjAAOAO4BADABADIBADSBA45MzI1I1NJTjM6NDc1MNoEAggA4AQA8ASL4Z9HiAUBmAUAoAX___________8BwAUAyQUAAAAAAADwP9IFCQkAAAAAAAAAANgFAeAFAfAF2tYC-gUECAAQAJAGAZgGALgGAMEGAAAAAAAA8L_QBvUv2gYWChAAAGmpEQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=ea4a54786a8f3cf5177b3372ce97682da060c358', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=aAAAAAMArgAFAQk3yQleAAAAABECgRQpQgdJWxk3yQleAAAAACCL4Z9HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1ja1gJiAklOaAFwAXgAgAEBiAEBkAGABZgB4AOgAQCoAYvhn0ewAQE.&s=778fbf3014328ec0b01d6ebd7b306be32cf79950&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149418123, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 12, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 15000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_brandCategoryExclusion.html&e=wqT_3QL8COh8BAAAAwDWAAUBCLeSp_AFEIKC0sii6MGkWxiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQi-GfR1ic8VtgAGjNunV4ybgFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5NjM5KTt1ZigncicsIDE0OTQxODEyMywgMTUZH_D9kgK5AiFQVHpud1FpbmtfOFBFSXZobjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQnJLY0RrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBZWhOYTFpdWN1d18yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwNVBfRDdvRENWTkpUak02TkRjMU1PQUR3aGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCWTRscVFVCRNEQUR3UHcuLpoCiQEhOXc0dF9nNj0BJG5QRmJJQVFvQUQVSFR1UURvSlUwbE9Nem8wTnpVd1FNSVlTEXgMUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDPCLZUFBLtgCAOACrZhI6gJcaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193b19icmFuZENhdGVnb3J5RXhjbHVzaW9uLmh0bWzyAhMKD0NVU1RPTV9NT0RFTF9JRBIA8gIaChZDVVNUT00NFkBMRUFGX05BTUUSAPICHgoaQzIdAAhBU1QBKPCQSUZJRUQSAIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIEDTIwMi41OS4yMzEuNDeoBMvmBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzUw2gQCCAHgBADwBGGQIIgFAZgFAKAF_xEBFAHABQDJBWnBFPA_0gUJCQkMeAAA2AUB4AUB8AXa1gL6BQQIABAAkAYBmAYAuAYAwQYJJSjwP9AG9S_aBhYKEAkRGQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=28a3b583912b95528519f63a75c0fe2d06064e7b' + } + } + }] + }, { + 'uuid': '2c52d7d1f2f703', + 'tag_id': 15394006, + 'auction_id': '2418275491761094586', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_brandCategoryExclusion.html&e=wqT_3QKgCKAgBAAAAwDWAAUBCLeSp_AFELr_z7v0l9zHIRiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5NjM5KTsBHTByJywgMTQ5NDE5NjAyNh8A8P2SArkCIUF6MUJSZ2lua184UEVOTHNuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCcktjRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFVNUE2dXpUVy1ZXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHA1UF9EN29EQ1ZOSlRqTTZORGMxTU9BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJZNGxxUVUJE0RBRHdQdy4umgKJASFTUTlYR3c2PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOelV3UU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M9FMBZUFBLtgCAOACrZhI6gJcaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193b19icmFuZENhdGVnb3J5RXhjbHVzaW9uLmh0bWyAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My9wcmViaWSYBACiBA0yMDIuNTkuMjMxLjQ3qATL5gSyBBIIARACGIAFIOADKAEoAjAAOAO4BADABADIBADSBA45MzI1I1NJTjM6NDc1MNoEAggA4AQA8ATS7J9HiAUBmAUAoAX___________8BwAUAyQUAAAAAAADwP9IFCQkAAAAAAAAAANgFAeAFAfAF2boG-gUECAAQAJAGAZgGALgGAMEGAAAAAAAA8L_QBvUv2gYWChAAAGmpEQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=c563626304ebb31fd6f1644cc2d4098133dec096', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=aAAAAAMArgAFAQk3yQleAAAAABG6_3NHv3CPIRk3yQleAAAAACDS7J9HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1jZugZiAklOaAFwAXgAgAEBiAEBkAGABZgB4AOgAQCoAdLsn0ewAQE.&s=88c9fbb2b9dc273865a5f9238543a29224908b26&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149419602, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 24, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 15000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_brandCategoryExclusion.html&e=wqT_3QL8COh8BAAAAwDWAAUBCLeSp_AFELr_z7v0l9zHIRiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQ0uyfR1ic8VtgAGjNunV4ybgFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5NjM5KTt1ZigncicsIDE0OTQxOTYwMiwgMTUZH_D9kgK5AiFBejFCUmdpbmtfOFBFTkxzbjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQnJLY0RrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBVTVBNnV6VFctWV8yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwNVBfRDdvRENWTkpUak02TkRjMU1PQUR3aGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCWTRscVFVCRNEQUR3UHcuLpoCiQEhU1E5WEd3Nj0BJG5QRmJJQVFvQUQVSFR1UURvSlUwbE9Nem8wTnpVd1FNSVlTEXgMUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDPCLZUFBLtgCAOACrZhI6gJcaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193b19icmFuZENhdGVnb3J5RXhjbHVzaW9uLmh0bWzyAhMKD0NVU1RPTV9NT0RFTF9JRBIA8gIaChZDVVNUT00NFkBMRUFGX05BTUUSAPICHgoaQzIdAAhBU1QBKPCQSUZJRUQSAIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIEDTIwMi41OS4yMzEuNDeoBMvmBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzUw2gQCCAHgBADwBGGQIIgFAZgFAKAF_xEBFAHABQDJBWnBFPA_0gUJCQkMeAAA2AUB4AUB8AXZugb6BQQIABAAkAYBmAYAuAYAwQYJJSjwP9AG9S_aBhYKEAkRGQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=e76aeb8daad477f4428631fc89d277d4a4646ded' + } + } + }] + }, { + 'uuid': '2c52d7d1f2f703', + 'tag_id': 15394006, + 'auction_id': '5990197965284733361', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_brandCategoryExclusion.html&e=wqT_3QKgCKAgBAAAAwDWAAUBCLeSp_AFELHjwfj9qd2QUxiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5NjM5KTsBHTByJywgMTQ5NDE5NjAyNh8A8P2SArkCIURUeDF3d2lua184UEVOTHNuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCcktjRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFmWXBYSEoxUGVNXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHA1UF9EN29EQ1ZOSlRqTTZORGMxTU9BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJZNGxxUVUJE0BBRHdQdy4umgKJASFTUTlYRzo9ASRuUEZiSUFRb0FEFUhUdVFEb0pVMGxPTXpvME56VXdRTUlZUxF4DFBBX1URDAxBQUFXHQwAWR0MAGEdDABjHQz0UwFlQUEu2AIA4AKtmEjqAlxodHRwOi8vdGVzdC5sb2NhbGhvc3Q6OTk5OS9pbnRlZ3JhdGlvbkV4YW1wbGVzL2xvbmdmb3JtL2Jhc2ljX3dvX2JyYW5kQ2F0ZWdvcnlFeGNsdXNpb24uaHRtbIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIEDTIwMi41OS4yMzEuNDeoBMvmBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzUw2gQCCADgBADwBNLsn0eIBQGYBQCgBf___________wHABQDJBQAAAAAAAPA_0gUJCQAAAAAAAAAA2AUB4AUB8AXZugb6BQQIABAAkAYBmAYAuAYAwQYAAAAAAADwv9AG9S_aBhYKEAAAaakRAVAQABgA4AYE8gYCCACABwGIBwCgB0A.&s=e443347514ff5f6a52a2811f591f9a346061a756', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=aAAAAAMArgAFAQk3yQleAAAAABGxcRDfT3UhUxk3yQleAAAAACDS7J9HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1jZugZiAklOaAFwAXgAgAEBiAEBkAGABZgB4AOgAQCoAdLsn0ewAQE.&s=50348eb78116f7d35ca5ac6f6fa4c5548a6ceffc&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149419602, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 24, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 15000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_brandCategoryExclusion.html&e=wqT_3QL8COh8BAAAAwDWAAUBCLeSp_AFELHjwfj9qd2QUxiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQ0uyfR1ic8VtgAGjNunV4ybgFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5NjM5KTt1ZigncicsIDE0OTQxOTYwMiwgMTUZH_D9kgK5AiFEVHgxd3dpbmtfOFBFTkxzbjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQnJLY0RrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBZllwWEhKMVBlTV8yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwNVBfRDdvRENWTkpUak02TkRjMU1PQUR3aGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCWTRscVFVCRNAQUR3UHcuLpoCiQEhU1E5WEc6PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOelV3UU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M8ItlQUEu2AIA4AKtmEjqAlxodHRwOi8vdGVzdC5sb2NhbGhvc3Q6OTk5OS9pbnRlZ3JhdGlvbkV4YW1wbGVzL2xvbmdmb3JtL2Jhc2ljX3dvX2JyYW5kQ2F0ZWdvcnlFeGNsdXNpb24uaHRtbPICEwoPQ1VTVE9NX01PREVMX0lEEgDyAhoKFkNVU1RPTQ0WQExFQUZfTkFNRRIA8gIeChpDMh0ACEFTVAEo8JBJRklFRBIAgAMAiAMBkAMAmAMXoAMBqgMAwAPgqAHIAwDYAwDgAwDoAwD4AwGABACSBA0vdXQvdjMvcHJlYmlkmAQAogQNMjAyLjU5LjIzMS40N6gEy-YEsgQSCAEQAhiABSDgAygBKAIwADgDuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ3NTDaBAIIAeAEAPAEYZAgiAUBmAUAoAX_EQEUAcAFAMkFacEU8D_SBQkJCQx4AADYBQHgBQHwBdm6BvoFBAgAEACQBgGYBgC4BgDBBgklKPA_0Ab1L9oGFgoQCREZAVAQABgA4AYE8gYCCACABwGIBwCgB0A.&s=a24f331ff55f96c5afe5134762f8d8e230b6287c' + } + } + }] + }, { + 'uuid': '2c52d7d1f2f703', + 'tag_id': 15394006, + 'auction_id': '4399290132982250349', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_brandCategoryExclusion.html&e=wqT_3QKgCKAgBAAAAwDWAAUBCLeSp_AFEO32psKU4tqGPRiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5NjM5KTsBHTByJywgMTQ5NDE5NjAyNh8A8P2SArkCITN6dDlwd2lua184UEVOTHNuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCcktjRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFRWlZqbkpncmV3XzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHA1UF9EN29EQ1ZOSlRqTTZORGMxTU9BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJZNGxxUVUJE0BBRHdQdy4umgKJASFTUTlYRzo9ASRuUEZiSUFRb0FEFUhUdVFEb0pVMGxPTXpvME56VXdRTUlZUxF4DFBBX1URDAxBQUFXHQwAWR0MAGEdDABjHQz0UwFlQUEu2AIA4AKtmEjqAlxodHRwOi8vdGVzdC5sb2NhbGhvc3Q6OTk5OS9pbnRlZ3JhdGlvbkV4YW1wbGVzL2xvbmdmb3JtL2Jhc2ljX3dvX2JyYW5kQ2F0ZWdvcnlFeGNsdXNpb24uaHRtbIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIEDTIwMi41OS4yMzEuNDeoBMvmBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzUw2gQCCADgBADwBNLsn0eIBQGYBQCgBf___________wHABQDJBQAAAAAAAPA_0gUJCQAAAAAAAAAA2AUB4AUB8AXZugb6BQQIABAAkAYBmAYAuAYAwQYAAAAAAADwv9AG9S_aBhYKEAAAaakRAVAQABgA4AYE8gYCCACABwGIBwCgB0A.&s=0d9b0a06992ff427d281fae8d8b18d4e6838b944', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=aAAAAAMArgAFAQk3yQleAAAAABFtu0lIEWsNPRk3yQleAAAAACDS7J9HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1jZugZiAklOaAFwAXgAgAEBiAEBkAGABZgB4AOgAQCoAdLsn0ewAQE.&s=52a446d84f5e9a2baa068760c4406f4a567a911a&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149419602, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 24, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 15000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_brandCategoryExclusion.html&e=wqT_3QL8COh8BAAAAwDWAAUBCLeSp_AFEO32psKU4tqGPRiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQ0uyfR1ic8VtgAGjNunV4ybgFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5NjM5KTt1ZigncicsIDE0OTQxOTYwMiwgMTUZH_D9kgK5AiEzenQ5cHdpbmtfOFBFTkxzbjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQnJLY0RrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBUVpWam5KZ3Jld18yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwNVBfRDdvRENWTkpUak02TkRjMU1PQUR3aGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCWTRscVFVCRNAQUR3UHcuLpoCiQEhU1E5WEc6PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOelV3UU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M8ItlQUEu2AIA4AKtmEjqAlxodHRwOi8vdGVzdC5sb2NhbGhvc3Q6OTk5OS9pbnRlZ3JhdGlvbkV4YW1wbGVzL2xvbmdmb3JtL2Jhc2ljX3dvX2JyYW5kQ2F0ZWdvcnlFeGNsdXNpb24uaHRtbPICEwoPQ1VTVE9NX01PREVMX0lEEgDyAhoKFkNVU1RPTQ0WQExFQUZfTkFNRRIA8gIeChpDMh0ACEFTVAEo8JBJRklFRBIAgAMAiAMBkAMAmAMXoAMBqgMAwAPgqAHIAwDYAwDgAwDoAwD4AwGABACSBA0vdXQvdjMvcHJlYmlkmAQAogQNMjAyLjU5LjIzMS40N6gEy-YEsgQSCAEQAhiABSDgAygBKAIwADgDuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ3NTDaBAIIAeAEAPAEYZAgiAUBmAUAoAX_EQEUAcAFAMkFacEU8D_SBQkJCQx4AADYBQHgBQHwBdm6BvoFBAgAEACQBgGYBgC4BgDBBgklKPA_0Ab1L9oGFgoQCREZAVAQABgA4AYE8gYCCACABwGIBwCgB0A.&s=e6ae592b5fc3de0053b5acd46294b83549aa00c8' + } + } + }] + }, { + 'uuid': '2c52d7d1f2f703', + 'tag_id': 15394006, + 'auction_id': '8677372908685012092', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_brandCategoryExclusion.html&e=wqT_3QKgCKAgBAAAAwDWAAUBCLeSp_AFEPzYku74lY62eBiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5NjM5KTsBHTByJywgMTQ5NDE4MTIzNh8A8P2SArkCIVVEeGp5d2lua184UEVJdmhuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCcktjRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFVN29abmh2c09RXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHA1UF9EN29EQ1ZOSlRqTTZORGMxTU9BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJZNGxxUVUJE0RBRHdQdy4umgKJASE5dzR0X2c2PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOelV3UU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M9FMBZUFBLtgCAOACrZhI6gJcaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193b19icmFuZENhdGVnb3J5RXhjbHVzaW9uLmh0bWyAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My9wcmViaWSYBACiBA0yMDIuNTkuMjMxLjQ3qATL5gSyBBIIARACGIAFIOADKAEoAjAAOAO4BADABADIBADSBA45MzI1I1NJTjM6NDc1MNoEAggA4AQA8ASL4Z9HiAUBmAUAoAX___________8BwAUAyQUAAAAAAADwP9IFCQkAAAAAAAAAANgFAeAFAfAF2tYC-gUECAAQAJAGAZgGALgGAMEGAAAAAAAA8L_QBvUv2gYWChAAAGmpEQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=522b764f2276ce75053a55a0198b79fb8d1d39d5', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=aAAAAAMArgAFAQk3yQleAAAAABF8rMSNrzhseBk3yQleAAAAACCL4Z9HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1ja1gJiAklOaAFwAXgAgAEBiAEBkAGABZgB4AOgAQCoAYvhn0ewAQE.&s=02b75d0ecc71c7897b9590be5e50b094158c8097&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149418123, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 12, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 15000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_brandCategoryExclusion.html&e=wqT_3QL8COh8BAAAAwDWAAUBCLeSp_AFEPzYku74lY62eBiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQi-GfR1ic8VtgAGjNunV4ybgFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5NjM5KTt1ZigncicsIDE0OTQxODEyMywgMTUZH_D9kgK5AiFVRHhqeXdpbmtfOFBFSXZobjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQnJLY0RrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBVTdvWm5odnNPUV8yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwNVBfRDdvRENWTkpUak02TkRjMU1PQUR3aGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCWTRscVFVCRNEQUR3UHcuLpoCiQEhOXc0dF9nNj0BJG5QRmJJQVFvQUQVSFR1UURvSlUwbE9Nem8wTnpVd1FNSVlTEXgMUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDPCLZUFBLtgCAOACrZhI6gJcaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193b19icmFuZENhdGVnb3J5RXhjbHVzaW9uLmh0bWzyAhMKD0NVU1RPTV9NT0RFTF9JRBIA8gIaChZDVVNUT00NFkBMRUFGX05BTUUSAPICHgoaQzIdAAhBU1QBKPCQSUZJRUQSAIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIEDTIwMi41OS4yMzEuNDeoBMvmBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzUw2gQCCAHgBADwBGGQIIgFAZgFAKAF_xEBFAHABQDJBWnBFPA_0gUJCQkMeAAA2AUB4AUB8AXa1gL6BQQIABAAkAYBmAYAuAYAwQYJJSjwP9AG9S_aBhYKEAkRGQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=0ae5558a7b0cc87eaa0c6811522629963b41bac5' + } + } + }] + }, { + 'uuid': '2c52d7d1f2f703', + 'tag_id': 15394006, + 'auction_id': '617065604518434488', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_brandCategoryExclusion.html&e=wqT_3QKgCKAgBAAAAwDWAAUBCLeSp_AFELitu4PevJDICBiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5NjM5KTsBHTByJywgMTQ5NDE5NjAyNh8A8P2SArkCIUFqMVNSZ2lua184UEVOTHNuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCcktjRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFaUzdZYTg5Ny13XzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHA1UF9EN29EQ1ZOSlRqTTZORGMxTU9BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJZNGxxUVUJE0RBRHdQdy4umgKJASFTUTlYR3c2PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOelV3UU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M9HYBZUFBLtgCAOACrZhI6gJcaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193b19icmFuZENhdGVnb3J5RXhjbHVzaW9uLmh0bWyAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My9wcmViaWSYBACiBA0yMDIuNTkuMjMxLjQ3qATL5gSyBBIIARACGIAFIOADKAEoAjAAOAO4BADABADIBADSBA45MzI1I1NJTjM6NDc1MNoEAggA4AQA8ATS7J9HiAUBmAUAoAX___________8BwAUAyQUAAAAAAADwP9IFCQkAAAAAAAAAANgFAeAFAfAF2boG-gUECAAQAJAGAZgGALgGAMEGAAAAAAAA8L_QBvUv2gYWChAAAAAAAAAAAAAAAAAAAAAAEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=f59bdb7b0f7020f75c6019f23686915b72d61779', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=aAAAAAMArgAFAQk3yQleAAAAABG41m7g5UGQCBk3yQleAAAAACDS7J9HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1jZugZiAklOaAFwAXgAgAEBiAEBkAGABZgB4AOgAQCoAdLsn0ewAQE.&s=912a721db8e85d4d64a8869d7cf9b56cd0c24907&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149419602, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 24, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 15000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_brandCategoryExclusion.html&e=wqT_3QL8COh8BAAAAwDWAAUBCLeSp_AFELitu4PevJDICBiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQ0uyfR1ic8VtgAGjNunV4ybgFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5NjM5KTt1ZigncicsIDE0OTQxOTYwMiwgMTUZH_D9kgK5AiFBajFTUmdpbmtfOFBFTkxzbjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQnJLY0RrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBWlM3WWE4OTctd18yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwNVBfRDdvRENWTkpUak02TkRjMU1PQUR3aGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCWTRscVFVCRNEQUR3UHcuLpoCiQEhU1E5WEd3Nj0BJG5QRmJJQVFvQUQVSFR1UURvSlUwbE9Nem8wTnpVd1FNSVlTEXgMUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDPCLZUFBLtgCAOACrZhI6gJcaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193b19icmFuZENhdGVnb3J5RXhjbHVzaW9uLmh0bWzyAhMKD0NVU1RPTV9NT0RFTF9JRBIA8gIaChZDVVNUT00NFkBMRUFGX05BTUUSAPICHgoaQzIdAAhBU1QBKPCQSUZJRUQSAIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIEDTIwMi41OS4yMzEuNDeoBMvmBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzUw2gQCCAHgBADwBGGQIIgFAZgFAKAF_xEBGAHABQDJBQAFARTwP9IFCQkFC3wAAADYBQHgBQHwBdm6BvoFBAgAEACQBgGYBgC4BgDBBgEhMAAA8D_QBvUv2gYWChAJERkBUBAAGADgBgTyBgIIAIAHAYgHAKAHQA..&s=9b4372ae0674305d9cd7152959910d1fa7d4daec' + } + } + }] + }, { + 'uuid': '2c52d7d1f2f703', + 'tag_id': 15394006, + 'auction_id': '8957511111704921777', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_brandCategoryExclusion.html&e=wqT_3QKfCKAfBAAAAwDWAAUBCLeSp_AFELGNpebanN6nfBiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5NjM5KTsBHTByJywgMTQ5NDE4NjcxNh8A8P2SArkCIXVqdHppQWlta184UEVLX2xuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCcktjRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFUM1dNOVpkQU9JXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHBwUF9EN29EQ1ZOSlRqTTZORGMxTU9BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJZNGxxUVUJE0BBRHdQdy4umgKJASFIZzhRRDo9ASRuUEZiSUFRb0FEFUhUdVFEb0pVMGxPTXpvME56VXdRTUlZUxF4DFBBX1URDAxBQUFXHQwAWR0MAGEdDABjHQz0UwFlQUEu2AIA4AKtmEjqAlxodHRwOi8vdGVzdC5sb2NhbGhvc3Q6OTk5OS9pbnRlZ3JhdGlvbkV4YW1wbGVzL2xvbmdmb3JtL2Jhc2ljX3dvX2JyYW5kQ2F0ZWdvcnlFeGNsdXNpb24uaHRtbIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIEDTIwMi41OS4yMzEuNDeoBMvmBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzUw2gQCCADgBADwBK_ln0eIBQGYBQCgBf___________wHABQDJBQAAAAAAAPA_0gUJCQAAAAAAAAAA2AUB4AUB8AXgWPoFBAgAEACQBgGYBgC4BgDBBgAAAAAAAPC_0Ab1L9oGFgoQAAAAaakNAVAQABgA4AYE8gYCCACABwGIBwCgB0A.&s=a8817d9dc3326ba1b59fe308f126ddaca5710a9c', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=ZwAAAAMArgAFAQk3yQleAAAAABGxRsms5XhPfBk3yQleAAAAACCv5Z9HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1jgWGICSU5oAXABeACAAQGIAQGQAYAFmAHgA6ABAKgBr-WfR7ABAQ..&s=a0ac94e902cbc609881fa9f39537bbc67ba046e7&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149418671, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 30, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 30000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_brandCategoryExclusion.html&e=wqT_3QL7COh7BAAAAwDWAAUBCLeSp_AFELGNpebanN6nfBiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQr-WfR1ic8VtgAGjNunV4ybgFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5NjM5KTt1ZigncicsIDE0OTQxODY3MSwgMTUZH_D9kgK5AiF1anR6aUFpbWtfOFBFS19sbjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQnJLY0RrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBVDNXTTlaZEFPSV8yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwcFBfRDdvRENWTkpUak02TkRjMU1PQUR3aGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCWTRscVFVCRNAQUR3UHcuLpoCiQEhSGc4UUQ6PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOelV3UU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M8ItlQUEu2AIA4AKtmEjqAlxodHRwOi8vdGVzdC5sb2NhbGhvc3Q6OTk5OS9pbnRlZ3JhdGlvbkV4YW1wbGVzL2xvbmdmb3JtL2Jhc2ljX3dvX2JyYW5kQ2F0ZWdvcnlFeGNsdXNpb24uaHRtbPICEwoPQ1VTVE9NX01PREVMX0lEEgDyAhoKFkNVU1RPTQ0WQExFQUZfTkFNRRIA8gIeChpDMh0ACEFTVAEo8JBJRklFRBIAgAMAiAMBkAMAmAMXoAMBqgMAwAPgqAHIAwDYAwDgAwDoAwD4AwGABACSBA0vdXQvdjMvcHJlYmlkmAQAogQNMjAyLjU5LjIzMS40N6gEy-YEsgQSCAEQAhiABSDgAygBKAIwADgDuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ3NTDaBAIIAeAEAPAEYZAgiAUBmAUAoAX_EQEUAcAFAMkFacEU8D_SBQkJCQx0AADYBQHgBQHwBeBY-gUECAAQAJAGAZgGALgGAMEGCSQo8D_QBvUv2gYWChAJERkBUBAAGADgBgTyBgIIAIAHAYgHAKAHQA..&s=75b3ad3e867323196da165cd655b3ae51c8b44d0' + } + } + }] + }, { + 'uuid': '2c52d7d1f2f703', + 'tag_id': 15394006, + 'auction_id': '2680240375770812721', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_brandCategoryExclusion.html&e=wqT_3QKfCKAfBAAAAwDWAAUBCLeSp_AFELGi6rO9jYiZJRiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5NjM5KTsBHTByJywgMTQ5NDE4OTQ4Nh8A8P2SArkCIWd6eTMtZ2lta184UEVNVG5uMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCcktjRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFYcFdVTk9rai1jXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHBwUF9EN29EQ1ZOSlRqTTZORGMxTU9BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJZNGxxUVUJE0RBRHdQdy4umgKJASFOUTg3RkE2PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOelV3UU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M9FMBZUFBLtgCAOACrZhI6gJcaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193b19icmFuZENhdGVnb3J5RXhjbHVzaW9uLmh0bWyAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My9wcmViaWSYBACiBA0yMDIuNTkuMjMxLjQ3qATL5gSyBBIIARACGIAFIOADKAEoAjAAOAO4BADABADIBADSBA45MzI1I1NJTjM6NDc1MNoEAggA4AQA8ATE559HiAUBmAUAoAX___________8BwAUAyQUAAAAAAADwP9IFCQkAAAAAAAAAANgFAeAFAfAFmT36BQQIABAAkAYBmAYAuAYAwQYAAAAAAADwv9AG9S_aBhYKEAAAAGmpDQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=f8458c6a48fed591c269169a9744aba11cb90285', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=ZwAAAAMArgAFAQk3yQleAAAAABExkXrWayAyJRk3yQleAAAAACDE559HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1iZPWICSU5oAXABeACAAQGIAQGQAYAFmAHgA6ABAKgBxOefR7ABAQ..&s=e2dbd082b353a37db9f632efc2532913a0c48166&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149418948, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 1, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 30000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_brandCategoryExclusion.html&e=wqT_3QL7COh7BAAAAwDWAAUBCLeSp_AFELGi6rO9jYiZJRiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQxOefR1ic8VtgAGjNunV4ybgFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5NjM5KTt1ZigncicsIDE0OTQxODk0OCwgMTUZH_D9kgK5AiFnenkzLWdpbWtfOFBFTVRubjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQnJLY0RrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBWHBXVU5Pa2otY18yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwcFBfRDdvRENWTkpUak02TkRjMU1PQUR3aGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCWTRscVFVCRNEQUR3UHcuLpoCiQEhTlE4N0ZBNj0BJG5QRmJJQVFvQUQVSFR1UURvSlUwbE9Nem8wTnpVd1FNSVlTEXgMUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDPCLZUFBLtgCAOACrZhI6gJcaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193b19icmFuZENhdGVnb3J5RXhjbHVzaW9uLmh0bWzyAhMKD0NVU1RPTV9NT0RFTF9JRBIA8gIaChZDVVNUT00NFkBMRUFGX05BTUUSAPICHgoaQzIdAAhBU1QBKPDtSUZJRUQSAIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIEDTIwMi41OS4yMzEuNDeoBMvmBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzUw2gQCCAHgBADwBMTnn0eIBQGYBQCgBf___________wHABQDJBQAAAAAAAPA_0gUJCQAAAAAAAAAA2AUB4AUB8AWZPfoFBAgAEACQBgGYBgC4BgDBBgAAAAAAAPA_0Ab1L9oGFgoQAIkDFQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=5475ac640321ae51a06b5c05ac62519e97e90114' + } + } + }] + }, { + 'uuid': '2c52d7d1f2f703', + 'tag_id': 15394006, + 'auction_id': '8439286287321689724', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_brandCategoryExclusion.html&e=wqT_3QKfCKAfBAAAAwDWAAUBCLeSp_AFEPzciY2kxZePdRiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5NjM5KTsBHTByJywgMTQ5NDE4OTQ4Nh8A8P2SArkCIU1UeWZ6d2lta184UEVNVG5uMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCcktjRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFWalR1QThjek9FXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHBwUF9EN29EQ1ZOSlRqTTZORGMxTU9BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJZNGxxUVUJE0RBRHdQdy4umgKJASFOUTg3RkE2PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOelV3UU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M9FMBZUFBLtgCAOACrZhI6gJcaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193b19icmFuZENhdGVnb3J5RXhjbHVzaW9uLmh0bWyAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My9wcmViaWSYBACiBA0yMDIuNTkuMjMxLjQ3qATL5gSyBBIIARACGIAFIOADKAEoAjAAOAO4BADABADIBADSBA45MzI1I1NJTjM6NDc1MNoEAggA4AQA8ATE559HiAUBmAUAoAX___________8BwAUAyQUAAAAAAADwP9IFCQkAAAAAAAAAANgFAeAFAfAFmT36BQQIABAAkAYBmAYAuAYAwQYAAAAAAADwv9AG9S_aBhYKEAAAAGmpDQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=73e760427d2aec3d47824994cf35c35f1eeddcf8', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=ZwAAAAMArgAFAQk3yQleAAAAABF8bqJBKl4edRk3yQleAAAAACDE559HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1iZPWICSU5oAXABeACAAQGIAQGQAYAFmAHgA6ABAKgBxOefR7ABAQ..&s=dac1e836a6f2c4dc036c50d0b3128dfefb34915d&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149418948, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 1, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 30000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_brandCategoryExclusion.html&e=wqT_3QL7COh7BAAAAwDWAAUBCLeSp_AFEPzciY2kxZePdRiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQxOefR1ic8VtgAGjNunV4ybgFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5NjM5KTt1ZigncicsIDE0OTQxODk0OCwgMTUZH_D9kgK5AiFNVHlmendpbWtfOFBFTVRubjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQnJLY0RrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBVmpUdUE4Y3pPRV8yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwcFBfRDdvRENWTkpUak02TkRjMU1PQUR3aGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCWTRscVFVCRNEQUR3UHcuLpoCiQEhTlE4N0ZBNj0BJG5QRmJJQVFvQUQVSFR1UURvSlUwbE9Nem8wTnpVd1FNSVlTEXgMUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDPCLZUFBLtgCAOACrZhI6gJcaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193b19icmFuZENhdGVnb3J5RXhjbHVzaW9uLmh0bWzyAhMKD0NVU1RPTV9NT0RFTF9JRBIA8gIaChZDVVNUT00NFkBMRUFGX05BTUUSAPICHgoaQzIdAAhBU1QBKPDtSUZJRUQSAIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIEDTIwMi41OS4yMzEuNDeoBMvmBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzUw2gQCCAHgBADwBMTnn0eIBQGYBQCgBf___________wHABQDJBQAAAAAAAPA_0gUJCQAAAAAAAAAA2AUB4AUB8AWZPfoFBAgAEACQBgGYBgC4BgDBBgAAAAAAAPA_0Ab1L9oGFgoQAIkDFQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=6c1fb35564d2ffd08fb4c5b290aadd6e1e3d83ec' + } + } + }] + }, { + 'uuid': '2c52d7d1f2f703', + 'tag_id': 15394006, + 'auction_id': '5519278898732145414', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_brandCategoryExclusion.html&e=wqT_3QKgCKAgBAAAAwDWAAUBCLeSp_AFEIa29Pmn3ZrMTBiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5NjM5KTsBHTByJywgMTQ5NDE3OTUxNh8A8P2SArkCITFEc0hwUWlta184UEVOX2ZuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCcktjRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFkQUZ3YVliRWVNXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHBwUF9EN29EQ1ZOSlRqTTZORGMxTU9BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJZNGxxUVUJE0RBRHdQdy4umgKJASFTQThFR3c2PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOelV3UU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M9FMBZUFBLtgCAOACrZhI6gJcaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193b19icmFuZENhdGVnb3J5RXhjbHVzaW9uLmh0bWyAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My9wcmViaWSYBACiBA0yMDIuNTkuMjMxLjQ3qATL5gSyBBIIARACGIAFIOADKAEoAjAAOAO4BADABADIBADSBA45MzI1I1NJTjM6NDc1MNoEAggA4AQA8ATf359HiAUBmAUAoAX___________8BwAUAyQUAAAAAAADwP9IFCQkAAAAAAAAAANgFAeAFAfAFrLwU-gUECAAQAJAGAZgGALgGAMEGAAAAAAAA8L_QBvUv2gYWChAAAGmpEQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=d01f411e7cc9126e912daca85136b2ca6f99a347', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=aAAAAAMArgAFAQk3yQleAAAAABEGGz1_6mqYTBk3yQleAAAAACDf359HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1isvBRiAklOaAFwAXgAgAEBiAEBkAGABZgB4AOgAQCoAd_fn0ewAQE.&s=81115280cee86ae0bc259627410fa5dbbc178646&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149417951, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 33, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 30000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_brandCategoryExclusion.html&e=wqT_3QL8COh8BAAAAwDWAAUBCLeSp_AFEIa29Pmn3ZrMTBiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQ39-fR1ic8VtgAGjNunV4ybgFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5NjM5KTt1ZigncicsIDE0OTQxNzk1MSwgMTUZH_D9kgK5AiExRHNIcFFpbWtfOFBFTl9mbjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQnJLY0RrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBZEFGd2FZYkVlTV8yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwcFBfRDdvRENWTkpUak02TkRjMU1PQUR3aGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCWTRscVFVCRNEQUR3UHcuLpoCiQEhU0E4RUd3Nj0BJG5QRmJJQVFvQUQVSFR1UURvSlUwbE9Nem8wTnpVd1FNSVlTEXgMUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDPCLZUFBLtgCAOACrZhI6gJcaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193b19icmFuZENhdGVnb3J5RXhjbHVzaW9uLmh0bWzyAhMKD0NVU1RPTV9NT0RFTF9JRBIA8gIaChZDVVNUT00NFkBMRUFGX05BTUUSAPICHgoaQzIdAAhBU1QBKPCQSUZJRUQSAIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIEDTIwMi41OS4yMzEuNDeoBMvmBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzUw2gQCCAHgBADwBGGQIIgFAZgFAKAF_xEBFAHABQDJBWnBFPA_0gUJCQkMeAAA2AUB4AUB8AWsvBT6BQQIABAAkAYBmAYAuAYAwQYJJSjwP9AG9S_aBhYKEAkRGQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=90f21feeb2c798cd77b3cadbc961240238825f0d' + } + } + }] + }, { + 'uuid': '2c52d7d1f2f703', + 'tag_id': 15394006, + 'auction_id': '6754624236211478320', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_brandCategoryExclusion.html&e=wqT_3QKfCKAfBAAAAwDWAAUBCLeSp_AFELC-hPXI3s_eXRiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5NjM5KTsBHTByJywgMTQ5NDE4OTQ4Nh8A8P2SArkCIVJqc0hVUWlta184UEVNVG5uMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCcktjRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFaRjJPd05MVnVvXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHBwUF9EN29EQ1ZOSlRqTTZORGMxTU9BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJZNGxxUVUJE0RBRHdQdy4umgKJASFOUTg3RkE2PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOelV3UU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M9FMBZUFBLtgCAOACrZhI6gJcaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193b19icmFuZENhdGVnb3J5RXhjbHVzaW9uLmh0bWyAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My9wcmViaWSYBACiBA0yMDIuNTkuMjMxLjQ3qATL5gSyBBIIARACGIAFIOADKAEoAjAAOAO4BADABADIBADSBA45MzI1I1NJTjM6NDc1MNoEAggA4AQA8ATE559HiAUBmAUAoAX___________8BwAUAyQUAAAAAAADwP9IFCQkAAAAAAAAAANgFAeAFAfAFmT36BQQIABAAkAYBmAYAuAYAwQYAAAAAAADwv9AG9S_aBhYKEAAAAGmpDQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=34811f7e5c917550619274f5b75a0cd214119812', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=ZwAAAAMArgAFAQk3yQleAAAAABEwH6GO9D69XRk3yQleAAAAACDE559HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1iZPWICSU5oAXABeACAAQGIAQGQAYAFmAHgA6ABAKgBxOefR7ABAQ..&s=d811faa48963b18d33c0a1f9d1e64ff97640a415&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149418948, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 1, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 30000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_brandCategoryExclusion.html&e=wqT_3QL7COh7BAAAAwDWAAUBCLeSp_AFELC-hPXI3s_eXRiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQxOefR1ic8VtgAGjNunV4ybgFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5NjM5KTt1ZigncicsIDE0OTQxODk0OCwgMTUZH_D9kgK5AiFSanNIVVFpbWtfOFBFTVRubjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQnJLY0RrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBWkYyT3dOTFZ1b18yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwcFBfRDdvRENWTkpUak02TkRjMU1PQUR3aGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCWTRscVFVCRNEQUR3UHcuLpoCiQEhTlE4N0ZBNj0BJG5QRmJJQVFvQUQVSFR1UURvSlUwbE9Nem8wTnpVd1FNSVlTEXgMUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDPCLZUFBLtgCAOACrZhI6gJcaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193b19icmFuZENhdGVnb3J5RXhjbHVzaW9uLmh0bWzyAhMKD0NVU1RPTV9NT0RFTF9JRBIA8gIaChZDVVNUT00NFkBMRUFGX05BTUUSAPICHgoaQzIdAAhBU1QBKPDtSUZJRUQSAIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIEDTIwMi41OS4yMzEuNDeoBMvmBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzUw2gQCCAHgBADwBMTnn0eIBQGYBQCgBf___________wHABQDJBQAAAAAAAPA_0gUJCQAAAAAAAAAA2AUB4AUB8AWZPfoFBAgAEACQBgGYBgC4BgDBBgAAAAAAAPA_0Ab1L9oGFgoQAIkDFQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=c0a0a2d65dd091bd2ed81f95da1a9f7ff16ad70e' + } + } + }] + }] + } + } + } +} diff --git a/test/mock-server/expectations/request-response-pairs/longform/basic_wo_brandCategoryExclusion_request_2.js b/test/mock-server/expectations/request-response-pairs/longform/basic_wo_brandCategoryExclusion_request_2.js new file mode 100644 index 00000000000..ce8bad3e9d7 --- /dev/null +++ b/test/mock-server/expectations/request-response-pairs/longform/basic_wo_brandCategoryExclusion_request_2.js @@ -0,0 +1,312 @@ +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 + * + */ + +/** + * 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': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }], + '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': '2c52d7d1f2f703', + 'tag_id': 15394006, + 'auction_id': '4631210661889362034', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_brandCategoryExclusion.html&e=wqT_3QKgCKAgBAAAAwDWAAUBCLeSp_AFEPKQq-_0sdeiQBiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5NjM5KTsBHTByJywgMTQ5NDE5NjAyNh8A8P2SArkCIXF6eU1HUWlua184UEVOTHNuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCcktjRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFVQk5fYTFxbHU0XzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHA1UF9EN29EQ1ZOSlRqTTZORGMwTS1BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJZY2xxUVUJE0RBRHdQdy4umgKJASFTd19PR3c2PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOelF6UU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M9FMBZUFBLtgCAOACrZhI6gJcaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193b19icmFuZENhdGVnb3J5RXhjbHVzaW9uLmh0bWyAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My9wcmViaWSYBACiBA0yMDIuNTkuMjMxLjQ3qATL5gSyBBIIARACGIAFIOADKAEoAjAAOAO4BADABADIBADSBA45MzI1I1NJTjM6NDc0M9oEAggA4AQA8ATS7J9HiAUBmAUAoAX___________8BwAUAyQUAAAAAAADwP9IFCQkAAAAAAAAAANgFAeAFAfAF2boG-gUECAAQAJAGAZgGALgGAMEGAAAAAAAA8L_QBvUv2gYWChAAAGmpEQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=0dae5294ed5bb48b7d3a156e5e587a26da27c7e1', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=aAAAAAMArgAFAQk3yQleAAAAABFyyOpNj11FQBk3yQleAAAAACDS7J9HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1jZugZiAklOaAFwAXgAgAEBiAEBkAGABZgB4AOgAQCoAdLsn0ewAQE.&s=9085e4dbb4849b0e6d3714d84a2754bbab578e16&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149419602, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 24, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 15000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_brandCategoryExclusion.html&e=wqT_3QL8COh8BAAAAwDWAAUBCLeSp_AFEPKQq-_0sdeiQBiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQ0uyfR1ic8VtgAGjNunV4z7gFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5NjM5KTt1ZigncicsIDE0OTQxOTYwMiwgMTUZH_D9kgK5AiFxenlNR1FpbmtfOFBFTkxzbjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQnJLY0RrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBVUJOX2ExcWx1NF8yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwNVBfRDdvRENWTkpUak02TkRjME0tQUR3aGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCWWNscVFVCRNEQUR3UHcuLpoCiQEhU3dfT0d3Nj0BJG5QRmJJQVFvQUQVSFR1UURvSlUwbE9Nem8wTnpRelFNSVlTEXgMUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDPCLZUFBLtgCAOACrZhI6gJcaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193b19icmFuZENhdGVnb3J5RXhjbHVzaW9uLmh0bWzyAhMKD0NVU1RPTV9NT0RFTF9JRBIA8gIaChZDVVNUT00NFkBMRUFGX05BTUUSAPICHgoaQzIdAAhBU1QBKPCQSUZJRUQSAIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIEDTIwMi41OS4yMzEuNDeoBMvmBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzQz2gQCCAHgBADwBGGQIIgFAZgFAKAF_xEBFAHABQDJBWnBFPA_0gUJCQkMeAAA2AUB4AUB8AXZugb6BQQIABAAkAYBmAYAuAYAwQYJJSjwP9AG9S_aBhYKEAkRGQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=aa5533d04e16ee398f8028ab3af03a48d7d8cc17' + } + } + }] + }, { + 'uuid': '2c52d7d1f2f703', + 'tag_id': 15394006, + 'auction_id': '714778825826946473', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_brandCategoryExclusion.html&e=wqT_3QKgCKAgBAAAAwDWAAUBCLeSp_AFEKmbi7Ph8dn1CRiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5NjM5KTsBHTByJywgMTQ5NDE4MTIzNh8A8P2SArkCIU56dmJOZ2lua184UEVJdmhuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCcktjRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFRbjlXUzRmY09jXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHA1UF9EN29EQ1ZOSlRqTTZORGMwTS1BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJZY2xxUVUJE0BBRHdQdy4umgKJASEtUTZrXzo9ASRuUEZiSUFRb0FEFUhUdVFEb0pVMGxPTXpvME56UXpRTUlZUxF4DFBBX1URDAxBQUFXHQwAWR0MAGEdDABjHQz0UwFlQUEu2AIA4AKtmEjqAlxodHRwOi8vdGVzdC5sb2NhbGhvc3Q6OTk5OS9pbnRlZ3JhdGlvbkV4YW1wbGVzL2xvbmdmb3JtL2Jhc2ljX3dvX2JyYW5kQ2F0ZWdvcnlFeGNsdXNpb24uaHRtbIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIEDTIwMi41OS4yMzEuNDeoBMvmBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzQz2gQCCADgBADwBIvhn0eIBQGYBQCgBf___________wHABQDJBQAAAAAAAPA_0gUJCQAAAAAAAAAA2AUB4AUB8AXa1gL6BQQIABAAkAYBmAYAuAYAwQYAAAAAAADwv9AG9S_aBhYKEAAAaakRAVAQABgA4AYE8gYCCACABwGIBwCgB0A.&s=8917b1722eed5b6d85c6d5a01eea7862089bee32', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=aAAAAAMArgAFAQk3yQleAAAAABGpzWIWjmfrCRk3yQleAAAAACCL4Z9HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1ja1gJiAklOaAFwAXgAgAEBiAEBkAGABZgB4AOgAQCoAYvhn0ewAQE.&s=9ec7e7de16b948b60d74b47f1917faf5d3b6dbf0&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149418123, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 12, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 15000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_brandCategoryExclusion.html&e=wqT_3QL8COh8BAAAAwDWAAUBCLeSp_AFEKmbi7Ph8dn1CRiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQi-GfR1ic8VtgAGjNunV4z7gFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5NjM5KTt1ZigncicsIDE0OTQxODEyMywgMTUZH_D9kgK5AiFOenZiTmdpbmtfOFBFSXZobjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQnJLY0RrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBUW45V1M0ZmNPY18yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwNVBfRDdvRENWTkpUak02TkRjME0tQUR3aGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCWWNscVFVCRNAQUR3UHcuLpoCiQEhLVE2a186PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOelF6UU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M8ItlQUEu2AIA4AKtmEjqAlxodHRwOi8vdGVzdC5sb2NhbGhvc3Q6OTk5OS9pbnRlZ3JhdGlvbkV4YW1wbGVzL2xvbmdmb3JtL2Jhc2ljX3dvX2JyYW5kQ2F0ZWdvcnlFeGNsdXNpb24uaHRtbPICEwoPQ1VTVE9NX01PREVMX0lEEgDyAhoKFkNVU1RPTQ0WQExFQUZfTkFNRRIA8gIeChpDMh0ACEFTVAEo8N5JRklFRBIAgAMAiAMBkAMAmAMXoAMBqgMAwAPgqAHIAwDYAwDgAwDoAwD4AwGABACSBA0vdXQvdjMvcHJlYmlkmAQAogQNMjAyLjU5LjIzMS40N6gEy-YEsgQSCAEQAhiABSDgAygBKAIwADgDuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ3NDPaBAIIAeAEAPAEi-GfR4gFAZgFAKAF____________AcAFAMkFAAAAAAAA8D_SBQkJAAAAAAAAAADYBQHgBQHwBdrWAvoFBAgAEACQBgGYBgC4BgDBBgAAYfQo8D_QBvUv2gYWChABDy4BAFAQABgA4AYE8gYCCACABwGIBwCgB0A.&s=8198652a5ee16abf4595ab1bfc6b051f81f0579d' + } + } + }] + }, { + 'uuid': '2c52d7d1f2f703', + 'tag_id': 15394006, + 'auction_id': '231404788116786844', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_brandCategoryExclusion.html&e=wqT_3QKgCKAgBAAAAwDWAAUBCLeSp_AFEJydmpjcrYebAxiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5NjM5KTsBHTByJywgMTQ5NDE5NjAyNh8A8P2SArkCIUVqMFlVZ2lua184UEVOTHNuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCcktjRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFhLXFPTExmZ2VrXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHA1UF9EN29EQ1ZOSlRqTTZORGMwTS1BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJZY2xxUVUJE0RBRHdQdy4umgKJASFTd19PR3c2PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOelF6UU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M9FMBZUFBLtgCAOACrZhI6gJcaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193b19icmFuZENhdGVnb3J5RXhjbHVzaW9uLmh0bWyAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My9wcmViaWSYBACiBA0yMDIuNTkuMjMxLjQ3qATL5gSyBBIIARACGIAFIOADKAEoAjAAOAO4BADABADIBADSBA45MzI1I1NJTjM6NDc0M9oEAggA4AQA8ATS7J9HiAUBmAUAoAX___________8BwAUAyQUAAAAAAADwP9IFCQkAAAAAAAAAANgFAeAFAfAF2boG-gUECAAQAJAGAZgGALgGAMEGAAAAAAAA8L_QBvUv2gYWChAAAGmpEQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=775dfc49086467337dee9a5e8d78b361931c6aaa', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=aAAAAAMArgAFAQk3yQleAAAAABGcjgbDbR02Axk3yQleAAAAACDS7J9HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1jZugZiAklOaAFwAXgAgAEBiAEBkAGABZgB4AOgAQCoAdLsn0ewAQE.&s=914256a92514df787ccb1eae7dea7578d23c8fba&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149419602, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 24, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 15000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_brandCategoryExclusion.html&e=wqT_3QL8COh8BAAAAwDWAAUBCLeSp_AFEJydmpjcrYebAxiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQ0uyfR1ic8VtgAGjNunV4z7gFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5NjM5KTt1ZigncicsIDE0OTQxOTYwMiwgMTUZH_D9kgK5AiFFajBZVWdpbmtfOFBFTkxzbjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQnJLY0RrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBYS1xT0xMZmdla18yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwNVBfRDdvRENWTkpUak02TkRjME0tQUR3aGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCWWNscVFVCRNEQUR3UHcuLpoCiQEhU3dfT0d3Nj0BJG5QRmJJQVFvQUQVSFR1UURvSlUwbE9Nem8wTnpRelFNSVlTEXgMUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDPCLZUFBLtgCAOACrZhI6gJcaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193b19icmFuZENhdGVnb3J5RXhjbHVzaW9uLmh0bWzyAhMKD0NVU1RPTV9NT0RFTF9JRBIA8gIaChZDVVNUT00NFkBMRUFGX05BTUUSAPICHgoaQzIdAAhBU1QBKPCQSUZJRUQSAIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIEDTIwMi41OS4yMzEuNDeoBMvmBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzQz2gQCCAHgBADwBGGQIIgFAZgFAKAF_xEBFAHABQDJBWnBFPA_0gUJCQkMeAAA2AUB4AUB8AXZugb6BQQIABAAkAYBmAYAuAYAwQYJJSjwP9AG9S_aBhYKEAkRGQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=f624619431372f9a248d0fa0dd8d09c4977bb544' + } + } + }] + }, { + 'uuid': '2c52d7d1f2f703', + 'tag_id': 15394006, + 'auction_id': '7557072342526904599', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_brandCategoryExclusion.html&e=wqT_3QKfCKAfBAAAAwDWAAUBCLeSp_AFEJeS-7GaqIfwaBiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5NjM5KTsBHTByJywgMTQ5NDE4NjcxNh8A8P2SArkCIUFqdmVKQWlta184UEVLX2xuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCcktjRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFSY2lLblVqeU9VXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHBwUF9EN29EQ1ZOSlRqTTZORGMwTS1BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJZY2xxUVUJE0BBRHdQdy4umgKJASFJQS1IRDo9ASRuUEZiSUFRb0FEFUhUdVFEb0pVMGxPTXpvME56UXpRTUlZUxF4DFBBX1URDAxBQUFXHQwAWR0MAGEdDABjHQz0dQFlQUEu2AIA4AKtmEjqAlxodHRwOi8vdGVzdC5sb2NhbGhvc3Q6OTk5OS9pbnRlZ3JhdGlvbkV4YW1wbGVzL2xvbmdmb3JtL2Jhc2ljX3dvX2JyYW5kQ2F0ZWdvcnlFeGNsdXNpb24uaHRtbIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIEDTIwMi41OS4yMzEuNDeoBMvmBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzQz2gQCCADgBADwBK_ln0eIBQGYBQCgBf___________wHABQDJBQAAAAAAAPA_0gUJCQAAAAAAAAAA2AUB4AUB8AXgWPoFBAgAEACQBgGYBgC4BgDBBgAAAAAAAPC_0Ab1L9oGFgoQAAAAAAAAAAAAAAAAAAAAABAAGADgBgTyBgIIAIAHAYgHAKAHQA..&s=552663ed1246fd2a3cc5824164f57d32f18078ee', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=ZwAAAAMArgAFAQk3yQleAAAAABEXyT6mQR3gaBk3yQleAAAAACCv5Z9HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1jgWGICSU5oAXABeACAAQGIAQGQAYAFmAHgA6ABAKgBr-WfR7ABAQ..&s=e1c80e622aa60bf7683413f4371b0055d0d16f47&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149418671, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 30, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 30000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_brandCategoryExclusion.html&e=wqT_3QL7COh7BAAAAwDWAAUBCLeSp_AFEJeS-7GaqIfwaBiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQr-WfR1ic8VtgAGjNunV4z7gFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5NjM5KTt1ZigncicsIDE0OTQxODY3MSwgMTUZH_D9kgK5AiFBanZlSkFpbWtfOFBFS19sbjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQnJLY0RrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBUmNpS25VanlPVV8yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwcFBfRDdvRENWTkpUak02TkRjME0tQUR3aGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCWWNscVFVCRNAQUR3UHcuLpoCiQEhSUEtSEQ6PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOelF6UU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M8ItlQUEu2AIA4AKtmEjqAlxodHRwOi8vdGVzdC5sb2NhbGhvc3Q6OTk5OS9pbnRlZ3JhdGlvbkV4YW1wbGVzL2xvbmdmb3JtL2Jhc2ljX3dvX2JyYW5kQ2F0ZWdvcnlFeGNsdXNpb24uaHRtbPICEwoPQ1VTVE9NX01PREVMX0lEEgDyAhoKFkNVU1RPTQ0WQExFQUZfTkFNRRIA8gIeChpDMh0ACEFTVAEo8JBJRklFRBIAgAMAiAMBkAMAmAMXoAMBqgMAwAPgqAHIAwDYAwDgAwDoAwD4AwGABACSBA0vdXQvdjMvcHJlYmlkmAQAogQNMjAyLjU5LjIzMS40N6gEy-YEsgQSCAEQAhiABSDgAygBKAIwADgDuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ3NDPaBAIIAeAEAPAEYZAgiAUBmAUAoAX_EQEYAcAFAMkFAAUBFPA_0gUJCQULeAAAANgFAeAFAfAF4Fj6BQQIABAAkAYBmAYAuAYAwQYBIDAAAPA_0Ab1L9oGFgoQCREZAVAQABgA4AYE8gYCCACABwGIBwCgB0A.&s=ccf266d1b02551a2ad0af0871d4af43e4aee4bba' + } + } + }] + }, { + 'uuid': '2c52d7d1f2f703', + 'tag_id': 15394006, + 'auction_id': '5093465143102876632', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_brandCategoryExclusion.html&e=wqT_3QKgCKAgBAAAAwDWAAUBCLeSp_AFENjX7JP78efXRhiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5NjM5KTsBHTByJywgMTQ5NDE4MTIzNh8A8P2SArkCIUJUeXRwUWlua184UEVJdmhuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCcktjRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFYamVBMVdNcXUwXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHA1UF9EN29EQ1ZOSlRqTTZORGMwTS1BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJZY2xxUVUJE0RBRHdQdy4umgKJASEtUTZrX2c2PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOelF6UU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M9FMBZUFBLtgCAOACrZhI6gJcaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193b19icmFuZENhdGVnb3J5RXhjbHVzaW9uLmh0bWyAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My9wcmViaWSYBACiBA0yMDIuNTkuMjMxLjQ3qATL5gSyBBIIARACGIAFIOADKAEoAjAAOAO4BADABADIBADSBA45MzI1I1NJTjM6NDc0M9oEAggA4AQA8ASL4Z9HiAUBmAUAoAX___________8BwAUAyQUAAAAAAADwP9IFCQkAAAAAAAAAANgFAeAFAfAF2tYC-gUECAAQAJAGAZgGALgGAMEGAAAAAAAA8L_QBvUv2gYWChAAAGmpEQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=6651c1436b699842aabb3ae53d96d07caf5b4938', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=aAAAAAMArgAFAQk3yQleAAAAABHYK3uyj5-vRhk3yQleAAAAACCL4Z9HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1ja1gJiAklOaAFwAXgAgAEBiAEBkAGABZgB4AOgAQCoAYvhn0ewAQE.&s=f62098bf5037b22ca4e5583289a1527fdfa87e43&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149418123, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 12, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 15000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_brandCategoryExclusion.html&e=wqT_3QL8COh8BAAAAwDWAAUBCLeSp_AFENjX7JP78efXRhiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQi-GfR1ic8VtgAGjNunV4z7gFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk5NjM5KTt1ZigncicsIDE0OTQxODEyMywgMTUZH_D9kgK5AiFCVHl0cFFpbmtfOFBFSXZobjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQnJLY0RrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBWGplQTFXTXF1MF8yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwNVBfRDdvRENWTkpUak02TkRjME0tQUR3aGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCWWNscVFVCRNEQUR3UHcuLpoCiQEhLVE2a19nNj0BJG5QRmJJQVFvQUQVSFR1UURvSlUwbE9Nem8wTnpRelFNSVlTEXgMUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDPCLZUFBLtgCAOACrZhI6gJcaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193b19icmFuZENhdGVnb3J5RXhjbHVzaW9uLmh0bWzyAhMKD0NVU1RPTV9NT0RFTF9JRBIA8gIaChZDVVNUT00NFkBMRUFGX05BTUUSAPICHgoaQzIdAAhBU1QBKPDeSUZJRUQSAIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIEDTIwMi41OS4yMzEuNDeoBMvmBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzQz2gQCCAHgBADwBIvhn0eIBQGYBQCgBf___________wHABQDJBQAAAAAAAPA_0gUJCQAAAAAAAAAA2AUB4AUB8AXa1gL6BQQIABAAkAYBmAYAuAYAwQYAAGH0KPA_0Ab1L9oGFgoQAQ8uAQBQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=4b43aaab766ee7d2e4c900ec32cb3c8b7ccef1d0' + } + } + }] + }] + } + } + } +} diff --git a/test/mock-server/expectations/request-response-pairs/longform/basic_wo_requireExactDuration_request_1.js b/test/mock-server/expectations/request-response-pairs/longform/basic_wo_requireExactDuration_request_1.js new file mode 100644 index 00000000000..fc2ad82fe5f --- /dev/null +++ b/test/mock-server/expectations/request-response-pairs/longform/basic_wo_requireExactDuration_request_1.js @@ -0,0 +1,620 @@ +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 + * + */ + +/** + * 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': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }], + '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': '2022b6b1fcf477', + 'tag_id': 15394006, + 'auction_id': '8905202273088829598', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_requireExactDuration.html&e=wqT_3QKdCKAdBAAAAwDWAAUBCLWXp_AFEJ7x1-ORyejKexiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3NzAwMjc3KTsBHTByJywgMTQ5NDE4OTQ4Nh8A8P2SArkCIWlEeE84Z2lta184UEVNVG5uMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCd3FjRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFhV09TRWpDY09NXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHBwUF9EN29EQ1ZOSlRqTTZORGMzTi1BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJha2xxUVUJE0BBRHdQdy4umgKJASFQZzlaRjo9ASRuUEZiSUFRb0FEFUhUdVFEb0pVMGxPTXpvME56YzNRTUlZUxF4DFBBX1URDAxBQUFXHQwAWR0MAGEdDABjHQz0DgFlQUEu2AIA4AKtmEjqAlpodHRwOi8vdGVzdC5sb2NhbGhvc3Q6OTk5OS9pbnRlZ3JhdGlvbkV4YW1wbGVzL2xvbmdmb3JtL2Jhc2ljX3dvX3JlcXVpcmVFeGFjdER1cmF0aW9uLmh0bWyAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My9wcmViaWSYBACiBA0yMDIuNTkuMjMxLjQ3qATV5gSyBBIIARACGIAFIOADKAEoAjAAOAO4BADABADIBADSBA45MzI1I1NJTjM6NDc3N9oEAggA4AQA8ATE559HiAUBmAUAoAX___________8BwAUAyQUAZWQU8D_SBQkJBQt4AAAA2AUB4AUB8AWZPfoFBAgAEACQBgGYBgC4BgDBBgEgMAAA8L_QBvUv2gYWChAJERkBUBAAGADgBgTyBgIIAIAHAYgHAKAHQA..&s=21195aa3e27f8eb88ba43d5da32e6b78c2aa03f8', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=ZwAAAAMArgAFAQm1ywleAAAAABGe-HUcSaKVexm1ywleAAAAACDE559HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1iZPWICSU5oAXABeACAAQGIAQGQAYAFmAHgA6ABAKgBxOefR7ABAQ..&s=3c05b8509dd5c7c4459886f4c69fdd9cd07caa66&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149418948, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 1, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 30000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_requireExactDuration.html&e=wqT_3QL5COh5BAAAAwDWAAUBCLWXp_AFEJ7x1-ORyejKexiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQxOefR1ic8VtgAGjNunV41rgFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3NzAwMjc3KTt1ZigncicsIDE0OTQxODk0OCwgMTUZH_D9kgK5AiFpRHhPOGdpbWtfOFBFTVRubjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQndxY0RrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBYVdPU0VqQ2NPTV8yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwcFBfRDdvRENWTkpUak02TkRjM04tQUR3aGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCYWtscVFVCRNAQUR3UHcuLpoCiQEhUGc5WkY6PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOemMzUU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M8ItlQUEu2AIA4AKtmEjqAlpodHRwOi8vdGVzdC5sb2NhbGhvc3Q6OTk5OS9pbnRlZ3JhdGlvbkV4YW1wbGVzL2xvbmdmb3JtL2Jhc2ljX3dvX3JlcXVpcmVFeGFjdER1cmF0aW9uLmh0bWzyAhMKD0NVU1RPTV9NT0RFTF9JRBIA8gIaChZDVVNUT01fTQUWPExFQUZfTkFNRRIA8gIeChoyMwDwwkxBU1RfTU9ESUZJRUQSAIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIEDTIwMi41OS4yMzEuNDeoBNXmBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0Nzc32gQCCAHgBADwBMTnn0eIBQGYBQCgBf___________wHABQDJBQAAAAAAAPA_0gUJCQAAAGXObNgFAeAFAfAFmT36BQQIABAAkAYBmAYAuAYAwQYFISwA8D_QBvUv2gYWChAJERkBUBAAGADgBgTyBgIIAIAHAYgHAKAHQA..&s=203ae79160a460b18f20165e5de53bb1f45e4933' + } + } + }] + }, { + 'uuid': '2022b6b1fcf477', + 'tag_id': 15394006, + 'auction_id': '2428831247136753876', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_requireExactDuration.html&e=wqT_3QKeCKAeBAAAAwDWAAUBCLWXp_AFENSR0sfppLzaIRiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3NzAwMjc3KTsBHTByJywgMTQ5NDE3OTUxNh8A8P2SArkCIXRUeV9FQWlta184UEVOX2ZuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCd3FjRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFTek5nNXJvQi0wXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHBwUF9EN29EQ1ZOSlRqTTZORGMzTi1BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJha2xxUVUJE0RBRHdQdy4umgKJASFVUThpSFE2PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOemMzUU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M9A4BZUFBLtgCAOACrZhI6gJaaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193b19yZXF1aXJlRXhhY3REdXJhdGlvbi5odG1sgAMAiAMBkAMAmAMXoAMBqgMAwAPgqAHIAwDYAwDgAwDoAwD4AwGABACSBA0vdXQvdjMvcHJlYmlkmAQAogQNMjAyLjU5LjIzMS40N6gE1eYEsgQSCAEQAhiABSDgAygBKAIwADgDuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ3NzfaBAIIAOAEAPAE39-fR4gFAZgFAKAF____________AcAFAMkFAGVkFPA_0gUJCQULfAAAANgFAeAFAfAFrLwU-gUECAAQAJAGAZgGALgGAMEGASEwAADwv9AG9S_aBhYKEAkRGQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=af2d5096aa4f934e84b59ad16cd18dfe5b9bbc77', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=aAAAAAMArgAFAQm1ywleAAAAABHUiPSYJvG0IRm1ywleAAAAACDf359HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1isvBRiAklOaAFwAXgAgAEBiAEBkAGABZgB4AOgAQCoAd_fn0ewAQE.&s=440a389c7f556dac70c650bb1e593a10cbcdf2af&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149417951, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 33, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 30000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_requireExactDuration.html&e=wqT_3QL6COh6BAAAAwDWAAUBCLWXp_AFENSR0sfppLzaIRiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQ39-fR1ic8VtgAGjNunV41rgFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3NzAwMjc3KTt1ZigncicsIDE0OTQxNzk1MSwgMTUZH_D9kgK5AiF0VHlfRUFpbWtfOFBFTl9mbjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQndxY0RrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBU3pOZzVyb0ItMF8yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwcFBfRDdvRENWTkpUak02TkRjM04tQUR3aGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCYWtscVFVCRNEQUR3UHcuLpoCiQEhVVE4aUhRNj0BJG5QRmJJQVFvQUQVSFR1UURvSlUwbE9Nem8wTnpjM1FNSVlTEXgMUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDPCLZUFBLtgCAOACrZhI6gJaaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193b19yZXF1aXJlRXhhY3REdXJhdGlvbi5odG1s8gITCg9DVVNUT01fTU9ERUxfSUQSAPICGgoWQ1VTVE9NX00FFjxMRUFGX05BTUUSAPICHgoaMjMA8MJMQVNUX01PRElGSUVEEgCAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My9wcmViaWSYBACiBA0yMDIuNTkuMjMxLjQ3qATV5gSyBBIIARACGIAFIOADKAEoAjAAOAO4BADABADIBADSBA45MzI1I1NJTjM6NDc3N9oEAggB4AQA8ATf359HiAUBmAUAoAX___________8BwAUAyQUAAAAAAADwP9IFCQkAAABlznDYBQHgBQHwBay8FPoFBAgAEACQBgGYBgC4BgDBBgUiLADwP9AG9S_aBhYKEAkRGQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=9b00ed17c420f328d63b72519d2d578c5921d0d7' + } + } + }] + }, { + 'uuid': '2022b6b1fcf477', + 'tag_id': 15394006, + 'auction_id': '1625697369389546128', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_requireExactDuration.html&e=wqT_3QKeCKAeBAAAAwDWAAUBCLWXp_AFEJD1gLbO5OjHFhiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3NzAwMjc3KTsBHTByJywgMTQ5NDE4MTIzNh8A8P2SArkCIXVqeHMtUWlua184UEVJdmhuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCd3FjRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFhcDVwSkxuSXVVXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHA1UF9EN29EQ1ZOSlRqTTZORGMzTi1BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJha2xxUVUJE0RBRHdQdy4umgKJASFBQTlhQUE2PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOemMzUU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M9A4BZUFBLtgCAOACrZhI6gJaaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193b19yZXF1aXJlRXhhY3REdXJhdGlvbi5odG1sgAMAiAMBkAMAmAMXoAMBqgMAwAPgqAHIAwDYAwDgAwDoAwD4AwGABACSBA0vdXQvdjMvcHJlYmlkmAQAogQNMjAyLjU5LjIzMS40N6gE1eYEsgQSCAEQAhiABSDgAygBKAIwADgDuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ3NzfaBAIIAOAEAPAEi-GfR4gFAZgFAKAF____________AcAFAMkFAGVkFPA_0gUJCQULfAAAANgFAeAFAfAF2tYC-gUECAAQAJAGAZgGALgGAMEGASEwAADwv9AG9S_aBhYKEAkRGQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=0e70f535a95c82238d685147f41e0bd2f86631c0', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=aAAAAAMArgAFAQm1ywleAAAAABGQOsDmJKOPFhm1ywleAAAAACCL4Z9HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1ja1gJiAklOaAFwAXgAgAEBiAEBkAGABZgB4AOgAQCoAYvhn0ewAQE.&s=144214d77cc4ced0893c9fe64132ad01c429c43c&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149418123, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 12, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 15000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_requireExactDuration.html&e=wqT_3QL6COh6BAAAAwDWAAUBCLWXp_AFEJD1gLbO5OjHFhiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQi-GfR1ic8VtgAGjNunV41rgFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3NzAwMjc3KTt1ZigncicsIDE0OTQxODEyMywgMTUZH_D9kgK5AiF1anhzLVFpbmtfOFBFSXZobjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQndxY0RrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBYXA1cEpMbkl1VV8yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwNVBfRDdvRENWTkpUak02TkRjM04tQUR3aGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCYWtscVFVCRNEQUR3UHcuLpoCiQEhQUE5YUFBNj0BJG5QRmJJQVFvQUQVSFR1UURvSlUwbE9Nem8wTnpjM1FNSVlTEXgMUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDPCLZUFBLtgCAOACrZhI6gJaaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193b19yZXF1aXJlRXhhY3REdXJhdGlvbi5odG1s8gITCg9DVVNUT01fTU9ERUxfSUQSAPICGgoWQ1VTVE9NX00FFjxMRUFGX05BTUUSAPICHgoaMjMA8MJMQVNUX01PRElGSUVEEgCAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My9wcmViaWSYBACiBA0yMDIuNTkuMjMxLjQ3qATV5gSyBBIIARACGIAFIOADKAEoAjAAOAO4BADABADIBADSBA45MzI1I1NJTjM6NDc3N9oEAggB4AQA8ASL4Z9HiAUBmAUAoAX___________8BwAUAyQUAAAAAAADwP9IFCQkAAABlznDYBQHgBQHwBdrWAvoFBAgAEACQBgGYBgC4BgDBBgUiLADwP9AG9S_aBhYKEAkRGQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=f6bc475b66c167036dcb9f10c7c5f176124829a6' + } + } + }] + }, { + 'uuid': '2022b6b1fcf477', + 'tag_id': 15394006, + 'auction_id': '5434800203981031918', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_requireExactDuration.html&e=wqT_3QKdCKAdBAAAAwDWAAUBCLWXp_AFEO6TivzZv5K2Sxiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3NzAwMjc3KTsBHTByJywgMTQ5NDE4NjcxNh8A8P2SArkCIW5Ud3I5QWlta184UEVLX2xuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCd3FjRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFXVVcwV1Y1LU9JXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHBwUF9EN29EQ1ZOSlRqTTZORGMzTi1BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJha2xxUVUJE0RBRHdQdy4umgKJASFKdzh1RGc2PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOemMzUU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M9A4BZUFBLtgCAOACrZhI6gJaaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193b19yZXF1aXJlRXhhY3REdXJhdGlvbi5odG1sgAMAiAMBkAMAmAMXoAMBqgMAwAPgqAHIAwDYAwDgAwDoAwD4AwGABACSBA0vdXQvdjMvcHJlYmlkmAQAogQNMjAyLjU5LjIzMS40N6gE1eYEsgQSCAEQAhiABSDgAygBKAIwADgDuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ3NzfaBAIIAOAEAPAEr-WfR4gFAZgFAKAF____________AcAFAMkFAGVkFPA_0gUJCQULeAAAANgFAeAFAfAF4Fj6BQQIABAAkAYBmAYAuAYAwQYBIDAAAPC_0Ab1L9oGFgoQCREZAVAQABgA4AYE8gYCCACABwGIBwCgB0A.&s=c3ba85f0eb0293896e02066385f82b4450af2cfb', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=ZwAAAAMArgAFAQm1ywleAAAAABHuiYKf_UlsSxm1ywleAAAAACCv5Z9HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1jgWGICSU5oAXABeACAAQGIAQGQAYAFmAHgA6ABAKgBr-WfR7ABAQ..&s=9eb2d880fa9b524a6a0807eef0c65b7b1393f48a&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149418671, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 30, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 30000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_requireExactDuration.html&e=wqT_3QL5COh5BAAAAwDWAAUBCLWXp_AFEO6TivzZv5K2Sxiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQr-WfR1ic8VtgAGjNunV41rgFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3NzAwMjc3KTt1ZigncicsIDE0OTQxODY3MSwgMTUZH_D9kgK5AiFuVHdyOUFpbWtfOFBFS19sbjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQndxY0RrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBV1VXMFdWNS1PSV8yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwcFBfRDdvRENWTkpUak02TkRjM04tQUR3aGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCYWtscVFVCRNEQUR3UHcuLpoCiQEhSnc4dURnNj0BJG5QRmJJQVFvQUQVSFR1UURvSlUwbE9Nem8wTnpjM1FNSVlTEXgMUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDPCLZUFBLtgCAOACrZhI6gJaaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193b19yZXF1aXJlRXhhY3REdXJhdGlvbi5odG1s8gITCg9DVVNUT01fTU9ERUxfSUQSAPICGgoWQ1VTVE9NX00FFjxMRUFGX05BTUUSAPICHgoaMjMA8MJMQVNUX01PRElGSUVEEgCAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My9wcmViaWSYBACiBA0yMDIuNTkuMjMxLjQ3qATV5gSyBBIIARACGIAFIOADKAEoAjAAOAO4BADABADIBADSBA45MzI1I1NJTjM6NDc3N9oEAggB4AQA8ASv5Z9HiAUBmAUAoAX___________8BwAUAyQUAAAAAAADwP9IFCQkAAABlzmzYBQHgBQHwBeBY-gUECAAQAJAGAZgGALgGAMEGBSEsAPA_0Ab1L9oGFgoQCREZAVAQABgA4AYE8gYCCACABwGIBwCgB0A.&s=17038c2671b58d2fd6ea98dd3f3e1166ee664dd0' + } + } + }] + }, { + 'uuid': '2022b6b1fcf477', + 'tag_id': 15394006, + 'auction_id': '8071104954749355970', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_requireExactDuration.html&e=wqT_3QKeCKAeBAAAAwDWAAUBCLWXp_AFEMKP7OWZ5pSBcBiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3NzAwMjc3KTsBHTByJywgMTQ5NDE5NjAyNh8A8P2SArkCIXBUeEJEQWlsa184UEVOTHNuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCd3FjRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIenJXcWtBQUFrUU1FQjg2MXFwQUFBSkVESkFRbWtta1pXNGVZXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHBaUF9EN29EQ1ZOSlRqTTZORGMzTi1BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJha2xxUVUJE0RBRHdQdy4umgKJASFSZ19sR1E2PQEkblBGYklBUW9BRBVIVGtRRG9KVTBsT016bzBOemMzUU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M9A4BZUFBLtgCAOACrZhI6gJaaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193b19yZXF1aXJlRXhhY3REdXJhdGlvbi5odG1sgAMAiAMBkAMAmAMXoAMBqgMAwAPgqAHIAwDYAwDgAwDoAwD4AwGABACSBA0vdXQvdjMvcHJlYmlkmAQAogQNMjAyLjU5LjIzMS40N6gE1eYEsgQSCAEQAhiABSDgAygBKAIwADgDuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ3NzfaBAIIAOAEAPAE0uyfR4gFAZgFAKAF____________AcAFAMkFAGVkFPA_0gUJCQULfAAAANgFAeAFAfAF2boG-gUECAAQAJAGAZgGALgGAMEGASEwAADwv9AG9S_aBhYKEAkRGQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=005579c0ff91586a887354409f637a63a1d69031', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=aAAAAAMArgAFAQm1ywleAAAAABHCB7ucMVMCcBm1ywleAAAAACDS7J9HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1jZugZiAklOaAFwAXgAgAEBiAEBkAGABZgB4AOgAQCoAdLsn0ewAQE.&s=edbfae73be0f41d672298d5c3ec9dd28a5307233&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149419602, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 10.000000, + 'cpm_publisher_currency': 10.000000, + 'publisher_currency_code': '$', + 'brand_category_id': 24, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 15000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_requireExactDuration.html&e=wqT_3QL6CKB6BAAAAwDWAAUBCLWXp_AFEMKP7OWZ5pSBcBiq5MnUovf28WEqNgkAAAECCCRAEQEHEAAAJEAZCQkI4D8hCQkIJEApEQkAMQkJsOA_MNbJqwc47UhA7UhIAlDS7J9HWJzxW2AAaM26dXjWuAWAAQGKAQNVU0SSAQEG8FWYAQGgAQGoAQGwAQC4AQPAAQTIAQLQAQDYAQDgAQDwAQCKAjx1ZignYScsIDI1Mjk4ODUsIDE1Nzc3MDAyNzcpO3VmKCdyJywgMTQ5NDE5NjAyLCAxNRkf8P2SArkCIXBUeEJEQWlsa184UEVOTHNuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCd3FjRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIenJXcWtBQUFrUU1FQjg2MXFwQUFBSkVESkFRbWtta1pXNGVZXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHBaUF9EN29EQ1ZOSlRqTTZORGMzTi1BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJha2xxUVUJE0RBRHdQdy4umgKJASFSZ19sR1E2PQEkblBGYklBUW9BRBVIVGtRRG9KVTBsT016bzBOemMzUU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M8ItlQUEu2AIA4AKtmEjqAlpodHRwOi8vdGVzdC5sb2NhbGhvc3Q6OTk5OS9pbnRlZ3JhdGlvbkV4YW1wbGVzL2xvbmdmb3JtL2Jhc2ljX3dvX3JlcXVpcmVFeGFjdER1cmF0aW9uLmh0bWzyAhMKD0NVU1RPTV9NT0RFTF9JRBIA8gIaChZDVVNUT01fTQUWPExFQUZfTkFNRRIA8gIeChoyMwDwwkxBU1RfTU9ESUZJRUQSAIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIEDTIwMi41OS4yMzEuNDeoBNXmBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0Nzc32gQCCAHgBADwBNLsn0eIBQGYBQCgBf___________wHABQDJBQAAAAAAAPA_0gUJCQAAAGXOcNgFAeAFAfAF2boG-gUECAAQAJAGAZgGALgGAMEGBSIsAPA_0Ab1L9oGFgoQCREZAVAQABgA4AYE8gYCCACABwGIBwCgB0A.&s=0ac18b64a6c0d58a114085d8b565b4c98de56448' + } + } + }] + }, { + 'uuid': '2022b6b1fcf477', + 'tag_id': 15394006, + 'auction_id': '6893555531330982923', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_requireExactDuration.html&e=wqT_3QKeCKAeBAAAAwDWAAUBCLWXp_AFEIuopuO2h7XVXxiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3NzAwMjc3KTsBHTByJywgMTQ5NDE0MTg4Nh8A8P2SArkCIVFqd1R0Z2lHa184UEVLekNuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCd3FjRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFFajRyM1ZBQUFxUU1FQkktSzkxUUFBS2tESkFZS1J6NEZQV2V3XzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRGhwUF9EN29EQ1ZOSlRqTTZORGMzTi1BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJha2xxUVUJE0RBRHdQdy4umgKJASEzUTZnOHc2PQEkblBGYklBUW9BRBVIVHFRRG9KVTBsT016bzBOemMzUU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M9A4BZUFBLtgCAOACrZhI6gJaaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193b19yZXF1aXJlRXhhY3REdXJhdGlvbi5odG1sgAMAiAMBkAMAmAMXoAMBqgMAwAPgqAHIAwDYAwDgAwDoAwD4AwGABACSBA0vdXQvdjMvcHJlYmlkmAQAogQNMjAyLjU5LjIzMS40N6gE1eYEsgQSCAEQAhiABSDgAygBKAIwADgDuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ3NzfaBAIIAOAEAPAErMKfR4gFAZgFAKAF____________AcAFAMkFAGVkFPA_0gUJCQULfAAAANgFAeAFAfAF8owB-gUECAAQAJAGAZgGALgGAMEGASEwAADwv9AG9S_aBhYKEAkRGQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=f9ddb1066825dfc556d108168ffc0d16cf567ae8', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=aAAAAAMArgAFAQm1ywleAAAAABELlGlsO9SqXxm1ywleAAAAACCswp9HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1jyjAFiAklOaAFwAXgAgAEBiAEBkAGABZgB4AOgAQCoAazCn0ewAQE.&s=db3a0d52f97edd94aa7e4213c437d8e4a5bd16ce&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149414188, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 13.000010, + 'cpm_publisher_currency': 13.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 32, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 29000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_requireExactDuration.html&e=wqT_3QL6COh6BAAAAwDWAAUBCLWXp_AFEIuopuO2h7XVXxiq5MnUovf28WEqNgmOWItPAQAqQBGOWItPAQAqQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQrMKfR1ic8VtgAGjNunV41rgFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3NzAwMjc3KTt1ZigncicsIDE0OTQxNDE4OCwgMTUZH_D9kgK5AiFRandUdGdpR2tfOFBFS3pDbjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQndxY0RrQUVBbUFFQW9BRUJxQUVEc0FFQXVRRWo0cjNWQUFBcVFNRUJJLUs5MVFBQUtrREpBWUtSejRGUFdld18yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RocFBfRDdvRENWTkpUak02TkRjM04tQUR3aGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCYWtscVFVCRNEQUR3UHcuLpoCiQEhM1E2Zzh3Nj0BJG5QRmJJQVFvQUQVSFRxUURvSlUwbE9Nem8wTnpjM1FNSVlTEXgMUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDPCLZUFBLtgCAOACrZhI6gJaaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193b19yZXF1aXJlRXhhY3REdXJhdGlvbi5odG1s8gITCg9DVVNUT01fTU9ERUxfSUQSAPICGgoWQ1VTVE9NX00FFjxMRUFGX05BTUUSAPICHgoaMjMA8MJMQVNUX01PRElGSUVEEgCAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My9wcmViaWSYBACiBA0yMDIuNTkuMjMxLjQ3qATV5gSyBBIIARACGIAFIOADKAEoAjAAOAO4BADABADIBADSBA45MzI1I1NJTjM6NDc3N9oEAggB4AQA8ASswp9HiAUBmAUAoAX___________8BwAUAyQUAAAAAAADwP9IFCQkAAABlznDYBQHgBQHwBfKMAfoFBAgAEACQBgGYBgC4BgDBBgUiLADwP9AG9S_aBhYKEAkRGQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=917c8192c7dc7e382c0bb7296ab0df261e69f572' + } + } + }] + }, { + 'uuid': '2022b6b1fcf477', + 'tag_id': 15394006, + 'auction_id': '5615186251901272031', + 'nobid': true, + 'ad_profile_id': 1182765 + }, { + 'uuid': '2022b6b1fcf477', + 'tag_id': 15394006, + 'auction_id': '6647218197537074925', + 'nobid': true, + 'ad_profile_id': 1182765 + }, { + 'uuid': '2022b6b1fcf477', + 'tag_id': 15394006, + 'auction_id': '4707051182303115567', + 'nobid': true, + 'ad_profile_id': 1182765 + }, { + 'uuid': '2022b6b1fcf477', + 'tag_id': 15394006, + 'auction_id': '4831890668873532085', + 'nobid': true, + 'ad_profile_id': 1182765 + }, { + 'uuid': '2022b6b1fcf477', + 'tag_id': 15394006, + 'auction_id': '7151522995196673389', + 'nobid': true, + 'ad_profile_id': 1182765 + }, { + 'uuid': '2022b6b1fcf477', + 'tag_id': 15394006, + 'auction_id': '4077353832159380438', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_requireExactDuration.html&e=wqT_3QKeCKAeBAAAAwDWAAUBCLWXp_AFENaHwKvS9urKOBiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3NzAwMjc3KTsBHTByJywgMTQ5NDE3NjY5Nh8A8P2SArkCIWJqeHo1UWlsa184UEVNWGRuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCd3FjRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIenJXcWtBQUFrUU1FQjg2MXFwQUFBSkVESkFZd1VQNVZMNi1VXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHBaUF9EN29EQ1ZOSlRqTTZORGMzTi1BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJha2xxUVUJE0RBRHdQdy4umgKJASFLZzhBRUE2PQEkblBGYklBUW9BRBVIVGtRRG9KVTBsT016bzBOemMzUU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M9A4BZUFBLtgCAOACrZhI6gJaaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193b19yZXF1aXJlRXhhY3REdXJhdGlvbi5odG1sgAMAiAMBkAMAmAMXoAMBqgMAwAPgqAHIAwDYAwDgAwDoAwD4AwGABACSBA0vdXQvdjMvcHJlYmlkmAQAogQNMjAyLjU5LjIzMS40N6gE1eYEsgQSCAEQAhiABSDgAygBKAIwADgDuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ3NzfaBAIIAOAEAPAExd2fR4gFAZgFAKAF____________AcAFAMkFAGVkFPA_0gUJCQULfAAAANgFAeAFAfAFwvIX-gUECAAQAJAGAZgGALgGAMEGASEwAADwv9AG9S_aBhYKEAkRGQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=e96d121a0a7d49e05c1d2b4fab2da60d0b544287', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=aAAAAAMArgAFAQm1ywleAAAAABHWA3AltauVOBm1ywleAAAAACDF3Z9HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1jC8hdiAklOaAFwAXgAgAEBiAEBkAGABZgB4AOgAQCoAcXdn0ewAQE.&s=8d90e3ce42fe47da19cb85f8fb2d78822c590464&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149417669, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 10.000000, + 'cpm_publisher_currency': 10.000000, + 'publisher_currency_code': '$', + 'brand_category_id': 4, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 30000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_requireExactDuration.html&e=wqT_3QL6CKB6BAAAAwDWAAUBCLWXp_AFENaHwKvS9urKOBiq5MnUovf28WEqNgkAAAECCCRAEQEHEAAAJEAZCQkI4D8hCQkIJEApEQkAMQkJsOA_MNbJqwc47UhA7UhIAlDF3Z9HWJzxW2AAaM26dXjWuAWAAQGKAQNVU0SSAQEG8FWYAQGgAQGoAQGwAQC4AQPAAQTIAQLQAQDYAQDgAQDwAQCKAjx1ZignYScsIDI1Mjk4ODUsIDE1Nzc3MDAyNzcpO3VmKCdyJywgMTQ5NDE3NjY5LCAxNRkf8P2SArkCIWJqeHo1UWlsa184UEVNWGRuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCd3FjRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIenJXcWtBQUFrUU1FQjg2MXFwQUFBSkVESkFZd1VQNVZMNi1VXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHBaUF9EN29EQ1ZOSlRqTTZORGMzTi1BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJha2xxUVUJE0RBRHdQdy4umgKJASFLZzhBRUE2PQEkblBGYklBUW9BRBVIVGtRRG9KVTBsT016bzBOemMzUU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M8ItlQUEu2AIA4AKtmEjqAlpodHRwOi8vdGVzdC5sb2NhbGhvc3Q6OTk5OS9pbnRlZ3JhdGlvbkV4YW1wbGVzL2xvbmdmb3JtL2Jhc2ljX3dvX3JlcXVpcmVFeGFjdER1cmF0aW9uLmh0bWzyAhMKD0NVU1RPTV9NT0RFTF9JRBIA8gIaChZDVVNUT01fTQUWPExFQUZfTkFNRRIA8gIeChoyMwDwwkxBU1RfTU9ESUZJRUQSAIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIEDTIwMi41OS4yMzEuNDeoBNXmBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0Nzc32gQCCAHgBADwBMXdn0eIBQGYBQCgBf___________wHABQDJBQAAAAAAAPA_0gUJCQAAAGXOcNgFAeAFAfAFwvIX-gUECAAQAJAGAZgGALgGAMEGBSIsAPA_0Ab1L9oGFgoQCREZAVAQABgA4AYE8gYCCACABwGIBwCgB0A.&s=db30796cc71c3bee3aa8fc2890c75ad7186f9d73' + } + } + }] + }, { + 'uuid': '2022b6b1fcf477', + 'tag_id': 15394006, + 'auction_id': '2099457773367093540', + 'nobid': true, + 'ad_profile_id': 1182765 + }, { + 'uuid': '2022b6b1fcf477', + 'tag_id': 15394006, + 'auction_id': '7214207858308840891', + 'nobid': true, + 'ad_profile_id': 1182765 + }, { + 'uuid': '2022b6b1fcf477', + 'tag_id': 15394006, + 'auction_id': '4564285281969145467', + 'nobid': true, + 'ad_profile_id': 1182765 + }] + } + } + } +} diff --git a/test/mock-server/expectations/request-response-pairs/longform/basic_wo_requireExactDuration_request_2.js b/test/mock-server/expectations/request-response-pairs/longform/basic_wo_requireExactDuration_request_2.js new file mode 100644 index 00000000000..751abfa14e4 --- /dev/null +++ b/test/mock-server/expectations/request-response-pairs/longform/basic_wo_requireExactDuration_request_2.js @@ -0,0 +1,312 @@ +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 + * + */ + +/** + * 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': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }], + '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': '2022b6b1fcf477', + 'tag_id': 15394006, + 'auction_id': '2704229116537156015', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_requireExactDuration.html&e=wqT_3QKeCKAeBAAAAwDWAAUBCLWXp_AFEK_j3NPcwdbDJRiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3NzAwMjc3KTsBHTByJywgMTQ5NDE3OTUxNh8A8P2SArkCIXpUczJvQWlta184UEVOX2ZuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCd3FjRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFURVBwVy1oVE9ZXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHBwUF9EN29EQ1ZOSlRqTTZORGMwT2VBRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJZMGxxUVUJE0BBRHdQdy4umgKJASFVQV9qSDo9ASRuUEZiSUFRb0FEFUhUdVFEb0pVMGxPTXpvME56UTVRTUlZUxF4DFBBX1URDAxBQUFXHQwAWR0MAGEdDABjHQz0DgFlQUEu2AIA4AKtmEjqAlpodHRwOi8vdGVzdC5sb2NhbGhvc3Q6OTk5OS9pbnRlZ3JhdGlvbkV4YW1wbGVzL2xvbmdmb3JtL2Jhc2ljX3dvX3JlcXVpcmVFeGFjdER1cmF0aW9uLmh0bWyAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My9wcmViaWSYBACiBA0yMDIuNTkuMjMxLjQ3qATV5gSyBBIIARACGIAFIOADKAEoAjAAOAO4BADABADIBADSBA45MzI1I1NJTjM6NDc0OdoEAggA4AQA8ATf359HiAUBmAUAoAX___________8BwAUAyQUAZWQU8D_SBQkJBQt8AAAA2AUB4AUB8AWsvBT6BQQIABAAkAYBmAYAuAYAwQYBITAAAPC_0Ab1L9oGFgoQCREZAVAQABgA4AYE8gYCCACABwGIBwCgB0A.&s=64565aadf65d370e9730e9ce82c93c9bd2fcfc14', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=aAAAAAMArgAFAQm1ywleAAAAABGvMXfKDVqHJRm1ywleAAAAACDf359HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1isvBRiAklOaAFwAXgAgAEBiAEBkAGABZgB4AOgAQCoAd_fn0ewAQE.&s=3b1f10f67b3253e38770fff694edbe6052795602&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149417951, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 33, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 30000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_requireExactDuration.html&e=wqT_3QL6COh6BAAAAwDWAAUBCLWXp_AFEK_j3NPcwdbDJRiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQ39-fR1ic8VtgAGjNunV4t7gFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3NzAwMjc3KTt1ZigncicsIDE0OTQxNzk1MSwgMTUZH_D9kgK5AiF6VHMyb0FpbWtfOFBFTl9mbjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQndxY0RrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBVEVQcFctaFRPWV8yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwcFBfRDdvRENWTkpUak02TkRjME9lQUR3aGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCWTBscVFVCRNAQUR3UHcuLpoCiQEhVUFfakg6PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOelE1UU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M8ItlQUEu2AIA4AKtmEjqAlpodHRwOi8vdGVzdC5sb2NhbGhvc3Q6OTk5OS9pbnRlZ3JhdGlvbkV4YW1wbGVzL2xvbmdmb3JtL2Jhc2ljX3dvX3JlcXVpcmVFeGFjdER1cmF0aW9uLmh0bWzyAhMKD0NVU1RPTV9NT0RFTF9JRBIA8gIaChZDVVNUT01fTQUWPExFQUZfTkFNRRIA8gIeChoyMwDwwkxBU1RfTU9ESUZJRUQSAIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIEDTIwMi41OS4yMzEuNDeoBNXmBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzQ52gQCCAHgBADwBN_fn0eIBQGYBQCgBf___________wHABQDJBQAAAAAAAPA_0gUJCQAAAGXOcNgFAeAFAfAFrLwU-gUECAAQAJAGAZgGALgGAMEGBSIsAPA_0Ab1L9oGFgoQCREZAVAQABgA4AYE8gYCCACABwGIBwCgB0A.&s=5316c3262f36e4d89735b1ba252c64651a84f479' + } + } + }] + }, { + 'uuid': '2022b6b1fcf477', + 'tag_id': 15394006, + 'auction_id': '7987581685263122854', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_requireExactDuration.html&e=wqT_3QKeCKAeBAAAAwDWAAUBCLWXp_AFEKaDmaSQ5-Xsbhiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3NzAwMjc3KTsBHTByJywgMTQ5NDE5NjAyNh8A8P2SArkCIU16MXpZd2lua184UEVOTHNuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCd3FjRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFYLVkxZU5tY3VRXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHA1UF9EN29EQ1ZOSlRqTTZORGMwT2VBRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJZMGxxUVUJE0RBRHdQdy4umgKJASFVUTgySFE2PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOelE1UU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M9A4BZUFBLtgCAOACrZhI6gJaaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193b19yZXF1aXJlRXhhY3REdXJhdGlvbi5odG1sgAMAiAMBkAMAmAMXoAMBqgMAwAPgqAHIAwDYAwDgAwDoAwD4AwGABACSBA0vdXQvdjMvcHJlYmlkmAQAogQNMjAyLjU5LjIzMS40N6gE1eYEsgQSCAEQAhiABSDgAygBKAIwADgDuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ3NDnaBAIIAOAEAPAE0uyfR4gFAZgFAKAF____________AcAFAMkFAGVkFPA_0gUJCQULfAAAANgFAeAFAfAF2boG-gUECAAQAJAGAZgGALgGAMEGASEwAADwv9AG9S_aBhYKEAkRGQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=17f2a3f5e78c188cc6ca23e677ced305198a8a05', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=aAAAAAMArgAFAQm1ywleAAAAABGmQYYEOZfZbhm1ywleAAAAACDS7J9HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1jZugZiAklOaAFwAXgAgAEBiAEBkAGABZgB4AOgAQCoAdLsn0ewAQE.&s=28e8f96efdfb9bc1e33e4d087ff5ed992e4692b1&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149419602, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 24, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 15000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_requireExactDuration.html&e=wqT_3QL6COh6BAAAAwDWAAUBCLWXp_AFEKaDmaSQ5-Xsbhiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQ0uyfR1ic8VtgAGjNunV4t7gFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3NzAwMjc3KTt1ZigncicsIDE0OTQxOTYwMiwgMTUZH_D9kgK5AiFNejF6WXdpbmtfOFBFTkxzbjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQndxY0RrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBWC1ZMWVObWN1UV8yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwNVBfRDdvRENWTkpUak02TkRjME9lQUR3aGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCWTBscVFVCRNEQUR3UHcuLpoCiQEhVVE4MkhRNj0BJG5QRmJJQVFvQUQVSFR1UURvSlUwbE9Nem8wTnpRNVFNSVlTEXgMUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDPCLZUFBLtgCAOACrZhI6gJaaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193b19yZXF1aXJlRXhhY3REdXJhdGlvbi5odG1s8gITCg9DVVNUT01fTU9ERUxfSUQSAPICGgoWQ1VTVE9NX00FFjxMRUFGX05BTUUSAPICHgoaMjMA8MJMQVNUX01PRElGSUVEEgCAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My9wcmViaWSYBACiBA0yMDIuNTkuMjMxLjQ3qATV5gSyBBIIARACGIAFIOADKAEoAjAAOAO4BADABADIBADSBA45MzI1I1NJTjM6NDc0OdoEAggB4AQA8ATS7J9HiAUBmAUAoAX___________8BwAUAyQUAAAAAAADwP9IFCQkAAABlznDYBQHgBQHwBdm6BvoFBAgAEACQBgGYBgC4BgDBBgUiLADwP9AG9S_aBhYKEAkRGQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=89d4586d9597cd2f9a4a918d1e6985aee45ade01' + } + } + }] + }, { + 'uuid': '2022b6b1fcf477', + 'tag_id': 15394006, + 'auction_id': '653115326806257319', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_requireExactDuration.html&e=wqT_3QKdCKAdBAAAAwDWAAUBCLWXp_AFEKfdmd3enZWICRiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3NzAwMjc3KTsBHTByJywgMTQ5NDE4NjcxNh8A8P2SArkCITlEd0hNZ2lta184UEVLX2xuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCd3FjRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFjTnlESmJxeS13XzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHBwUF9EN29EQ1ZOSlRqTTZORGMwT2VBRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJZMGxxUVUJE0RBRHdQdy4umgKJASFKZ192RFE2PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOelE1UU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M9A4BZUFBLtgCAOACrZhI6gJaaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193b19yZXF1aXJlRXhhY3REdXJhdGlvbi5odG1sgAMAiAMBkAMAmAMXoAMBqgMAwAPgqAHIAwDYAwDgAwDoAwD4AwGABACSBA0vdXQvdjMvcHJlYmlkmAQAogQNMjAyLjU5LjIzMS40N6gE1eYEsgQSCAEQAhiABSDgAygBKAIwADgDuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ3NDnaBAIIAOAEAPAEr-WfR4gFAZgFAKAF____________AcAFAMkFAGVkFPA_0gUJCQULeAAAANgFAeAFAfAF4Fj6BQQIABAAkAYBmAYAuAYAwQYBIDAAAPC_0Ab1L9oGFgoQCREZAVAQABgA4AYE8gYCCACABwGIBwCgB0A.&s=1928a9daadbd431792adace7620880dda961eefb', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=ZwAAAAMArgAFAQm1ywleAAAAABGnbqbr7VQQCRm1ywleAAAAACCv5Z9HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1jgWGICSU5oAXABeACAAQGIAQGQAYAFmAHgA6ABAKgBr-WfR7ABAQ..&s=7617d08e0c16fe1dea8ec80cd6bf73ec0a736b41&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149418671, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 30, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 30000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_requireExactDuration.html&e=wqT_3QL5COh5BAAAAwDWAAUBCLWXp_AFEKfdmd3enZWICRiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQr-WfR1ic8VtgAGjNunV4t7gFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3NzAwMjc3KTt1ZigncicsIDE0OTQxODY3MSwgMTUZH_D9kgK5AiE5RHdITWdpbWtfOFBFS19sbjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQndxY0RrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBY055REpicXktd18yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwcFBfRDdvRENWTkpUak02TkRjME9lQUR3aGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCWTBscVFVCRNEQUR3UHcuLpoCiQEhSmdfdkRRNj0BJG5QRmJJQVFvQUQVSFR1UURvSlUwbE9Nem8wTnpRNVFNSVlTEXgMUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDPCLZUFBLtgCAOACrZhI6gJaaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193b19yZXF1aXJlRXhhY3REdXJhdGlvbi5odG1s8gITCg9DVVNUT01fTU9ERUxfSUQSAPICGgoWQ1VTVE9NX00FFjxMRUFGX05BTUUSAPICHgoaMjMA8MJMQVNUX01PRElGSUVEEgCAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My9wcmViaWSYBACiBA0yMDIuNTkuMjMxLjQ3qATV5gSyBBIIARACGIAFIOADKAEoAjAAOAO4BADABADIBADSBA45MzI1I1NJTjM6NDc0OdoEAggB4AQA8ASv5Z9HiAUBmAUAoAX___________8BwAUAyQUAAAAAAADwP9IFCQkAAABlzmzYBQHgBQHwBeBY-gUECAAQAJAGAZgGALgGAMEGBSEsAPA_0Ab1L9oGFgoQCREZAVAQABgA4AYE8gYCCACABwGIBwCgB0A.&s=0d1d3f42fa225995a2f57ab84877dce3d24e9901' + } + } + }] + }, { + 'uuid': '2022b6b1fcf477', + 'tag_id': 15394006, + 'auction_id': '866435845408148233', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_requireExactDuration.html&e=wqT_3QKeCKAeBAAAAwDWAAUBCLWXp_AFEImW35H52YyDDBiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3NzAwMjc3KTsBHTByJywgMTQ5NDE4MTIzNh8A8P2SArkCIXJEenNfZ2lua184UEVJdmhuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCd3FjRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFjMmZTZ1BpMi1BXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHA1UF9EN29EQ1ZOSlRqTTZORGMwT2VBRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJZMGxxUVUJE0RBRHdQdy4umgKJASFfdzRiQUE2PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOelE1UU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M9A4BZUFBLtgCAOACrZhI6gJaaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193b19yZXF1aXJlRXhhY3REdXJhdGlvbi5odG1sgAMAiAMBkAMAmAMXoAMBqgMAwAPgqAHIAwDYAwDgAwDoAwD4AwGABACSBA0vdXQvdjMvcHJlYmlkmAQAogQNMjAyLjU5LjIzMS40N6gE1eYEsgQSCAEQAhiABSDgAygBKAIwADgDuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ3NDnaBAIIAOAEAPAEi-GfR4gFAZgFAKAF____________AcAFAMkFAGVkFPA_0gUJCQULfAAAANgFAeAFAfAF2tYC-gUECAAQAJAGAZgGALgGAMEGASEwAADwv9AG9S_aBhYKEAkRGQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=83f65f38b4fd56344b3aceb70df7bac1b9b5f229', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=aAAAAAMArgAFAQm1ywleAAAAABEJyzeSzzIGDBm1ywleAAAAACCL4Z9HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1ja1gJiAklOaAFwAXgAgAEBiAEBkAGABZgB4AOgAQCoAYvhn0ewAQE.&s=9130c13cca7a1d3eb05c2b96585ccfdc2faa6844&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149418123, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 12, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 15000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_requireExactDuration.html&e=wqT_3QL6COh6BAAAAwDWAAUBCLWXp_AFEImW35H52YyDDBiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQi-GfR1ic8VtgAGjNunV4t7gFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3NzAwMjc3KTt1ZigncicsIDE0OTQxODEyMywgMTUZH_D9kgK5AiFyRHpzX2dpbmtfOFBFSXZobjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQndxY0RrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBYzJmU2dQaTItQV8yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwNVBfRDdvRENWTkpUak02TkRjME9lQUR3aGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCWTBscVFVCRNEQUR3UHcuLpoCiQEhX3c0YkFBNj0BJG5QRmJJQVFvQUQVSFR1UURvSlUwbE9Nem8wTnpRNVFNSVlTEXgMUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDPCLZUFBLtgCAOACrZhI6gJaaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193b19yZXF1aXJlRXhhY3REdXJhdGlvbi5odG1s8gITCg9DVVNUT01fTU9ERUxfSUQSAPICGgoWQ1VTVE9NX00FFjxMRUFGX05BTUUSAPICHgoaMjMA8MJMQVNUX01PRElGSUVEEgCAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My9wcmViaWSYBACiBA0yMDIuNTkuMjMxLjQ3qATV5gSyBBIIARACGIAFIOADKAEoAjAAOAO4BADABADIBADSBA45MzI1I1NJTjM6NDc0OdoEAggB4AQA8ASL4Z9HiAUBmAUAoAX___________8BwAUAyQUAAAAAAADwP9IFCQkAAABlznDYBQHgBQHwBdrWAvoFBAgAEACQBgGYBgC4BgDBBgUiLADwP9AG9S_aBhYKEAkRGQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=1f88d8b0a467d528291f90a54fd810b8fdac4488' + } + } + }] + }, { + 'uuid': '2022b6b1fcf477', + 'tag_id': 15394006, + 'auction_id': '1540903203561034860', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_requireExactDuration.html&e=wqT_3QKdCKAdBAAAAwDWAAUBCLWXp_AFEOyokYzL6ZixFRiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3NzAwMjc3KTsBHTByJywgMTQ5NDE4OTQ4Nh8A8P2SArkCIXdUekVId2lta184UEVNVG5uMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCd3FjRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFaeE00NUxjRXVNXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHBwUF9EN29EQ1ZOSlRqTTZORGMwT2VBRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJZMGxxUVUJE0RBRHdQdy4umgKJASFQUThhRmc2PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOelE1UU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M9A4BZUFBLtgCAOACrZhI6gJaaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193b19yZXF1aXJlRXhhY3REdXJhdGlvbi5odG1sgAMAiAMBkAMAmAMXoAMBqgMAwAPgqAHIAwDYAwDgAwDoAwD4AwGABACSBA0vdXQvdjMvcHJlYmlkmAQAogQNMjAyLjU5LjIzMS40N6gE1eYEsgQSCAEQAhiABSDgAygBKAIwADgDuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ3NDnaBAIIAOAEAPAExOefR4gFAZgFAKAF____________AcAFAMkFAGVkFPA_0gUJCQULeAAAANgFAeAFAfAFmT36BQQIABAAkAYBmAYAuAYAwQYBIDAAAPC_0Ab1L9oGFgoQCREZAVAQABgA4AYE8gYCCACABwGIBwCgB0A.&s=a4de0e4084ce04a5cb2d347c07fde867aa9ff5c1', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=ZwAAAAMArgAFAQm1ywleAAAAABFsVISxTGNiFRm1ywleAAAAACDE559HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1iZPWICSU5oAXABeACAAQGIAQGQAYAFmAHgA6ABAKgBxOefR7ABAQ..&s=cf600d825cec85f83c06119e5e383f8548b469a2&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149418948, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 1, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 30000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_wo_requireExactDuration.html&e=wqT_3QL5COh5BAAAAwDWAAUBCLWXp_AFEOyokYzL6ZixFRiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQxOefR1ic8VtgAGjNunV4t7gFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3NzAwMjc3KTt1ZigncicsIDE0OTQxODk0OCwgMTUZH_D9kgK5AiF3VHpFSHdpbWtfOFBFTVRubjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQndxY0RrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBWnhNNDVMY0V1TV8yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwcFBfRDdvRENWTkpUak02TkRjME9lQUR3aGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCWTBscVFVCRNEQUR3UHcuLpoCiQEhUFE4YUZnNj0BJG5QRmJJQVFvQUQVSFR1UURvSlUwbE9Nem8wTnpRNVFNSVlTEXgMUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDPCLZUFBLtgCAOACrZhI6gJaaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193b19yZXF1aXJlRXhhY3REdXJhdGlvbi5odG1s8gITCg9DVVNUT01fTU9ERUxfSUQSAPICGgoWQ1VTVE9NX00FFjxMRUFGX05BTUUSAPICHgoaMjMA8MJMQVNUX01PRElGSUVEEgCAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My9wcmViaWSYBACiBA0yMDIuNTkuMjMxLjQ3qATV5gSyBBIIARACGIAFIOADKAEoAjAAOAO4BADABADIBADSBA45MzI1I1NJTjM6NDc0OdoEAggB4AQA8ATE559HiAUBmAUAoAX___________8BwAUAyQUAAAAAAADwP9IFCQkAAABlzmzYBQHgBQHwBZk9-gUECAAQAJAGAZgGALgGAMEGBSEsAPA_0Ab1L9oGFgoQCREZAVAQABgA4AYE8gYCCACABwGIBwCgB0A.&s=17c466ea45d5d4beff02aa2b0eb87bc6c4d5aff3' + } + } + }] + }] + } + } + } +} diff --git a/test/mock-server/expectations/request-response-pairs/longform/bidder_settings_request_1.js b/test/mock-server/expectations/request-response-pairs/longform/bidder_settings_request_1.js new file mode 100644 index 00000000000..4f11a203724 --- /dev/null +++ b/test/mock-server/expectations/request-response-pairs/longform/bidder_settings_request_1.js @@ -0,0 +1,418 @@ +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 + * + */ + +/** + * 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': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }], + 'user': {}, + 'brand_category_uniqueness': true + } + } + } +} + +/** + * 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': '2d4806af582cf6', + 'tag_id': 15394006, + 'auction_id': '2678252910506723691', + 'nobid': true, + 'ad_profile_id': 1182765 + }, { + 'uuid': '2d4806af582cf6', + 'tag_id': 15394006, + 'auction_id': '3548675574061430850', + 'nobid': true, + 'ad_profile_id': 1182765 + }, { + 'uuid': '2d4806af582cf6', + 'tag_id': 15394006, + 'auction_id': '8693167356543642173', + 'nobid': true, + 'ad_profile_id': 1182765 + }, { + 'uuid': '2d4806af582cf6', + 'tag_id': 15394006, + 'auction_id': '7686428711280367086', + 'nobid': true, + 'ad_profile_id': 1182765 + }, { + 'uuid': '2d4806af582cf6', + 'tag_id': 15394006, + 'auction_id': '3784359541475413084', + 'nobid': true, + 'ad_profile_id': 1182765 + }, { + 'uuid': '2d4806af582cf6', + 'tag_id': 15394006, + 'auction_id': '7233136875958651734', + 'nobid': true, + 'ad_profile_id': 1182765 + }, { + 'uuid': '2d4806af582cf6', + 'tag_id': 15394006, + 'auction_id': '159775901183771330', + 'nobid': true, + 'ad_profile_id': 1182765 + }, { + 'uuid': '2d4806af582cf6', + 'tag_id': 15394006, + 'auction_id': '6558726890185052779', + 'nobid': true, + 'ad_profile_id': 1182765 + }, { + 'uuid': '2d4806af582cf6', + 'tag_id': 15394006, + 'auction_id': '6624810255570939818', + 'nobid': true, + 'ad_profile_id': 1182765 + }, { + 'uuid': '2d4806af582cf6', + 'tag_id': 15394006, + 'auction_id': '528384387675374412', + 'nobid': true, + 'ad_profile_id': 1182765 + }, { + 'uuid': '2d4806af582cf6', + 'tag_id': 15394006, + 'auction_id': '2535665225687089273', + 'nobid': true, + 'ad_profile_id': 1182765 + }, { + 'uuid': '2d4806af582cf6', + 'tag_id': 15394006, + 'auction_id': '2166694611986638079', + 'nobid': true, + 'ad_profile_id': 1182765 + }, { + 'uuid': '2d4806af582cf6', + 'tag_id': 15394006, + 'auction_id': '9137369006412413609', + 'nobid': true, + 'ad_profile_id': 1182765 + }, { + 'uuid': '2d4806af582cf6', + 'tag_id': 15394006, + 'auction_id': '3524702228053475248', + 'nobid': true, + 'ad_profile_id': 1182765 + }, { + 'uuid': '2d4806af582cf6', + 'tag_id': 15394006, + 'auction_id': '57990683038266307', + 'nobid': true, + 'ad_profile_id': 1182765 + }] + } + } + } +} diff --git a/test/mock-server/expectations/request-response-pairs/longform/bidder_settings_request_2.js b/test/mock-server/expectations/request-response-pairs/longform/bidder_settings_request_2.js new file mode 100644 index 00000000000..b69612d86b9 --- /dev/null +++ b/test/mock-server/expectations/request-response-pairs/longform/bidder_settings_request_2.js @@ -0,0 +1,284 @@ +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 + * + */ + +/** + * 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': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }], + 'user': {}, + 'brand_category_uniqueness': true + } + } + } +} + +/** + * 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': '245a09bd675168', + 'tag_id': 15394006, + 'auction_id': '3810681093956255668', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_bidderSettings.html&e=wqT_3QKVCKAVBAAAAwDWAAUBCKD4kfAFELT_vOy9yJDxNBiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3MzUyMjI0KTsBHTByJywgMTQ5NDE5NjAyNh8A8P2SArkCIUxEMWZkUWlua184UEVOTHNuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCOE13Q2tBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFZVS10N09mcU9BXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHA1UF9EN29EQ1ZOSlRqTTZORGMxTS1BRG9SaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJaRWxxUVUJE0RBRHdQdy4umgKJASFLdy1SRkE2PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOelV6UUtFWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M9AUBZUFBLtgCAOACrZhI6gJTaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193X2JpZGRlclNldHRpbmdzLmh0bWyAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My9wcmViaWSYBACiBAsxMC43NS43NC42OagErLkEsgQSCAEQAhiABSDgAygBKAIwADgDuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ3NTPaBAIIAOAEAPAE0uyfR4gFAZgFAKAF____________AcAFAMkFAGVbFPA_0gUJCQULfAAAANgFAeAFAfAF2boG-gUECAAQAJAGAZgGALgGAMEGASEwAADwv9AG9S_aBhYKEAkRGQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=66ba37441db5e28c87ee52e729333fd9324333f9', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=aAAAAAMArgAFAQkgfAReAAAAABG0P4_dQ0LiNBkgfAReAAAAACDS7J9HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1jZugZiAi0taAFwAXgAgAEBiAEBkAGABZgB4AOgAQCoAdLsn0ewAQE.&s=6931bf3569012d0e1f02cb5a2e88dfcafe00dba9&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149419602, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 24, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 15000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_bidderSettings.html&e=wqT_3QLxCOhxBAAAAwDWAAUBCKD4kfAFELT_vOy9yJDxNBiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQ0uyfR1ic8VtgAGjNunV4vLgFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3MzUyMjI0KTt1ZigncicsIDE0OTQxOTYwMiwgMTUZH_D9kgK5AiFMRDFmZFFpbmtfOFBFTkxzbjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQjhNd0NrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBWVUtdDdPZnFPQV8yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwNVBfRDdvRENWTkpUak02TkRjMU0tQURvUmlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCWkVscVFVCRNEQUR3UHcuLpoCiQEhS3ctUkZBNj0BJG5QRmJJQVFvQUQVSFR1UURvSlUwbE9Nem8wTnpVelFLRVlTEXgMUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDPCaZUFBLtgCAOACrZhI6gJTaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193X2JpZGRlclNldHRpbmdzLmh0bWzyAhMKD0NVU1RPTV9NT0RFTF9JRBIA8gIaChZDVVNUT01fTU9ERUxfTEVBRl9OQU1FEgDyAh4KGkMyHQDwlUFTVF9NT0RJRklFRBIAgAMAiAMBkAMAmAMXoAMBqgMAwAPgqAHIAwDYAwDgAwDoAwD4AwGABACSBA0vdXQvdjMvcHJlYmlkmAQAogQLMTAuNzUuNzQuNjmoBKy5BLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzUz2gQCCAHgBADwBGGFIIgFAZgFAKAF_xEBFAHABQDJBWm2FPA_0gUJCQkMeAAA2AUB4AUB8AXZugb6BQQIABAAkAYBmAYAuAYAwQYJJSjwP9AG9S_aBhYKEAkRGQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=ea46ec90cf31744c7be2af5d5f239ab4eed29098' + } + } + }] + }, { + 'uuid': '245a09bd675168', + 'tag_id': 15394006, + 'auction_id': '7325897349627488405', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_bidderSettings.html&e=wqT_3QKUCKAUBAAAAwDWAAUBCKD4kfAFEJXRloy0mrTVZRiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3MzUyMjI0KTsBHTByJywgMTQ5NDE4NjcxNh8A8P2SArkCIXJUeTNJd2lta184UEVLX2xuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCOE13Q2tBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFVSzAtQ2hwcWRrXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHBwUF9EN29EQ1ZOSlRqTTZORGMxTS1BRG9SaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJaRWxxUVUJE0RBRHdQdy4umgKJASFBQTlLQlE2PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOelV6UUtFWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M9AUBZUFBLtgCAOACrZhI6gJTaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193X2JpZGRlclNldHRpbmdzLmh0bWyAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My9wcmViaWSYBACiBAsxMC43NS43NC42OagErLkEsgQSCAEQAhiABSDgAygBKAIwADgDuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ3NTPaBAIIAOAEAPAEr-WfR4gFAZgFAKAF____________AcAFAMkFAGVbFPA_0gUJCQULeAAAANgFAeAFAfAF4Fj6BQQIABAAkAYBmAYAuAYAwQYBIDAAAPC_0Ab1L9oGFgoQCREZAVAQABgA4AYE8gYCCACABwGIBwCgB0A.&s=271fd8a0ccdfc36e320f707164588ed1b33e9861', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=ZwAAAAMArgAFAQkgfAReAAAAABGVqIVB09CqZRkgfAReAAAAACCv5Z9HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1jgWGICLS1oAXABeACAAQGIAQGQAYAFmAHgA6ABAKgBr-WfR7ABAQ..&s=115ac2b842cf3efeb5acaeda94ddf05632c345ca&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149418671, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 30, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 30000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_bidderSettings.html&e=wqT_3QLwCOhwBAAAAwDWAAUBCKD4kfAFEJXRloy0mrTVZRiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQr-WfR1ic8VtgAGjNunV4vLgFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3MzUyMjI0KTt1ZigncicsIDE0OTQxODY3MSwgMTUZH_D9kgK5AiFyVHkzSXdpbWtfOFBFS19sbjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQjhNd0NrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBVUswLUNocHFka18yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwcFBfRDdvRENWTkpUak02TkRjMU0tQURvUmlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCWkVscVFVCRNEQUR3UHcuLpoCiQEhQUE5S0JRNj0BJG5QRmJJQVFvQUQVSFR1UURvSlUwbE9Nem8wTnpVelFLRVlTEXgMUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDPCaZUFBLtgCAOACrZhI6gJTaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193X2JpZGRlclNldHRpbmdzLmh0bWzyAhMKD0NVU1RPTV9NT0RFTF9JRBIA8gIaChZDVVNUT01fTU9ERUxfTEVBRl9OQU1FEgDyAh4KGkMyHQDwlUFTVF9NT0RJRklFRBIAgAMAiAMBkAMAmAMXoAMBqgMAwAPgqAHIAwDYAwDgAwDoAwD4AwGABACSBA0vdXQvdjMvcHJlYmlkmAQAogQLMTAuNzUuNzQuNjmoBKy5BLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzUz2gQCCAHgBADwBGGFIIgFAZgFAKAF_xEBFAHABQDJBWm2FPA_0gUJCQkMdAAA2AUB4AUB8AXgWPoFBAgAEACQBgGYBgC4BgDBBgkkKPA_0Ab1L9oGFgoQCREZAVAQABgA4AYE8gYCCACABwGIBwCgB0A.&s=f73e060b15a6bbcca65f918a296f155b78c74eca' + } + } + }] + }, { + 'uuid': '245a09bd675168', + 'tag_id': 15394006, + 'auction_id': '968802322305726102', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_bidderSettings.html&e=wqT_3QKVCKAVBAAAAwDWAAUBCKD4kfAFEJbt7LTEkvi4DRiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3MzUyMjI0KTsBHTByJywgMTQ5NDE0MTg4Nh8A8P2SArkCIUtUejN5d2lHa184UEVLekNuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCOE13Q2tBRUFtQUVBb0FFQnFBRURzQUVBdVFFajRyM1ZBQUFxUU1FQkktSzkxUUFBS2tESkFTT3dTTWVaYnVJXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRGhwUF9EN29EQ1ZOSlRqTTZORGMxTS1BRG9SaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJaRWxxUVUJE0RBRHdQdy4umgKJASF0ZzY4Nmc2PQEkblBGYklBUW9BRBVIVHFRRG9KVTBsT016bzBOelV6UUtFWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M9AUBZUFBLtgCAOACrZhI6gJTaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193X2JpZGRlclNldHRpbmdzLmh0bWyAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My9wcmViaWSYBACiBAsxMC43NS43NC42OagErLkEsgQSCAEQAhiABSDgAygBKAIwADgDuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ3NTPaBAIIAOAEAPAErMKfR4gFAZgFAKAF____________AcAFAMkFAGVbFPA_0gUJCQULfAAAANgFAeAFAfAF8owB-gUECAAQAJAGAZgGALgGAMEGASEwAADwv9AG9S_aBhYKEAkRGQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=e35825a106304da78477df1575f981395be21d5f', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=aAAAAAMArgAFAQkgfAReAAAAABGWNptGlOBxDRkgfAReAAAAACCswp9HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1jyjAFiAi0taAFwAXgAgAEBiAEBkAGABZgB4AOgAQCoAazCn0ewAQE.&s=677bedd5b2d21fdc3f940cbae279261c8f84c2e7&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149414188, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 13.000010, + 'cpm_publisher_currency': 13.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 32, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 29000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_bidderSettings.html&e=wqT_3QLxCOhxBAAAAwDWAAUBCKD4kfAFEJbt7LTEkvi4DRiq5MnUovf28WEqNgmOWItPAQAqQBGOWItPAQAqQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQrMKfR1ic8VtgAGjNunV4vLgFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3MzUyMjI0KTt1ZigncicsIDE0OTQxNDE4OCwgMTUZH_D9kgK5AiFLVHozeXdpR2tfOFBFS3pDbjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQjhNd0NrQUVBbUFFQW9BRUJxQUVEc0FFQXVRRWo0cjNWQUFBcVFNRUJJLUs5MVFBQUtrREpBU093U01lWmJ1SV8yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RocFBfRDdvRENWTkpUak02TkRjMU0tQURvUmlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCWkVscVFVCRNEQUR3UHcuLpoCiQEhdGc2ODZnNj0BJG5QRmJJQVFvQUQVSFRxUURvSlUwbE9Nem8wTnpVelFLRVlTEXgMUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDPCaZUFBLtgCAOACrZhI6gJTaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193X2JpZGRlclNldHRpbmdzLmh0bWzyAhMKD0NVU1RPTV9NT0RFTF9JRBIA8gIaChZDVVNUT01fTU9ERUxfTEVBRl9OQU1FEgDyAh4KGkMyHQDwlUFTVF9NT0RJRklFRBIAgAMAiAMBkAMAmAMXoAMBqgMAwAPgqAHIAwDYAwDgAwDoAwD4AwGABACSBA0vdXQvdjMvcHJlYmlkmAQAogQLMTAuNzUuNzQuNjmoBKy5BLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzUz2gQCCAHgBADwBGGFIIgFAZgFAKAF_xEBFAHABQDJBWm2FPA_0gUJCQkMeAAA2AUB4AUB8AXyjAH6BQQIABAAkAYBmAYAuAYAwQYJJSjwP9AG9S_aBhYKEAkRGQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=0707b1385afa81517cd338f1516aeccc46fe33e1' + } + } + }] + }, { + 'uuid': '245a09bd675168', + 'tag_id': 15394006, + 'auction_id': '1273216786519070425', + 'nobid': true, + 'ad_profile_id': 1182765 + }, { + 'uuid': '245a09bd675168', + 'tag_id': 15394006, + 'auction_id': '1769115862397582681', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_bidderSettings.html&e=wqT_3QKUCKAUBAAAAwDWAAUBCKD4kfAFENn63YWPsMrGGBiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3MzUyMjI0KTsBHTByJywgMTQ5NDE4OTQ4Nh8A8P2SArkCIXp6djFzd2lta184UEVNVG5uMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCOE13Q2tBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFZbW5MamdJaXVRXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHBwUF9EN29EQ1ZOSlRqTTZORGMxTS1BRG9SaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJaRWxxUVUJE0RBRHdQdy4umgKJASFGdzkxRFE2PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOelV6UUtFWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M9AUBZUFBLtgCAOACrZhI6gJTaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193X2JpZGRlclNldHRpbmdzLmh0bWyAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My9wcmViaWSYBACiBAsxMC43NS43NC42OagErLkEsgQSCAEQAhiABSDgAygBKAIwADgDuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ3NTPaBAIIAOAEAPAExOefR4gFAZgFAKAF____________AcAFAMkFAGVbFPA_0gUJCQULeAAAANgFAeAFAfAFmT36BQQIABAAkAYBmAYAuAYAwQYBIDAAAPC_0Ab1L9oGFgoQCREZAVAQABgA4AYE8gYCCACABwGIBwCgB0A.&s=fb3a15e7ff747fccd750671b763e312d97083c72', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=ZwAAAAMArgAFAQkgfAReAAAAABFZfbfwgCmNGBkgfAReAAAAACDE559HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1iZPWICLS1oAXABeACAAQGIAQGQAYAFmAHgA6ABAKgBxOefR7ABAQ..&s=7f4b8dd7c7dd9faecebac2e9ec6d7ef8da08da16&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149418948, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 1, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 30000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_bidderSettings.html&e=wqT_3QLwCOhwBAAAAwDWAAUBCKD4kfAFENn63YWPsMrGGBiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQxOefR1ic8VtgAGjNunV4vLgFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3MzUyMjI0KTt1ZigncicsIDE0OTQxODk0OCwgMTUZH_D9kgK5AiF6enYxc3dpbWtfOFBFTVRubjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQjhNd0NrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBWW1uTGpnSWl1UV8yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwcFBfRDdvRENWTkpUak02TkRjMU0tQURvUmlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCWkVscVFVCRNEQUR3UHcuLpoCiQEhRnc5MURRNj0BJG5QRmJJQVFvQUQVSFR1UURvSlUwbE9Nem8wTnpVelFLRVlTEXgMUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDPCaZUFBLtgCAOACrZhI6gJTaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193X2JpZGRlclNldHRpbmdzLmh0bWzyAhMKD0NVU1RPTV9NT0RFTF9JRBIA8gIaChZDVVNUT01fTU9ERUxfTEVBRl9OQU1FEgDyAh4KGkMyHQDwsEFTVF9NT0RJRklFRBIAgAMAiAMBkAMAmAMXoAMBqgMAwAPgqAHIAwDYAwDgAwDoAwD4AwGABACSBA0vdXQvdjMvcHJlYmlkmAQAogQLMTAuNzUuNzQuNjmoBKy5BLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzUz2gQCCAHgBADwBMTnn0eIBQGYBQCgBf___________wHABQDJBWm2FPA_0gUJCQkMdAAA2AUB4AUB8AWZPfoFBAgAEACQBgGYBgC4BgDBBgkkKPA_0Ab1L9oGFgoQCREZAVAQABgA4AYE8gYCCACABwGIBwCgB0A.&s=3a27c12c33ebaaae43dbce1cafb0bae43b753fa0' + } + } + }] + }] + } + } + } +} diff --git a/test/mock-server/expectations/request-response-pairs/longform/price_gran_request_1.js b/test/mock-server/expectations/request-response-pairs/longform/price_gran_request_1.js new file mode 100644 index 00000000000..ffb03cc0563 --- /dev/null +++ b/test/mock-server/expectations/request-response-pairs/longform/price_gran_request_1.js @@ -0,0 +1,620 @@ +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 + * + */ + +/** + * 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': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }], + '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': '2def02900a6cda', + 'tag_id': 15394006, + 'auction_id': '1249897353793397796', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_priceGran.html&e=wqT_3QKSCKASBAAAAwDWAAUBCMmFp_AFEKTIuZTW4KGsERiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk3OTkzKTsBHTByJywgMTQ5NDE3OTUxNh8A8P2SArkCITFqdjBlZ2lta184UEVOX2ZuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCOXFZRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFXU1JOVU1OTk9jXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHBwUF9EN29EQ1ZOSlRqTTZORGN6TS1BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJmMGtxUVUJE0RBRHdQdy4umgKJASFTUTgtR3c2PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOek16UU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M9A4BZUFBLtgCAOACrZhI6gJOaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193X3ByaWNlR3Jhbi5odG1sgAMAiAMBkAMAmAMXoAMBqgMAwAPgqAHIAwDYAwDgAwDoAwD4AwGABACSBA0vdXQvdjMvcHJlYmlkmAQAogQNMjAyLjU5LjIzMS40N6gEr-YEsgQSCAEQAhiABSDgAygBKAIwADgDuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ3MzPaBAIIAOAEAPAE39-fR4gFAZgFAKAF____________AcAFAMkFAAAAAAAA8D_SBQkJAGlkdADYBQHgBQHwBay8FPoFBAgAEACQBgGYBgC4BgDBBgkkKPC_0Ab1L9oGFgoQCREZAVAQABgA4AYE8gYCCACABwGIBwCgB0A.&s=e9887c670ae9fcb7eb2a0253037c64c3587f4bcb', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=aAAAAAMArgAFAQnKwgleAAAAABEkZI5iBYdYERnJwgleAAAAACDf359HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1isvBRiAklOaAFwAXgAgAEBiAEBkAGABZgB4AOgAQCoAd_fn0ewAQE.&s=68a5c49da3a6ecf3dfc0835cb3da72b3b2c7b080&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149417951, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 33, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 30000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_priceGran.html&e=wqT_3QLuCOhuBAAAAwDWAAUBCMmFp_AFEKTIuZTW4KGsERiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQ39-fR1ic8VtgAGjNunV4w7gFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk3OTkzKTt1ZigncicsIDE0OTQxNzk1MSwgMTUZH_D9kgK5AiExanYwZWdpbWtfOFBFTl9mbjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQjlxWURrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBV1NSTlVNTk5PY18yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwcFBfRDdvRENWTkpUak02TkRjek0tQUR3aGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCZjBrcVFVCRNEQUR3UHcuLpoCiQEhU1E4LUd3Nj0BJG5QRmJJQVFvQUQVSFR1UURvSlUwbE9Nem8wTnpNelFNSVlTEXgMUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDPCaZUFBLtgCAOACrZhI6gJOaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193X3ByaWNlR3Jhbi5odG1s8gITCg9DVVNUT01fTU9ERUxfSUQSAPICGgoWQ1VTVE9NX01PREVMX0xFQUZfTkFNRRIA8gIeChpDVVNUT00RHQhBU1QBC_CQSUZJRUQSAIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIEDTIwMi41OS4yMzEuNDeoBK_mBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzMz2gQCCAHgBADwBGGCIIgFAZgFAKAF_xEBFAHABQDJBWmzFPA_0gUJCQkMeAAA2AUB4AUB8AWsvBT6BQQIABAAkAYBmAYAuAYAwQYJJSjwP9AG9S_aBhYKEAkRGQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=9514ae5f8aae1ee9dddd24dce3e812ae76e0e783' + } + } + }] + }, { + 'uuid': '2def02900a6cda', + 'tag_id': 15394006, + 'auction_id': '4278372095219023172', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_priceGran.html&e=wqT_3QKSCKASBAAAAwDWAAUBCMmFp_AFEMT65MOLmPWvOxiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk3OTkzKTsBHTByJywgMTQ5NDE4MTIzNh8A8P2SArkCIUxEeUhqUWlua184UEVJdmhuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCOXFZRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFaQWJScDluWS1FXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHA1UF9EN29EQ1ZOSlRqTTZORGN6TS1BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJmMGtxUVUJE0RBRHdQdy4umgKJASEtQTVuX2c2PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOek16UU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M9A4BZUFBLtgCAOACrZhI6gJOaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193X3ByaWNlR3Jhbi5odG1sgAMAiAMBkAMAmAMXoAMBqgMAwAPgqAHIAwDYAwDgAwDoAwD4AwGABACSBA0vdXQvdjMvcHJlYmlkmAQAogQNMjAyLjU5LjIzMS40N6gEr-YEsgQSCAEQAhiABSDgAygBKAIwADgDuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ3MzPaBAIIAOAEAPAEi-GfR4gFAZgFAKAF____________AcAFAMkFAAAAAAAA8D_SBQkJAGlkdADYBQHgBQHwBdrWAvoFBAgAEACQBgGYBgC4BgDBBgkkKPC_0Ab1L9oGFgoQCREZAVAQABgA4AYE8gYCCACABwGIBwCgB0A.&s=987d4bb0c7611d41b5974ec412469da2241084cd', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=aAAAAAMArgAFAQnKwgleAAAAABFEPXm4wNRfOxnJwgleAAAAACCL4Z9HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1ja1gJiAklOaAFwAXgAgAEBiAEBkAGABZgB4AOgAQCoAYvhn0ewAQE.&s=75aaa9ec84807690ceff60e39fbba6625240f9f3&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149418123, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 12, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 15000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_priceGran.html&e=wqT_3QLuCOhuBAAAAwDWAAUBCMmFp_AFEMT65MOLmPWvOxiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQi-GfR1ic8VtgAGjNunV4w7gFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk3OTkzKTt1ZigncicsIDE0OTQxODEyMywgMTUZH_D9kgK5AiFMRHlIalFpbmtfOFBFSXZobjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQjlxWURrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBWkFiUnA5blktRV8yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwNVBfRDdvRENWTkpUak02TkRjek0tQUR3aGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCZjBrcVFVCRNEQUR3UHcuLpoCiQEhLUE1bl9nNj0BJG5QRmJJQVFvQUQVSFR1UURvSlUwbE9Nem8wTnpNelFNSVlTEXgMUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDPCaZUFBLtgCAOACrZhI6gJOaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193X3ByaWNlR3Jhbi5odG1s8gITCg9DVVNUT01fTU9ERUxfSUQSAPICGgoWQ1VTVE9NX01PREVMX0xFQUZfTkFNRRIA8gIeChpDVVNUT00RHQhBU1QBC_CQSUZJRUQSAIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIEDTIwMi41OS4yMzEuNDeoBK_mBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzMz2gQCCAHgBADwBGGCIIgFAZgFAKAF_xEBFAHABQDJBWmzFPA_0gUJCQkMeAAA2AUB4AUB8AXa1gL6BQQIABAAkAYBmAYAuAYAwQYJJSjwP9AG9S_aBhYKEAkRGQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=9872a378866ce61fc366ca8c34bdd9302fa41a9b' + } + } + }] + }, { + 'uuid': '2def02900a6cda', + 'tag_id': 15394006, + 'auction_id': '8860024420878272196', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_priceGran.html&e=wqT_3QKRCKARBAAAAwDWAAUBCMmFp_AFEMSN8Z3LqMj6ehiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk3OTkzKTsBHTByJywgMTQ5NDE4NjcxNh8A8P2SArkCIU9EMjhLZ2lta184UEVLX2xuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCOXFZRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFkZExBS3hfN09nXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHBwUF9EN29EQ1ZOSlRqTTZORGN6TS1BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJmMGtxUVUJE0RBRHdQdy4umgKJASFIdzlLREE2PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOek16UU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M9A4BZUFBLtgCAOACrZhI6gJOaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193X3ByaWNlR3Jhbi5odG1sgAMAiAMBkAMAmAMXoAMBqgMAwAPgqAHIAwDYAwDgAwDoAwD4AwGABACSBA0vdXQvdjMvcHJlYmlkmAQAogQNMjAyLjU5LjIzMS40N6gEr-YEsgQSCAEQAhiABSDgAygBKAIwADgDuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ3MzPaBAIIAOAEAPAEr-WfR4gFAZgFAKAF____________AcAFAMkFAAAAAAAA8D_SBQkJAGlkcADYBQHgBQHwBeBY-gUECAAQAJAGAZgGALgGAMEGCSMo8L_QBvUv2gYWChAJERkBUBAAGADgBgTyBgIIAIAHAYgHAKAHQA..&s=1289862cbe265fd9af13d2aab9635e3232421ec1', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=ZwAAAAMArgAFAQnKwgleAAAAABHERryzRCH1ehnJwgleAAAAACCv5Z9HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1jgWGICSU5oAXABeACAAQGIAQGQAYAFmAHgA6ABAKgBr-WfR7ABAQ..&s=0b094204d5c18803149e081bd2bc0077d25ebb14&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149418671, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 30, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 30000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_priceGran.html&e=wqT_3QLtCOhtBAAAAwDWAAUBCMmFp_AFEMSN8Z3LqMj6ehiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQr-WfR1ic8VtgAGjNunV4w7gFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk3OTkzKTt1ZigncicsIDE0OTQxODY3MSwgMTUZH_D9kgK5AiFPRDI4S2dpbWtfOFBFS19sbjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQjlxWURrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBZGRMQUt4XzdPZ18yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwcFBfRDdvRENWTkpUak02TkRjek0tQUR3aGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCZjBrcVFVCRNEQUR3UHcuLpoCiQEhSHc5S0RBNj0BJG5QRmJJQVFvQUQVSFR1UURvSlUwbE9Nem8wTnpNelFNSVlTEXgMUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDPCaZUFBLtgCAOACrZhI6gJOaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193X3ByaWNlR3Jhbi5odG1s8gITCg9DVVNUT01fTU9ERUxfSUQSAPICGgoWQ1VTVE9NX01PREVMX0xFQUZfTkFNRRIA8gIeChpDVVNUT00RHQhBU1QBC_CQSUZJRUQSAIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIEDTIwMi41OS4yMzEuNDeoBK_mBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzMz2gQCCAHgBADwBGGCIIgFAZgFAKAF_xEBFAHABQDJBWmzFPA_0gUJCQkMdAAA2AUB4AUB8AXgWPoFBAgAEACQBgGYBgC4BgDBBgkkKPA_0Ab1L9oGFgoQCREZAVAQABgA4AYE8gYCCACABwGIBwCgB0A.&s=f35771975371bb250fd6701914534b4f595fcf68' + } + } + }] + }, { + 'uuid': '2def02900a6cda', + 'tag_id': 15394006, + 'auction_id': '5236733650551797458', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_priceGran.html&e=wqT_3QKRCKARBAAAAwDWAAUBCMmFp_AFENLt5YOosKfWSBiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk3OTkzKTsBHTByJywgMTQ5NDE4OTQ4Nh8A8P2SArkCIThUMjJsZ2lta184UEVNVG5uMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCOXFZRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFkczByb2Ytbk9VXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHBwUF9EN29EQ1ZOSlRqTTZORGN6TS1BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJmMGtxUVUJE0RBRHdQdy4umgKJASFOZzkxRkE2PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOek16UU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M9A4BZUFBLtgCAOACrZhI6gJOaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193X3ByaWNlR3Jhbi5odG1sgAMAiAMBkAMAmAMXoAMBqgMAwAPgqAHIAwDYAwDgAwDoAwD4AwGABACSBA0vdXQvdjMvcHJlYmlkmAQAogQNMjAyLjU5LjIzMS40N6gEr-YEsgQSCAEQAhiABSDgAygBKAIwADgDuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ3MzPaBAIIAOAEAPAExOefR4gFAZgFAKAF____________AcAFAMkFAAAAAAAA8D_SBQkJAGlkcADYBQHgBQHwBZk9-gUECAAQAJAGAZgGALgGAMEGCSMo8L_QBvUv2gYWChAJERkBUBAAGADgBgTyBgIIAIAHAYgHAKAHQA..&s=e997907677e4e2f9b641d51b522a901b85944899', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=ZwAAAAMArgAFAQnKwgleAAAAABHSdnmAgp2sSBnJwgleAAAAACDE559HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1iZPWICSU5oAXABeACAAQGIAQGQAYAFmAHgA6ABAKgBxOefR7ABAQ..&s=d70eef0df40cece50465a13d05a2dc11b65eadeb&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149418948, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 1, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 30000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_priceGran.html&e=wqT_3QLtCOhtBAAAAwDWAAUBCMmFp_AFENLt5YOosKfWSBiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQxOefR1ic8VtgAGjNunV4w7gFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk3OTkzKTt1ZigncicsIDE0OTQxODk0OCwgMTUZH_D9kgK5AiE4VDIybGdpbWtfOFBFTVRubjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQjlxWURrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBZHMwcm9mLW5PVV8yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwcFBfRDdvRENWTkpUak02TkRjek0tQUR3aGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCZjBrcVFVCRNEQUR3UHcuLpoCiQEhTmc5MUZBNj0BJG5QRmJJQVFvQUQVSFR1UURvSlUwbE9Nem8wTnpNelFNSVlTEXgMUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDPCaZUFBLtgCAOACrZhI6gJOaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193X3ByaWNlR3Jhbi5odG1s8gITCg9DVVNUT01fTU9ERUxfSUQSAPICGgoWQ1VTVE9NX01PREVMX0xFQUZfTkFNRRIA8gIeChpDVVNUT00RHQhBU1QBC_DtSUZJRUQSAIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIEDTIwMi41OS4yMzEuNDeoBK_mBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzMz2gQCCAHgBADwBMTnn0eIBQGYBQCgBf___________wHABQDJBQAAAAAAAPA_0gUJCQAAAAAAAAAA2AUB4AUB8AWZPfoFBAgAEACQBgGYBgC4BgDBBgAAAAAAAPA_0Ab1L9oGFgoQAGn1FQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=e8b6716ad3d2fcbdb79976f72d60f8e90ce8f5a6' + } + } + }] + }, { + 'uuid': '2def02900a6cda', + 'tag_id': 15394006, + 'auction_id': '4987762881548953446', + 'nobid': true, + 'ad_profile_id': 1182765 + }, { + 'uuid': '2def02900a6cda', + 'tag_id': 15394006, + 'auction_id': '201567478388503336', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_priceGran.html&e=wqT_3QKSCKASBAAAAwDWAAUBCMmFp_AFEKjm-NzbkYfmAhiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk3OTkzKTsBHTByJywgMTQ5NDE5NjAyNh8A8P2SArkCIXV6NlFDd2lua184UEVOTHNuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCOXFZRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFkejE5MUdLNk8wXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHA1UF9EN29EQ1ZOSlRqTTZORGN6TS1BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJmMGtxUVUJE0BBRHdQdy4umgKJASFTZy1SRzo9ASRuUEZiSUFRb0FEFUhUdVFEb0pVMGxPTXpvME56TXpRTUlZUxF4DFBBX1URDAxBQUFXHQwAWR0MAGEdDABjHQz0DgFlQUEu2AIA4AKtmEjqAk5odHRwOi8vdGVzdC5sb2NhbGhvc3Q6OTk5OS9pbnRlZ3JhdGlvbkV4YW1wbGVzL2xvbmdmb3JtL2Jhc2ljX3dfcHJpY2VHcmFuLmh0bWyAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My9wcmViaWSYBACiBA0yMDIuNTkuMjMxLjQ3qASv5gSyBBIIARACGIAFIOADKAEoAjAAOAO4BADABADIBADSBA45MzI1I1NJTjM6NDczM9oEAggA4AQA8ATS7J9HiAUBmAUAoAX___________8BwAUAyQUAAAAAAADwP9IFCQkAaWR0ANgFAeAFAfAF2boG-gUECAAQAJAGAZgGALgGAMEGCSQo8L_QBvUv2gYWChAJERkBUBAAGADgBgTyBgIIAIAHAYgHAKAHQA..&s=4a887316a3197dfae07c1443a4debc62a2f17fef', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=aAAAAAMArgAFAQnKwgleAAAAABEoM567jRzMAhnJwgleAAAAACDS7J9HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1jZugZiAklOaAFwAXgAgAEBiAEBkAGABZgB4AOgAQCoAdLsn0ewAQE.&s=eef6278d136f8df4879846840f97933e9d67388a&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149419602, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 24, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 15000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_priceGran.html&e=wqT_3QLuCOhuBAAAAwDWAAUBCMmFp_AFEKjm-NzbkYfmAhiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQ0uyfR1ic8VtgAGjNunV4w7gFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk3OTkzKTt1ZigncicsIDE0OTQxOTYwMiwgMTUZH_D9kgK5AiF1ejZRQ3dpbmtfOFBFTkxzbjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQjlxWURrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBZHoxOTFHSzZPMF8yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwNVBfRDdvRENWTkpUak02TkRjek0tQUR3aGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCZjBrcVFVCRNAQUR3UHcuLpoCiQEhU2ctUkc6PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOek16UU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M8JplQUEu2AIA4AKtmEjqAk5odHRwOi8vdGVzdC5sb2NhbGhvc3Q6OTk5OS9pbnRlZ3JhdGlvbkV4YW1wbGVzL2xvbmdmb3JtL2Jhc2ljX3dfcHJpY2VHcmFuLmh0bWzyAhMKD0NVU1RPTV9NT0RFTF9JRBIA8gIaChZDVVNUT01fTU9ERUxfTEVBRl9OQU1FEgDyAh4KGkNVU1RPTREdCEFTVAEL8JBJRklFRBIAgAMAiAMBkAMAmAMXoAMBqgMAwAPgqAHIAwDYAwDgAwDoAwD4AwGABACSBA0vdXQvdjMvcHJlYmlkmAQAogQNMjAyLjU5LjIzMS40N6gEr-YEsgQSCAEQAhiABSDgAygBKAIwADgDuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ3MzPaBAIIAeAEAPAEYYIgiAUBmAUAoAX_EQEUAcAFAMkFabMU8D_SBQkJCQx4AADYBQHgBQHwBdm6BvoFBAgAEACQBgGYBgC4BgDBBgklKPA_0Ab1L9oGFgoQCREZAVAQABgA4AYE8gYCCACABwGIBwCgB0A.&s=e68b089e4fc94aa7566784ccbff299e50c8bc090' + } + } + }] + }, { + 'uuid': '2def02900a6cda', + 'tag_id': 15394006, + 'auction_id': '3876520534914199302', + 'nobid': true, + 'ad_profile_id': 1182765 + }, { + 'uuid': '2def02900a6cda', + 'tag_id': 15394006, + 'auction_id': '4833995299234629234', + 'nobid': true, + 'ad_profile_id': 1182765 + }, { + 'uuid': '2def02900a6cda', + 'tag_id': 15394006, + 'auction_id': '8352235304492782614', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_priceGran.html&e=wqT_3QKSCKASBAAAAwDWAAUBCMmFp_AFEJaok6aeuMb0cxiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk3OTkzKTsBHTByJywgMTQ5NDE0MTg4Nh8A8P2SArkCIUpUMS1FZ2lHa184UEVLekNuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCOXFZRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFFajRyM1ZBQUFxUU1FQkktSzkxUUFBS2tESkFmQ1lIN1I1bmVzXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRGhwUF9EN29EQ1ZOSlRqTTZORGN6TS1BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJmMGtxUVUJE0RBRHdQdy4umgKJASExUTY4OFE2PQEkblBGYklBUW9BRBVIVHFRRG9KVTBsT016bzBOek16UU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M9A4BZUFBLtgCAOACrZhI6gJOaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193X3ByaWNlR3Jhbi5odG1sgAMAiAMBkAMAmAMXoAMBqgMAwAPgqAHIAwDYAwDgAwDoAwD4AwGABACSBA0vdXQvdjMvcHJlYmlkmAQAogQNMjAyLjU5LjIzMS40N6gEr-YEsgQSCAEQAhiABSDgAygBKAIwADgDuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ3MzPaBAIIAOAEAPAErMKfR4gFAZgFAKAF____________AcAFAMkFAAAAAAAA8D_SBQkJAGlkdADYBQHgBQHwBfKMAfoFBAgAEACQBgGYBgC4BgDBBgkkKPC_0Ab1L9oGFgoQCREZAVAQABgA4AYE8gYCCACABwGIBwCgB0A.&s=7081f4ad4ae9837aaff4b4f59abc4ce7f8b02cb6', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=aAAAAAMArgAFAQnKwgleAAAAABEW1MTkwRnpcxnJwgleAAAAACCswp9HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1jyjAFiAklOaAFwAXgAgAEBiAEBkAGABZgB4AOgAQCoAazCn0ewAQE.&s=71f281c81d1ae269bde275b84aa955c833ab1dea&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149414188, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 13.000010, + 'cpm_publisher_currency': 13.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 32, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 29000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_priceGran.html&e=wqT_3QLuCOhuBAAAAwDWAAUBCMmFp_AFEJaok6aeuMb0cxiq5MnUovf28WEqNgmOWItPAQAqQBGOWItPAQAqQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQrMKfR1ic8VtgAGjNunV4w7gFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk3OTkzKTt1ZigncicsIDE0OTQxNDE4OCwgMTUZH_D9kgK5AiFKVDEtRWdpR2tfOFBFS3pDbjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQjlxWURrQUVBbUFFQW9BRUJxQUVEc0FFQXVRRWo0cjNWQUFBcVFNRUJJLUs5MVFBQUtrREpBZkNZSDdSNW5lc18yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RocFBfRDdvRENWTkpUak02TkRjek0tQUR3aGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCZjBrcVFVCRNEQUR3UHcuLpoCiQEhMVE2ODhRNj0BJG5QRmJJQVFvQUQVSFRxUURvSlUwbE9Nem8wTnpNelFNSVlTEXgMUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDPCaZUFBLtgCAOACrZhI6gJOaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193X3ByaWNlR3Jhbi5odG1s8gITCg9DVVNUT01fTU9ERUxfSUQSAPICGgoWQ1VTVE9NX01PREVMX0xFQUZfTkFNRRIA8gIeChpDVVNUT00RHQhBU1QBC_CQSUZJRUQSAIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIEDTIwMi41OS4yMzEuNDeoBK_mBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzMz2gQCCAHgBADwBGGCIIgFAZgFAKAF_xEBFAHABQDJBWmzFPA_0gUJCQkMeAAA2AUB4AUB8AXyjAH6BQQIABAAkAYBmAYAuAYAwQYJJSjwP9AG9S_aBhYKEAkRGQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=05fc37623521011853ff69d194aa6d692b6c0504' + } + } + }] + }, { + 'uuid': '2def02900a6cda', + 'tag_id': 15394006, + 'auction_id': '2318891724556922037', + 'nobid': true, + 'ad_profile_id': 1182765 + }, { + 'uuid': '2def02900a6cda', + 'tag_id': 15394006, + 'auction_id': '5654583906891472332', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_priceGran.html&e=wqT_3QKSCKASBAAAAwDWAAUBCMmFp_AFEMy7oJeqw8e8Thiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk3OTkzKTsBHTByJywgMTQ5NDE3NjY5Nh8A8P2SArkCIXZ6Ml9mZ2lsa184UEVNWGRuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCOXFZRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIenJXcWtBQUFrUU1FQjg2MXFwQUFBSkVESkFhYzY5MFRlZi1rXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHBaUF9EN29EQ1ZOSlRqTTZORGN6TS1BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJmMGtxUVUJE0BBRHdQdy4umgKJASFJZzhjRDo9ASRuUEZiSUFRb0FEFUhUa1FEb0pVMGxPTXpvME56TXpRTUlZUxF4DFBBX1URDAxBQUFXHQwAWR0MAGEdDABjHQz0DgFlQUEu2AIA4AKtmEjqAk5odHRwOi8vdGVzdC5sb2NhbGhvc3Q6OTk5OS9pbnRlZ3JhdGlvbkV4YW1wbGVzL2xvbmdmb3JtL2Jhc2ljX3dfcHJpY2VHcmFuLmh0bWyAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My9wcmViaWSYBACiBA0yMDIuNTkuMjMxLjQ3qASv5gSyBBIIARACGIAFIOADKAEoAjAAOAO4BADABADIBADSBA45MzI1I1NJTjM6NDczM9oEAggA4AQA8ATF3Z9HiAUBmAUAoAX___________8BwAUAyQUAAAAAAADwP9IFCQkAaWR0ANgFAeAFAfAFwvIX-gUECAAQAJAGAZgGALgGAMEGCSQo8L_QBvUv2gYWChAJERkBUBAAGADgBgTyBgIIAIAHAYgHAKAHQA..&s=f929565158c7caa5b85e88fa456cdd04d0e4b6d8', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=aAAAAAMArgAFAQnKwgleAAAAABHMHeiiGh55ThnJwgleAAAAACDF3Z9HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1jC8hdiAklOaAFwAXgAgAEBiAEBkAGABZgB4AOgAQCoAcXdn0ewAQE.&s=a93773067b8588465b9c007e19970bd9e08c1b6c&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149417669, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 10.000000, + 'cpm_publisher_currency': 10.000000, + 'publisher_currency_code': '$', + 'brand_category_id': 4, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 30000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_priceGran.html&e=wqT_3QLuCKBuBAAAAwDWAAUBCMmFp_AFEMy7oJeqw8e8Thiq5MnUovf28WEqNgkAAAECCCRAEQEHEAAAJEAZCQkI4D8hCQkIJEApEQkAMQkJsOA_MNbJqwc47UhA7UhIAlDF3Z9HWJzxW2AAaM26dXjDuAWAAQGKAQNVU0SSAQEG8FWYAQGgAQGoAQGwAQC4AQPAAQTIAQLQAQDYAQDgAQDwAQCKAjx1ZignYScsIDI1Mjk4ODUsIDE1Nzc2OTc5OTMpO3VmKCdyJywgMTQ5NDE3NjY5LCAxNRkf8P2SArkCIXZ6Ml9mZ2lsa184UEVNWGRuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCOXFZRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIenJXcWtBQUFrUU1FQjg2MXFwQUFBSkVESkFhYzY5MFRlZi1rXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHBaUF9EN29EQ1ZOSlRqTTZORGN6TS1BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJmMGtxUVUJE0BBRHdQdy4umgKJASFJZzhjRDo9ASRuUEZiSUFRb0FEFUhUa1FEb0pVMGxPTXpvME56TXpRTUlZUxF4DFBBX1URDAxBQUFXHQwAWR0MAGEdDABjHQzwmmVBQS7YAgDgAq2YSOoCTmh0dHA6Ly90ZXN0LmxvY2FsaG9zdDo5OTk5L2ludGVncmF0aW9uRXhhbXBsZXMvbG9uZ2Zvcm0vYmFzaWNfd19wcmljZUdyYW4uaHRtbPICEwoPQ1VTVE9NX01PREVMX0lEEgDyAhoKFkNVU1RPTV9NT0RFTF9MRUFGX05BTUUSAPICHgoaQ1VTVE9NER0IQVNUAQvwkElGSUVEEgCAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My9wcmViaWSYBACiBA0yMDIuNTkuMjMxLjQ3qASv5gSyBBIIARACGIAFIOADKAEoAjAAOAO4BADABADIBADSBA45MzI1I1NJTjM6NDczM9oEAggB4AQA8ARhgiCIBQGYBQCgBf8RARQBwAUAyQVpsxTwP9IFCQkJDHgAANgFAeAFAfAFwvIX-gUECAAQAJAGAZgGALgGAMEGCSUo8D_QBvUv2gYWChAJERkBUBAAGADgBgTyBgIIAIAHAYgHAKAHQA..&s=a3a24cbf148bb959f539e883af3d118f64e81bc9' + } + } + }] + }, { + 'uuid': '2def02900a6cda', + 'tag_id': 15394006, + 'auction_id': '2268711976967571175', + 'nobid': true, + 'ad_profile_id': 1182765 + }, { + 'uuid': '2def02900a6cda', + 'tag_id': 15394006, + 'auction_id': '8379392370800588084', + 'nobid': true, + 'ad_profile_id': 1182765 + }, { + 'uuid': '2def02900a6cda', + 'tag_id': 15394006, + 'auction_id': '6225030428438795793', + 'nobid': true, + 'ad_profile_id': 1182765 + }, { + 'uuid': '2def02900a6cda', + 'tag_id': 15394006, + 'auction_id': '1592368529919250324', + 'nobid': true, + 'ad_profile_id': 1182765 + }] + } + } + } +} diff --git a/test/mock-server/expectations/request-response-pairs/longform/price_gran_request_2.js b/test/mock-server/expectations/request-response-pairs/longform/price_gran_request_2.js new file mode 100644 index 00000000000..5a716c6e8e9 --- /dev/null +++ b/test/mock-server/expectations/request-response-pairs/longform/price_gran_request_2.js @@ -0,0 +1,283 @@ +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 + * + */ + +/** + * 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': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 15394006, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'require_asset_url': true, + 'video': { + 'maxduration': 30 + } + }], + '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': '2def02900a6cda', + 'tag_id': 15394006, + 'auction_id': '6123799897847039642', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_priceGran.html&e=wqT_3QKRCKARBAAAAwDWAAUBCMmFp_AFEJqN_JX98Yb-VBiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk3OTkzKTsBHTByJywgMTQ5NDE4NjcxNh8A8P2SArkCIUN6dzV3Z2lta184UEVLX2xuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCOXFZRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFYQm5aNWdRbi1NXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHBwUF9EN29EQ1ZOSlRqTTZORGMwTS1BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJZY2xxUVUJE0RBRHdQdy4umgKJASFJQS1IREE2PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOelF6UU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M9A4BZUFBLtgCAOACrZhI6gJOaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193X3ByaWNlR3Jhbi5odG1sgAMAiAMBkAMAmAMXoAMBqgMAwAPgqAHIAwDYAwDgAwDoAwD4AwGABACSBA0vdXQvdjMvcHJlYmlkmAQAogQNMjAyLjU5LjIzMS40N6gEr-YEsgQSCAEQAhiABSDgAygBKAIwADgDuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ3NDPaBAIIAOAEAPAEr-WfR4gFAZgFAKAF____________AcAFAMkFAAAAAAAA8D_SBQkJAGlkcADYBQHgBQHwBeBY-gUECAAQAJAGAZgGALgGAMEGCSMo8L_QBvUv2gYWChAJERkBUBAAGADgBgTyBgIIAIAHAYgHAKAHQA..&s=a7e4ff14c60153db90971365f90e514f45875324', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=ZwAAAAMArgAFAQnJwgleAAAAABGaBr_Sjxv8VBnJwgleAAAAACCv5Z9HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1jgWGICSU5oAXABeACAAQGIAQGQAYAFmAHgA6ABAKgBr-WfR7ABAQ..&s=842283d9de78fba7e92fac09f95bb63902a0b54a&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149418671, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 30, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 30000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_priceGran.html&e=wqT_3QLtCOhtBAAAAwDWAAUBCMmFp_AFEJqN_JX98Yb-VBiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQr-WfR1ic8VtgAGjNunV4zrgFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk3OTkzKTt1ZigncicsIDE0OTQxODY3MSwgMTUZH_D9kgK5AiFDenc1d2dpbWtfOFBFS19sbjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQjlxWURrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBWEJuWjVnUW4tTV8yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwcFBfRDdvRENWTkpUak02TkRjME0tQUR3aGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCWWNscVFVCRNEQUR3UHcuLpoCiQEhSUEtSERBNj0BJG5QRmJJQVFvQUQVSFR1UURvSlUwbE9Nem8wTnpRelFNSVlTEXgMUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDPCaZUFBLtgCAOACrZhI6gJOaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193X3ByaWNlR3Jhbi5odG1s8gITCg9DVVNUT01fTU9ERUxfSUQSAPICGgoWQ1VTVE9NX01PREVMX0xFQUZfTkFNRRIA8gIeChpDVVNUT00RHQhBU1QBC_CQSUZJRUQSAIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIEDTIwMi41OS4yMzEuNDeoBK_mBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzQz2gQCCAHgBADwBGGCIIgFAZgFAKAF_xEBFAHABQDJBWmzFPA_0gUJCQkMdAAA2AUB4AUB8AXgWPoFBAgAEACQBgGYBgC4BgDBBgkkKPA_0Ab1L9oGFgoQCREZAVAQABgA4AYE8gYCCACABwGIBwCgB0A.&s=0fb74d544be103e1440c3ee8f7abc14d2c322d15' + } + } + }] + }, { + 'uuid': '2def02900a6cda', + 'tag_id': 15394006, + 'auction_id': '889501690217653627', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_priceGran.html&e=wqT_3QKSCKASBAAAAwDWAAUBCMmFp_AFEPvKoYSxoomsDBiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk3OTkzKTsBHTByJywgMTQ5NDE5NjAyNh8A8P2SArkCIWt6eTlHUWlua184UEVOTHNuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCOXFZRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFRSzgzNzR1VnVVXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHA1UF9EN29EQ1ZOSlRqTTZORGMwTS1BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJZY2xxUVUJE0RBRHdQdy4umgKJASFTd19PR3c2PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOelF6UU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M9A4BZUFBLtgCAOACrZhI6gJOaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193X3ByaWNlR3Jhbi5odG1sgAMAiAMBkAMAmAMXoAMBqgMAwAPgqAHIAwDYAwDgAwDoAwD4AwGABACSBA0vdXQvdjMvcHJlYmlkmAQAogQNMjAyLjU5LjIzMS40N6gEr-YEsgQSCAEQAhiABSDgAygBKAIwADgDuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ3NDPaBAIIAOAEAPAE0uyfR4gFAZgFAKAF____________AcAFAMkFAAAAAAAA8D_SBQkJAGlkdADYBQHgBQHwBdm6BvoFBAgAEACQBgGYBgC4BgDBBgkkKPC_0Ab1L9oGFgoQCREZAVAQABgA4AYE8gYCCACABwGIBwCgB0A.&s=78ac70aeeae1da43c90efd248fb30a4ee630ffd5', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=aAAAAAMArgAFAQnJwgleAAAAABF7ZYgQEyVYDBnJwgleAAAAACDS7J9HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1jZugZiAklOaAFwAXgAgAEBiAEBkAGABZgB4AOgAQCoAdLsn0ewAQE.&s=f21e2a522ddcaf0a67bc7d52f70288fdf7e6f3dd&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149419602, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 24, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 15000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_priceGran.html&e=wqT_3QLuCOhuBAAAAwDWAAUBCMmFp_AFEPvKoYSxoomsDBiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQ0uyfR1ic8VtgAGjNunV4zrgFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk3OTkzKTt1ZigncicsIDE0OTQxOTYwMiwgMTUZH_D9kgK5AiFrenk5R1FpbmtfOFBFTkxzbjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQjlxWURrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBUUs4Mzc0dVZ1VV8yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwNVBfRDdvRENWTkpUak02TkRjME0tQUR3aGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCWWNscVFVCRNEQUR3UHcuLpoCiQEhU3dfT0d3Nj0BJG5QRmJJQVFvQUQVSFR1UURvSlUwbE9Nem8wTnpRelFNSVlTEXgMUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDPCaZUFBLtgCAOACrZhI6gJOaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193X3ByaWNlR3Jhbi5odG1s8gITCg9DVVNUT01fTU9ERUxfSUQSAPICGgoWQ1VTVE9NX01PREVMX0xFQUZfTkFNRRIA8gIeChpDVVNUT00RHQhBU1QBC_CQSUZJRUQSAIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIEDTIwMi41OS4yMzEuNDeoBK_mBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzQz2gQCCAHgBADwBGGCIIgFAZgFAKAF_xEBFAHABQDJBWmzFPA_0gUJCQkMeAAA2AUB4AUB8AXZugb6BQQIABAAkAYBmAYAuAYAwQYJJSjwP9AG9S_aBhYKEAkRGQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=69611db1024ddb77e0754087ddbeae68a00633a1' + } + } + }] + }, { + 'uuid': '2def02900a6cda', + 'tag_id': 15394006, + 'auction_id': '2793012314322059080', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_priceGran.html&e=wqT_3QKSCKASBAAAAwDWAAUBCMmFp_AFEMj-1IPuvLHhJhiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk3OTkzKTsBHTByJywgMTQ5NDE0MTg4Nh8A8P2SArkCIXhqb2ZBZ2lHa184UEVLekNuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCOXFZRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFFajRyM1ZBQUFxUU1FQkktSzkxUUFBS2tESkFRQWhlSGt0VHVRXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRGhwUF9EN29EQ1ZOSlRqTTZORGMwTS1BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJZY2xxUVUJE0RBRHdQdy4umgKJASExZzc1OFE2PQEkblBGYklBUW9BRBVIVHFRRG9KVTBsT016bzBOelF6UU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M9A4BZUFBLtgCAOACrZhI6gJOaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193X3ByaWNlR3Jhbi5odG1sgAMAiAMBkAMAmAMXoAMBqgMAwAPgqAHIAwDYAwDgAwDoAwD4AwGABACSBA0vdXQvdjMvcHJlYmlkmAQAogQNMjAyLjU5LjIzMS40N6gEr-YEsgQSCAEQAhiABSDgAygBKAIwADgDuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ3NDPaBAIIAOAEAPAErMKfR4gFAZgFAKAF____________AcAFAMkFAAAAAAAA8D_SBQkJAGlkdADYBQHgBQHwBfKMAfoFBAgAEACQBgGYBgC4BgDBBgkkKPC_0Ab1L9oGFgoQCREZAVAQABgA4AYE8gYCCACABwGIBwCgB0A.&s=243f58d85b09468de2fe485662c950a86b5d90fb', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=aAAAAAMArgAFAQnJwgleAAAAABFIP3Xg5sXCJhnJwgleAAAAACCswp9HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1jyjAFiAklOaAFwAXgAgAEBiAEBkAGABZgB4AOgAQCoAazCn0ewAQE.&s=99dd40ab6ae736c6aa7c96b5319e1723ea581e0d&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149414188, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 13.000010, + 'cpm_publisher_currency': 13.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 32, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 29000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_priceGran.html&e=wqT_3QLuCOhuBAAAAwDWAAUBCMmFp_AFEMj-1IPuvLHhJhiq5MnUovf28WEqNgmOWItPAQAqQBGOWItPAQAqQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQrMKfR1ic8VtgAGjNunV4zrgFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk3OTkzKTt1ZigncicsIDE0OTQxNDE4OCwgMTUZH_D9kgK5AiF4am9mQWdpR2tfOFBFS3pDbjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQjlxWURrQUVBbUFFQW9BRUJxQUVEc0FFQXVRRWo0cjNWQUFBcVFNRUJJLUs5MVFBQUtrREpBUUFoZUhrdFR1UV8yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RocFBfRDdvRENWTkpUak02TkRjME0tQUR3aGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCWWNscVFVCRNEQUR3UHcuLpoCiQEhMWc3NThRNj0BJG5QRmJJQVFvQUQVSFRxUURvSlUwbE9Nem8wTnpRelFNSVlTEXgMUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDPCaZUFBLtgCAOACrZhI6gJOaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkvaW50ZWdyYXRpb25FeGFtcGxlcy9sb25nZm9ybS9iYXNpY193X3ByaWNlR3Jhbi5odG1s8gITCg9DVVNUT01fTU9ERUxfSUQSAPICGgoWQ1VTVE9NX01PREVMX0xFQUZfTkFNRRIA8gIeChpDVVNUT00RHQhBU1QBC_CQSUZJRUQSAIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIEDTIwMi41OS4yMzEuNDeoBK_mBLIEEggBEAIYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzQz2gQCCAHgBADwBGGCIIgFAZgFAKAF_xEBFAHABQDJBWmzFPA_0gUJCQkMeAAA2AUB4AUB8AXyjAH6BQQIABAAkAYBmAYAuAYAwQYJJSjwP9AG9S_aBhYKEAkRGQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=d9a3c817696f263b6e6d81f7251827fa54a47c37' + } + } + }] + }, { + 'uuid': '2def02900a6cda', + 'tag_id': 15394006, + 'auction_id': '45194178065897765', + 'nobid': true, + 'ad_profile_id': 1182765 + }, { + 'uuid': '2def02900a6cda', + 'tag_id': 15394006, + 'auction_id': '3805126675549039795', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_priceGran.html&e=wqT_3QKSCKASBAAAAwDWAAUBCMmFp_AFELPZ2uvQ0aHnNBiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQjgPyEJCQgAACkRCQAxCQnwaeA_MNbJqwc47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEDwAEAyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk3OTkzKTsBHTByJywgMTQ5NDE4MTIzNh8A8P2SArkCIWNUM1hkZ2lua184UEVJdmhuMGNZQUNDYzhWc3dBRGdBUUFSSTdVaFExc21yQjFnQVlJSUNhQUJ3QUhnQWdBSElBb2dCOXFZRGtBRUFtQUVBb0FFQnFBRURzQUVBdVFIdEJLRDJBQUF1UU1FQjdRU2c5Z0FBTGtESkFjbUQzMExTME9VXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFPQUNBT2dDQVBnQ0FJQURBWmdEQWFnRHA1UF9EN29EQ1ZOSlRqTTZORGMwTS1BRHdoaUlCQUNRQkFDWUJBSEJCQUFBQQ1yCHlRUQ0KJEFBQU5nRUFQRUUBCwkBMEQ0QkFDSUJZY2xxUVUJE0BBRHdQdy4umgKJASEtUTZrXzo9ASRuUEZiSUFRb0FEFUhUdVFEb0pVMGxPTXpvME56UXpRTUlZUxF4DFBBX1URDAxBQUFXHQwAWR0MAGEdDABjHQz0DgFlQUEu2AIA4AKtmEjqAk5odHRwOi8vdGVzdC5sb2NhbGhvc3Q6OTk5OS9pbnRlZ3JhdGlvbkV4YW1wbGVzL2xvbmdmb3JtL2Jhc2ljX3dfcHJpY2VHcmFuLmh0bWyAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My9wcmViaWSYBACiBA0yMDIuNTkuMjMxLjQ3qASv5gSyBBIIARACGIAFIOADKAEoAjAAOAO4BADABADIBADSBA45MzI1I1NJTjM6NDc0M9oEAggA4AQA8ASL4Z9HiAUBmAUAoAX___________8BwAUAyQUAAAAAAADwP9IFCQkAaWR0ANgFAeAFAfAF2tYC-gUECAAQAJAGAZgGALgGAMEGCSQo8L_QBvUv2gYWChAJERkBUBAAGADgBgTyBgIIAIAHAYgHAKAHQA..&s=bbeaa584bea9afedf6dcab51b1616988441dfa22', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'https://sin3-ib.adnxs.com/vast_track/v2?info=aAAAAAMArgAFAQnJwgleAAAAABGzrHYNjYbONBnJwgleAAAAACCL4Z9HKAAw7Ug47UhA0-hISLuv1AFQ1smrB1ja1gJiAklOaAFwAXgAgAEBiAEBkAGABZgB4AOgAQCoAYvhn0ewAQE.&s=b7e937b5acc3d8b910f6b08c3a40e04aa10818cd&event_type=1', + 'usersync_url': 'https%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 149418123, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 15.000010, + 'cpm_publisher_currency': 15.000010, + 'publisher_currency_code': '$', + 'brand_category_id': 12, + 'client_initiated_ad_counting': true, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 15000, + 'playback_methods': ['auto_play_sound_on'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'asset_url': 'https://sin3-ib.adnxs.com/ab?ro=1&an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2FintegrationExamples%2Flongform%2Fbasic_w_priceGran.html&e=wqT_3QLuCOhuBAAAAwDWAAUBCMmFp_AFELPZ2uvQ0aHnNBiq5MnUovf28WEqNgmOWItPAQAuQBGOWItPAQAuQBkAAAECCOA_IREbACkRCQAxARm4AADgPzDWyasHOO1IQO1ISAJQi-GfR1ic8VtgAGjNunV4zrgFgAEBigEDVVNEkgEBBvBVmAEBoAEBqAEBsAEAuAEDwAEEyAEC0AEA2AEA4AEA8AEAigI8dWYoJ2EnLCAyNTI5ODg1LCAxNTc3Njk3OTkzKTt1ZigncicsIDE0OTQxODEyMywgMTUZH_D9kgK5AiFjVDNYZGdpbmtfOFBFSXZobjBjWUFDQ2M4VnN3QURnQVFBUkk3VWhRMXNtckIxZ0FZSUlDYUFCd0FIZ0FnQUhJQW9nQjlxWURrQUVBbUFFQW9BRUJxQUVEc0FFQXVRSHRCS0QyQUFBdVFNRUI3UVNnOWdBQUxrREpBY21EMzBMUzBPVV8yUUVBQUFBQUFBRHdQLUFCQVBVQkFBQUFBSmdDQUtBQ0FMVUNBQUFBQUwwQ0FBQUFBT0FDQU9nQ0FQZ0NBSUFEQVpnREFhZ0RwNVBfRDdvRENWTkpUak02TkRjME0tQUR3aGlJQkFDUUJBQ1lCQUhCQkFBQUENcgh5UVENCiRBQUFOZ0VBUEVFAQsJATBENEJBQ0lCWWNscVFVCRNAQUR3UHcuLpoCiQEhLVE2a186PQEkblBGYklBUW9BRBVIVHVRRG9KVTBsT016bzBOelF6UU1JWVMReAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M8JplQUEu2AIA4AKtmEjqAk5odHRwOi8vdGVzdC5sb2NhbGhvc3Q6OTk5OS9pbnRlZ3JhdGlvbkV4YW1wbGVzL2xvbmdmb3JtL2Jhc2ljX3dfcHJpY2VHcmFuLmh0bWzyAhMKD0NVU1RPTV9NT0RFTF9JRBIA8gIaChZDVVNUT01fTU9ERUxfTEVBRl9OQU1FEgDyAh4KGkNVU1RPTREdCEFTVAEL8N5JRklFRBIAgAMAiAMBkAMAmAMXoAMBqgMAwAPgqAHIAwDYAwDgAwDoAwD4AwGABACSBA0vdXQvdjMvcHJlYmlkmAQAogQNMjAyLjU5LjIzMS40N6gEr-YEsgQSCAEQAhiABSDgAygBKAIwADgDuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ3NDPaBAIIAeAEAPAEi-GfR4gFAZgFAKAF____________AcAFAMkFAAAAAAAA8D_SBQkJAAAAAAAAAADYBQHgBQHwBdrWAvoFBAgAEACQBgGYBgC4BgDBBgAAYeYo8D_QBvUv2gYWChABDy4BAFAQABgA4AYE8gYCCACABwGIBwCgB0A.&s=279827127eba3204bc3a152b8abaf701260eb494' + } + } + }] + }] + } + } + } +} diff --git a/test/mock-server/expectations/request-response-pairs/multiple-bidders/index-1.js b/test/mock-server/expectations/request-response-pairs/multiple-bidders/index-1.js new file mode 100644 index 00000000000..9c4128fc004 --- /dev/null +++ b/test/mock-server/expectations/request-response-pairs/multiple-bidders/index-1.js @@ -0,0 +1,110 @@ +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 + * + */ + +/** + * 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': 1, + 'height': 1 + }], + 'ad_types': ['native'], + 'id': 13232392, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'native': { + 'layouts': [{ + 'title': { + 'required': true + }, + 'main_image': { + 'required': true + }, + 'sponsored_by': { + 'required': 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': '256e5e4b136d05', + 'tag_id': 13232392, + 'auction_id': '6287559286677633407', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2Ftest%2Fpages%2Fmultiple_bidders.html%3Fpbjs_debug%3Dtrue&e=wqT_3QKICKAIBAAAAwDWAAUBCM3FpfEFEP_yg9W7u_mgVxi7_-bKzp3kuD8qNgkAAAkCABEJBwgAABkJCQgkQCEJCQgAACkRCQAxCQnwaSRAMIjSpwY47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEBwAEAyAEC0AEA2AEA4AEA8AEAigI7dWYoJ2EnLCAyNTI5ODg1LCAxNTc5NzcwNTczKTsBHSxyJywgOTc1MjA0MzQ2HgDw0JICtQIhQWp4NUh3aUgtYndLRUxLV3dDNFlBQ0NjOFZzd0FEZ0FRQVJJN1VoUWlOS25CbGdBWUtzR2FBQndBbmlLQVlBQkhvZ0JpZ0dRQVFDWUFRQ2dBUUdvQVFPd0FRQzVBZk90YXFRQUFDUkF3UUh6cldxa0FBQWtRTWtCb2FZc1BwVDM0VF9aQVFBQUFBQUFBUEFfNEFFQTlRRUFBQUFBbUFJQW9BSUF0UUlBQUFBQXZRSUFBQUFBNEFJQTZBSUEtQUlBZ0FNQm1BTUJxQU9IAcSIdWdNSlUwbE9Nem8wT0RRMDRBUDRHWWdFQUpBRUFKZ0VBY0UJXQUBCERKQgUICQEYMkFRQThRUQkNAQEsUGdFQUlnRjdDV3BCERc0UEFfmgKJASFDZy1TX2c2OQEkblBGYklBUW9BRBVkDGtRRG8ykQAQUVBnWlMdTQBVEQwMQUFBVx0MAFkdDABhHQwAYx0MoGVBQS7YAgDgAq2YSOoCS2h0dHA6Ly90ZXN0LmxvY2FsaG9zdDo5OTk5BRTw3i9wYWdlcy9tdWx0aXBsZV9iaWRkZXJzLmh0bWw_cGJqc19kZWJ1Zz10cnVlgAMAiAMBkAMAmAMXoAMBqgMAwAPgqAHIAwDYAwDgAwDoAwD4AwGABACSBA0vdXQvdjMvcHJlYmlkmAQAogQOMTAzLjc5LjEwMC4xODCoBOZCsgQQCAQQARgAIAAoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0ODQ02gQCCADgBAHwBLKWwC6IBQGYBQCgBf___________wHABQDJBQAAAAAAAPA_0gUJCQAAAAABDnDYBQHgBQHwBZn0IfoFBAgAEACQBgGYBgC4BgDBBgEhMAAA8L_QBvUv2gYWChAJERkBUBAAGADgBgzyBgIIAIAHAYgHAKAHQQ..&s=8b14b952b73092945ef66436be991786b53f7a68', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'native', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 97520434, + 'media_type_id': 12, + 'media_subtype_id': 65, + 'cpm': 10.000000, + 'cpm_publisher_currency': 10.000000, + 'publisher_currency_code': '$', + 'brand_category_id': 53, + 'client_initiated_ad_counting': true, + 'viewability': { + 'config': '' + }, + 'rtb': { + 'native': { + 'title': 'This is a Prebid Native Creative', + 'sponsored': 'Prebid.org', + 'main_img': { + 'url': 'https://vcdn.adnxs.com/p/creative-image/f8/7f/0f/13/f87f0f13-230c-4f05-8087-db9216e393de.jpg', + 'width': 989, + 'height': 742, + 'prevent_crop': false + }, + 'link': { + 'url': 'http://prebid.org/dev-docs/show-multi-format-ads.html', + 'click_trackers': ['https://sin3-ib.adnxs.com/click?AAAAAAAAJEAAAAAAAAAkQAAAAAAAACRAAAAAAAAAJEAAAAAAAAAkQH_5oLrb5UFXu79Z6eyQcT_NYileAAAAAAjpyQBtJAAAbSQAAAIAAAAyC9AFnPgWAAAAAABVU0QAVVNEAAEAAQBNXQAAAAABAQQCAAAAALoAnRbC8wAAAAA./bcr=AAAAAAAA8D8=/cnd=%21Cg-S_giH-bwKELKWwC4YnPFbIAQoADEAAAAAAAAkQDoJU0lOMzo0ODQ0QPgZSQAAAAAAAPA_UQAAAAAAAAAAWQAAAAAAAAAAYQAAAAAAAAAAaQAAAAAAAAAAcQAAAAAAAAAAeAA./cca=OTMyNSNTSU4zOjQ4NDQ=/bn=89112/'] + }, + 'impression_trackers': ['https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2Ftest%2Fpages%2Fmultiple_bidders.html%3Fpbjs_debug%3Dtrue&e=wqT_3QKQCKAQBAAAAwDWAAUBCM3FpfEFEP_yg9W7u_mgVxi7_-bKzp3kuD8qNgkAAAECCCRAEQEHEAAAJEAZEQkAIREJACkRCQAxEQmoMIjSpwY47UhA7UhIAlCylsAuWJzxW2AAaM26dXiYuAWAAQGKAQNVU0SSAQEG8FKYAQGgAQGoAQGwAQC4AQHAAQTIAQLQAQDYAQDgAQDwAQCKAjt1ZignYScsIDI1Mjk4ODUsIDE1Nzk3NzA1NzMpO3VmKCdyJywgOTc1MjA0MzQsIC4eAPDQkgK1AiFBang1SHdpSC1id0tFTEtXd0M0WUFDQ2M4VnN3QURnQVFBUkk3VWhRaU5LbkJsZ0FZS3NHYUFCd0FuaUtBWUFCSG9nQmlnR1FBUUNZQVFDZ0FRR29BUU93QVFDNUFmT3RhcVFBQUNSQXdRSHpyV3FrQUFBa1FNa0JvYVlzUHBUMzRUX1pBUUFBQUFBQUFQQV80QUVBOVFFQUFBQUFtQUlBb0FJQXRRSUFBQUFBdlFJQUFBQUE0QUlBNkFJQS1BSUFnQU1CbUFNQnFBT0gBxIh1Z01KVTBsT016bzBPRFEwNEFQNEdZZ0VBSkFFQUpnRUFjRQldBQEIREpCBQgJARgyQVFBOFFRCQ0BASxQZ0VBSWdGN0NXcEIRFzRQQV-aAokBIUNnLVNfZzY5ASRuUEZiSUFRb0FEFWQMa1FEbzKRABBRUGdaUx1NAFURDAxBQUFXHQwAWR0MAGEdDABjHQygZUFBLtgCAOACrZhI6gJLaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkFFPDeL3BhZ2VzL211bHRpcGxlX2JpZGRlcnMuaHRtbD9wYmpzX2RlYnVnPXRydWWAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My9wcmViaWSYBACiBA4xMDMuNzkuMTAwLjE4MKgE5kKyBBAIBBABGAAgACgBKAIwADgDuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ4NDTaBAIIAeAEAfAEspbALogFAZgFAKAF____________AcAFAMkFAAAAAAAA8D_SBQkJAAAAAAEOcNgFAeAFAfAFmfQh-gUECAAQAJAGAZgGALgGAMEGASEwAADwP9AG9S_aBhYKEAkRGQFQEAAYAOAGDPIGAggAgAcBiAcAoAdB&s=2061bd85ce022a41bc16ebb20c193aabbbc07809'], + 'id': 97520434 + } + } + }] + }] + } + } + } +} diff --git a/test/mock-server/expectations/request-response-pairs/multiple-bidders/index-2.js b/test/mock-server/expectations/request-response-pairs/multiple-bidders/index-2.js new file mode 100644 index 00000000000..d3c8e8ea376 --- /dev/null +++ b/test/mock-server/expectations/request-response-pairs/multiple-bidders/index-2.js @@ -0,0 +1,175 @@ +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 + * + */ + +/** + * 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': 13232392, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true + }, { + 'sizes': [{ + 'width': 1, + 'height': 1 + }], + 'ad_types': ['native'], + 'id': 13232354, + 'allow_smaller_sizes': true, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'native': { + 'layouts': [{ + 'title': { + 'required': true + }, + 'description': { + 'required': true + }, + 'main_image': { + 'required': true + }, + 'sponsored_by': { + 'required': true + }, + 'icon': { + 'required': false + } + }] + } + }], + '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': '28ae233df319a1', + 'tag_id': 13232392, + 'auction_id': '6917498423334366136', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2Ftest%2Fpages%2Fmultiple_bidders.html%3Fpbjs_debug%3Dtrue&e=wqT_3QLBCKBBBAAAAwDWAAUBCNGcpvEFELjXrYmmhfn_Xxi7_-bKzp3kuD8qNgkAAAkCABEJBwgAABkJCQgkQCEJCQgAACkRCQAxCQn0gQEkQDCI0qcGOO1IQO1ISABQAFic8VtgAGjNunV4AIABAYoBAJIBA1VTRJgBrAKgAfoBqAEBsAEAuAEBwAEAyAEC0AEA2AEA4AEA8AEAigI7dWYoJ2EnLCAyNTI5ODg1LCAxNTc5NzgxNzEzKTt1ZigncicsIDk2ODQ2MDM1LCAxNTc5NzgxNzEzKTuSArUCITZEb2NyZ2lILWJ3S0VOT0JseTRZQUNDYzhWc3dBRGdBUUFSSTdVaFFpTktuQmxnQVlLc0dhQUJ3R25oaWdBR1lBWWdCWXBBQkFKZ0JBS0FCQWFnQkE3QUJBTGtCODYxcXBBQUFKRURCQWZPdGFxUUFBQ1JBeVFHQ1VBT2x6Q0xkUDlrQkFBQUFBQUFBOERfZ0FRRDFBUUFBQUFDWUFnQ2dBZ0MxQWdBQUFBQzlBZ0FBQUFEZ0FnRG9BZ0Q0QWdDQUF3R1lBd0dvQTRmNXZBcTZBd2xUU1U0ek9qUTNNem5nQV9nWmlBUUFrQVFBbUFRQndRUQFNCQEITWtFCQkBARhEWUJBRHhCAQsNASwtQVFBaUFXREpha0YNE0BBOEQ4LpoCiQEhOEE1YjlRaTI5ASRuUEZiSUFRb0FEFVhYa1FEb0pVMGxPTXpvME56TTVRUGdaU1ENTwxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M8EZlQUEuwgI1aHR0cDovL3ByZWJpZC5vcmcvZGV2LWRvY3Mvc2hvdy1tdWx0aS1mb3JtYXQtYWRzLmh0bWzYAgDgAq2YSOoCSw1ASHRlc3QubG9jYWxob3N0Ojk5OTkFFBgvcGFnZXMvBUYocGxlX2JpZGRlcnMFRvBAP3BianNfZGVidWc9dHJ1ZYADAIgDAZADAJgDF6ADAaoDAMADrALIAwDYAwDgAwDoAwD4AwGABACSBA0vdXQvdjMNtvBhmAQAogQOMTAzLjc5LjEwMC4xODCoBJ9EsgQSCAQQARisAiD6ASgBKAIwADgDuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ3MznaBAIIAOAEAfAE04GXLogFAZgFAKAF______8BAxQBwAUAyQVpiBTwP9IFCQkJDHAAANgFAeAFAfAFAfoFBAgAEACQBgCYBgC4BgDBBgkjKPC_0Ab1L9oGFgoQCREZAVAQABgA4AYB8gYCCACABwGIBwCgBwE.&s=8d42ac30ca2d2a8a63215f5aba2a43bd23af0023', + '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': 10.000000, + 'cpm_publisher_currency': 10.000000, + 'publisher_currency_code': '$', + 'brand_category_id': 0, + 'client_initiated_ad_counting': true, + 'rtb': { + 'banner': { + 'content': "
", + 'width': 300, + 'height': 250 + }, + 'trackers': [{ + 'impression_urls': ['https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2Ftest%2Fpages%2Fmultiple_bidders.html%3Fpbjs_debug%3Dtrue&e=wqT_3QLJCKBJBAAAAwDWAAUBCNGcpvEFELjXrYmmhfn_Xxi7_-bKzp3kuD8qNgkAAAECCCRAEQEHEAAAJEAZEQkAIREJACkRCQAxEQmoMIjSpwY47UhA7UhIAlDTgZcuWJzxW2AAaM26dXicuAWAAQGKAQNVU0SSAQEG8FKYAawCoAH6AagBAbABALgBAcABBMgBAtABANgBAOABAPABAIoCO3VmKCdhJywgMjUyOTg4NSwgMTU3OTc4MTcxMyk7dWYoJ3InLCA5Njg0NjAzNTYeAPCakgK1AiE2RG9jcmdpSC1id0tFTk9CbHk0WUFDQ2M4VnN3QURnQVFBUkk3VWhRaU5LbkJsZ0FZS3NHYUFCd0duaGlnQUdZQVlnQllwQUJBSmdCQUtBQkFhZ0JBN0FCQUxrQjg2MXFwQUFBSkVEQkFmT3RhcVFBQUNSQXlRR0NVQU9sekNMZFA5a0JBQUFBQUFBQThEX2dBUUQxQVEBDyxDWUFnQ2dBZ0MxQWcFEAA5CQjwQERnQWdEb0FnRDRBZ0NBQXdHWUF3R29BNGY1dkFxNkF3bFRTVTR6T2pRM016bmdBX2daaUFRQWtBUUFtQVFCd1FRAU0JAQhNa0UJCQEBGERZQkFEeEIBCw0BLC1BUUFpQVdESmFrRg0TPEE4RDgumgKJASE4QTViOVE2OQEkblBGYklBUW9BRBVYWGtRRG9KVTBsT016bzBOek01UVBnWlNRDU8MUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDPBGZUFBLsICNWh0dHA6Ly9wcmViaWQub3JnL2Rldi1kb2NzL3Nob3ctbXVsdGktZm9ybWF0LWFkcy5odG1s2AIA4AKtmEjqAksNQEh0ZXN0LmxvY2FsaG9zdDo5OTk5BRQYL3BhZ2VzLwVGKHBsZV9iaWRkZXJzBUbwQD9wYmpzX2RlYnVnPXRydWWAAwCIAwGQAwCYAxegAwGqAwDAA6wCyAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzDbbwYZgEAKIEDjEwMy43OS4xMDAuMTgwqASfRLIEEggEEAEYrAIg-gEoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzM52gQCCAHgBAHwBNOBly6IBQGYBQCgBf______AQMUAcAFAMkFaZAU8D_SBQkJCQxwAADYBQHgBQHwBQH6BQQIABAAkAYAmAYAuAYAwQYJIyjwP9AG9S_aBhYKEAkRGQFQEAAYAOAGAfIGAggAgAcBiAcAoAcB&s=6c6fb8a005b60bc5535b528c16ed74cd66c08dd0'], + 'video_events': {} + }] + } + }] + }, { + 'uuid': '375d249fda4d84', + 'tag_id': 13232354, + 'auction_id': '2793298983265666969', + 'nobid': false, + 'no_ad_url': 'https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2Ftest%2Fpages%2Fmultiple_bidders.html%3Fpbjs_debug%3Dtrue&e=wqT_3QKGCKAGBAAAAwDWAAUBCNGcpvEFEJmPioiD1PLhJhi7_-bKzp3kuD8qNgkAAAkCABEJBwgAABkJCQgkQCEJCQgAACkRCQAxCQnwaSRAMOLRpwY47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEBwAEAyAEC0AEA2AEA4AEA8AEAigI7dWYoJ2EnLCAyNTI5ODg1LCAxNTc5NzgxNzEzKTsBHSxyJywgOTc0OTQyMDQ2HgDw0JICtQIhZ2oxVmFnajgtTHdLRUx6SnZpNFlBQ0NjOFZzd0FEZ0FRQVJJN1VoUTR0R25CbGdBWUtzR2FBQndCbmlhQklBQm1BR0lBV0tRQVFDWUFRQ2dBUUdvQVFPd0FRQzVBZk90YXFRQUFDUkF3UUh6cldxa0FBQWtRTWtCQXNyenVXOVg0RF9aQVFBQUFBQUFBUEFfNEFFQTlRRUFBQUFBbUFJQW9BSUF0UUlBQUFBQXZRSUFBQUFBNEFJQTZBSUEtQUlBZ0FNQm1BTUJxQVA4AcSIdWdNSlUwbE9Nem8wTnpNNTRBUDRHWWdFQUpBRUFKZ0VBY0UJXQUBCERKQgUICQEYMkFRQThRUQkNAQEsUGdFQUlnRmd5V3BCERc0UEFfmgKJASF2QS1kUHc2OQEkblBGYklBUW9BRBVkDGtRRG8ykQAQUVBnWlMdTQBVEQwMQUFBVx0MAFkdDABhHQwAYx0MoGVBQS7YAgDgAq2YSOoCS2h0dHA6Ly90ZXN0LmxvY2FsaG9zdDo5OTk5BRT0DgEvcGFnZXMvbXVsdGlwbGVfYmlkZGVycy5odG1sP3BianNfZGVidWc9dHJ1ZYADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIEDjEwMy43OS4xMDAuMTgwqASfRLIEDggAEAEYACAAKAAwADgCuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ3MznaBAIIAOAEAfAEvMm-LogFAZgFAKAF____________AcAFAMkFAAAAAAAA8D_SBQkJAAAAAAAAAADYBQHgBQHwBZn0IfoFBAgAEACQBgGYBgC4BgDBBgAAAAAAAPC_0Ab1L9oGFgoQCREZAVAQABgA4AYM8gYCCACABwGIBwCgB0E.&s=acd26154fe24e1ce797e3016322901140c18ce65', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'native', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 97494204, + 'media_type_id': 12, + 'media_subtype_id': 65, + 'cpm': 10.000000, + 'cpm_publisher_currency': 10.000000, + 'publisher_currency_code': '$', + 'brand_category_id': 53, + 'client_initiated_ad_counting': true, + 'viewability': { + 'config': '' + }, + 'rtb': { + 'native': { + 'title': 'This is a Prebid Native Creative', + 'desc': 'This is a Prebid Native Creative. There are many like it, but this one is mine.', + 'sponsored': 'Prebid.org', + 'icon': { + 'url': 'https://vcdn.adnxs.com/p/creative-image/1a/3e/e9/5b/1a3ee95b-06cd-4260-98c7-0258627c9197.png', + 'width': 127, + 'height': 83, + 'prevent_crop': false + }, + 'main_img': { + 'url': 'https://vcdn.adnxs.com/p/creative-image/f8/7f/0f/13/f87f0f13-230c-4f05-8087-db9216e393de.jpg', + 'width': 989, + 'height': 742, + 'prevent_crop': false + }, + 'link': { + 'url': 'http://prebid.org/dev-docs/show-native-ads.html', + 'click_trackers': ['https://sin3-ib.adnxs.com/click?AAAAAAAAJEAAAAAAAAAkQAAAAAAAACRAAAAAAAAAJEAAAAAAAAAkQJmHAjGgysMmu79Z6eyQcT9RjileAAAAAOLoyQBtJAAAbSQAAAIAAAC8pM8FnPgWAAAAAABVU0QAVVNEAAEAAQBNXQAAAAABAQQCAAAAALoAxBbHxgAAAAA./bcr=AAAAAAAA8D8=/cnd=%21vA-dPwj8-LwKELzJvi4YnPFbIAQoADEAAAAAAAAkQDoJU0lOMzo0NzM5QPgZSQAAAAAAAPA_UQAAAAAAAAAAWQAAAAAAAAAAYQAAAAAAAAAAaQAAAAAAAAAAcQAAAAAAAAAAeAA./cca=OTMyNSNTSU4zOjQ3Mzk=/bn=89116/'] + }, + 'impression_trackers': ['https://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2Ftest%2Fpages%2Fmultiple_bidders.html%3Fpbjs_debug%3Dtrue&e=wqT_3QKOCKAOBAAAAwDWAAUBCNGcpvEFEJmPioiD1PLhJhi7_-bKzp3kuD8qNgkAAAECCCRAEQEHEAAAJEAZEQkAIREJACkRCQAxEQmoMOLRpwY47UhA7UhIAlC8yb4uWJzxW2AAaM26dXicuAWAAQGKAQNVU0SSAQEG8FKYAQGgAQGoAQGwAQC4AQHAAQTIAQLQAQDYAQDgAQDwAQCKAjt1ZignYScsIDI1Mjk4ODUsIDE1Nzk3ODE3MTMpO3VmKCdyJywgOTc0OTQyMDQsIC4eAPDQkgK1AiFnajFWYWdqOC1Md0tFTHpKdmk0WUFDQ2M4VnN3QURnQVFBUkk3VWhRNHRHbkJsZ0FZS3NHYUFCd0JuaWFCSUFCbUFHSUFXS1FBUUNZQVFDZ0FRR29BUU93QVFDNUFmT3RhcVFBQUNSQXdRSHpyV3FrQUFBa1FNa0JBc3J6dVc5WDREX1pBUUFBQUFBQUFQQV80QUVBOVFFQUFBQUFtQUlBb0FJQXRRSUFBQUFBdlFJQUFBQUE0QUlBNkFJQS1BSUFnQU1CbUFNQnFBUDgBxIh1Z01KVTBsT016bzBOek01NEFQNEdZZ0VBSkFFQUpnRUFjRQldBQEIREpCBQgJARgyQVFBOFFRCQ0BASxQZ0VBSWdGZ3lXcEIRFzRQQV-aAokBIXZBLWRQdzY5ASRuUEZiSUFRb0FEFWQMa1FEbzKRABBRUGdaUx1NAFURDAxBQUFXHQwAWR0MAGEdDABjHQygZUFBLtgCAOACrZhI6gJLaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkFFPQOAS9wYWdlcy9tdWx0aXBsZV9iaWRkZXJzLmh0bWw_cGJqc19kZWJ1Zz10cnVlgAMAiAMBkAMAmAMXoAMBqgMAwAPgqAHIAwDYAwDgAwDoAwD4AwGABACSBA0vdXQvdjMvcHJlYmlkmAQAogQOMTAzLjc5LjEwMC4xODCoBJ9EsgQOCAAQARgAIAAoADAAOAK4BADABADIBADSBA45MzI1I1NJTjM6NDczOdoEAggB4AQB8AS8yb4uiAUBmAUAoAX___________8BwAUAyQUAAAAAAADwP9IFCQkAAAAAAAAAANgFAeAFAfAFmfQh-gUECAAQAJAGAZgGALgGAMEGAAAAAAAA8D_QBvUv2gYWChAJERkBUBAAGADgBgzyBgIIAIAHAYgHAKAHQQ..&s=2d3f9336af4da684d7733e29f53bbb80bf69a18c'], + 'id': 97494204 + } + } + }] + }] + } + } + } +} diff --git a/test/mock-server/expectations/request-response-pairs/native/index.js b/test/mock-server/expectations/request-response-pairs/native/index.js new file mode 100644 index 00000000000..f9a8b9e3585 --- /dev/null +++ b/test/mock-server/expectations/request-response-pairs/native/index.js @@ -0,0 +1,191 @@ +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 + * + */ + +/** + * 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': 1, + 'height': 1 + }], + 'ad_types': ['native'], + 'id': 13232354, + 'allow_smaller_sizes': true, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'native': { + 'layouts': [{ + 'title': { + 'required': true + }, + 'main_image': { + 'required': true + }, + 'sponsored_by': { + 'required': true + } + }] + } + }, { + 'sizes': [{ + 'width': 1, + 'height': 1 + }], + 'ad_types': ['native'], + 'id': 13232354, + 'allow_smaller_sizes': true, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'native': { + 'layouts': [{ + 'title': { + 'required': true + }, + 'description': { + 'required': true + }, + 'main_image': { + 'required': true + }, + 'sponsored_by': { + 'required': true + }, + 'icon': { + 'required': false + } + }] + } + }], + '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': '2b7ae9fa0e76be', + 'tag_id': 13232354, + 'auction_id': '2566965852006062421', + 'nobid': false, + 'no_ad_url': 'http://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2Ftest%2Fpages%2Fnative.html&e=wqT_3QLhB6DhAwAAAwDWAAUBCNDZme8FENWyhPv4uuzPIxiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQgkQCEJCQgAACkRCQAxCQnwaSRAMOLRpwY47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEBwAEAyAEC0AEA2AEA4AEA8AEAigI7dWYoJ2EnLCAyNTI5ODg1LCAxNTc1MzgyMjI0KTsBHThyJywgOTc0OTQ0MDMsIDEdHvDQkgKpAiFCenhPTlFqOC1Md0tFSVBMdmk0WUFDQ2M4VnN3QURnQVFBUkk3VWhRNHRHbkJsZ0FZSUlDYUFCd0FIZ0FnQUdtQVlnQl9GLVFBUUNZQVFDZ0FRR29BUU93QVFDNUFmT3RhcVFBQUNSQXdRSHpyV3FrQUFBa1FNa0JRTDdBTHVfbzFqX1pBUUFBQUFBQUFQQV80QUVBOVFFQUFBQUFtQUlBb0FJQXRRSUFBQUFBdlFJQUFBQUE0QUlBNkFJQS1BSUFnQU1CbUFNQnFBUDgBxIh1Z01KVTBsT016bzBOelF5NEFQbUZvZ0VBSkFFQUpnRUFjRQldBQEIREpCBQgJARgyQVFBOFFRCQ0BAVBQZ0VBSWdGaGlVLpoCiQEhYWdfb0o6LQEkblBGYklBUW9BRBVYDGtRRG8yhQAQUU9ZV1MRWAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0MoGVBQS7YAgDgAq2YSOoCMWh0dHA6Ly90ZXN0LmxvY2FsaG9zdDo5OTk5BRTwvC9wYWdlcy9uYXRpdmUuaHRtbIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIECzEwLjc1Ljc0LjY5qATruAKyBA4IABABGAAgACgAMAA4ArgEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzQy2gQCCADgBAHwBIPLvi6IBQGYBQCgBf___________wHABQDJBQAAAAAAAPA_0gUJCQkMeAAA2AUB4AUB8AWZ9CH6BQQIABAAkAYBmAYAuAYAwQYJJTTwv8gGANAG9S_aBhYKEAkUGQFQEAAYAOAGDPIGAggAgAcBiAcAoAdB&s=54514bb848c51d509dfe3e21af09b77edfe9738e', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'native', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 97494403, + 'media_type_id': 12, + 'media_subtype_id': 65, + 'cpm': 10.000000, + 'cpm_publisher_currency': 10.000000, + 'publisher_currency_code': '$', + 'brand_category_id': 53, + 'client_initiated_ad_counting': true, + 'viewability': { + 'config': '' + }, + 'rtb': { + 'native': { + 'title': 'This is a Prebid Native Creative', + 'sponsored': 'Prebid.org', + 'main_img': { + 'url': 'http://vcdn.adnxs.com/p/creative-image/94/22/cd/0f/9422cd0f-f400-45d3-80f5-2b92629d9257.jpg', + 'width': 3000, + 'height': 2250, + 'prevent_crop': false + }, + 'link': { + 'url': 'http://prebid.org/dev-docs/show-native-ads.html', + 'click_trackers': ['http://sin3-ib.adnxs.com/click?AAAAAAAAJEAAAAAAAAAkQAAAAAAAACRAAAAAAAAAJEAAAAAAAAAkQFUZYY_XsZ8jKnKSKrrb42HQbOZdAAAAAOLoyQBtJAAAbSQAAAIAAACDpc8FnPgWAAAAAABVU0QAVVNEAAEAAQBNXQAAAAABAQQCAAAAALoA8BZszgAAAAA./bcr=AAAAAAAA8D8=/cnd=%21ag_oJQj8-LwKEIPLvi4YnPFbIAQoADEAAAAAAAAkQDoJU0lOMzo0NzQyQOYWSQAAAAAAAPA_UQAAAAAAAAAAWQAAAAAAAAAAYQAAAAAAAAAAaQAAAAAAAAAAcQAAAAAAAAAAeAA./cca=OTMyNSNTSU4zOjQ3NDI=/bn=89169/'] + }, + 'impression_trackers': ['http://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2Ftest%2Fpages%2Fnative.html&e=wqT_3QLpB6DpAwAAAwDWAAUBCNDZme8FENWyhPv4uuzPIxiq5MnUovf28WEqNgkAAAECCCRAEQEHEAAAJEAZEQkAIREJACkRCQAxEQmoMOLRpwY47UhA7UhIAlCDy74uWJzxW2AAaM26dXjRuAWAAQGKAQNVU0SSAQEG8FKYAQGgAQGoAQGwAQC4AQHAAQTIAQLQAQDYAQDgAQDwAQCKAjt1ZignYScsIDI1Mjk4ODUsIDE1NzUzODIyMjQpO3VmKCdyJywgOTc0OTQ0MDMsIC4eAPDQkgKpAiFCenhPTlFqOC1Md0tFSVBMdmk0WUFDQ2M4VnN3QURnQVFBUkk3VWhRNHRHbkJsZ0FZSUlDYUFCd0FIZ0FnQUdtQVlnQl9GLVFBUUNZQVFDZ0FRR29BUU93QVFDNUFmT3RhcVFBQUNSQXdRSHpyV3FrQUFBa1FNa0JRTDdBTHVfbzFqX1pBUUFBQUFBQUFQQV80QUVBOVFFQUFBQUFtQUlBb0FJQXRRSUFBQUFBdlFJQUFBQUE0QUlBNkFJQS1BSUFnQU1CbUFNQnFBUDgBxIh1Z01KVTBsT016bzBOelF5NEFQbUZvZ0VBSkFFQUpnRUFjRQldBQEIREpCBQgJARgyQVFBOFFRCQ0BAVBQZ0VBSWdGaGlVLpoCiQEhYWdfb0o6LQEkblBGYklBUW9BRBVYDGtRRG8yhQAQUU9ZV1MRWAxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0MoGVBQS7YAgDgAq2YSOoCMWh0dHA6Ly90ZXN0LmxvY2FsaG9zdDo5OTk5BRTwlS9wYWdlcy9uYXRpdmUuaHRtbIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzL3ByZWJpZJgEAKIECzEwLjc1Ljc0LjY5qATruAKyBA4IABABGAAgACgAMAA4ArgEAMAEAMgEANIEDjkzMjUjU0lOMzo0NzQy2gQCCAHgBAHwBEH6IIgFAZgFAKAF_xEBGAHABQDJBQAFARTwP9IFCQkFC3wAAADYBQHgBQHwBZn0IfoFBAgAEACQBgGYBgC4BgDBBgEhQAAA8D_IBgDQBvUv2gYWChAAOgEAUBAAGADgBgzyBgIIAIAHAYgHAKAHQQ..&s=6b203c7aee654cffa9c0b3771f6945f6d1e8d06c'], + 'id': 97494403 + } + } + }] + }, { + 'uuid': '35598a5ad26f59', + 'tag_id': 13232354, + 'auction_id': '6083251961435599864', + 'nobid': false, + 'no_ad_url': 'http://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2Ftest%2Fpages%2Fnative.html&e=wqT_3QLhB6DhAwAAAwDWAAUBCNDZme8FEPjnxITbrYO2VBiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQgkQCEJCQgAACkRCQAxCQnwaSRAMOLRpwY47UhA7UhIAFAAWJzxW2AAaM26dXgAgAEBigEAkgEDVVNEmAEBoAEBqAEBsAEAuAEBwAEAyAEC0AEA2AEA4AEA8AEAigI7dWYoJ2EnLCAyNTI5ODg1LCAxNTc1MzgyMjI0KTsBHSxyJywgOTc0OTQyMDQ2HgDw0JICqQIhYlR3OWZBajgtTHdLRUx6SnZpNFlBQ0NjOFZzd0FEZ0FRQVJJN1VoUTR0R25CbGdBWUlJQ2FBQndBSGdBZ0FHbUFZZ0JfRi1RQVFDWUFRQ2dBUUdvQVFPd0FRQzVBZk90YXFRQUFDUkF3UUh6cldxa0FBQWtRTWtCeVdmYjBYeWIxVF9aQVFBQUFBQUFBUEFfNEFFQTlRRUFBQUFBbUFJQW9BSUF0UUlBQUFBQXZRSUFBQUFBNEFJQTZBSUEtQUlBZ0FNQm1BTUJxQVA4AcSIdWdNSlUwbE9Nem8wTnpReTRBUG1Gb2dFQUpBRUFKZ0VBY0UJXQUBCERKQgUICQEYMkFRQThRUQkNAQFUUGdFQUlnRmhpVS6aAokBIW9ROTNPUTYtASRuUEZiSUFRb0FEFVgMa1FEbzKFABBRT1lXUxFYDFBBX1URDAxBQUFXHQwAWR0MAGEdDABjHQygZUFBLtgCAOACrZhI6gIxaHR0cDovL3Rlc3QubG9jYWxob3N0Ojk5OTkFFPC8L3BhZ2VzL25hdGl2ZS5odG1sgAMAiAMBkAMAmAMXoAMBqgMAwAPgqAHIAwDYAwDgAwDoAwD4AwGABACSBA0vdXQvdjMvcHJlYmlkmAQAogQLMTAuNzUuNzQuNjmoBOu4ArIEDggAEAEYACAAKAAwADgCuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ3NDLaBAIIAOAEAfAEvMm-LogFAZgFAKAF____________AcAFAMkFAAAAAAAA8D_SBQkJCQx4AADYBQHgBQHwBZn0IfoFBAgAEACQBgGYBgC4BgDBBgklNPC_yAYA0Ab1L9oGFgoQCRQZAVAQABgA4AYM8gYCCACABwGIBwCgB0E.&s=99a73b39ab82dd9384eee306ff03276ab688cfe5', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'native', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 97494204, + 'media_type_id': 12, + 'media_subtype_id': 65, + 'cpm': 10.000000, + 'cpm_publisher_currency': 10.000000, + 'publisher_currency_code': '$', + 'brand_category_id': 53, + 'client_initiated_ad_counting': true, + 'viewability': { + 'config': '' + }, + 'rtb': { + 'native': { + 'title': 'This is a Prebid Native Creative', + 'desc': 'This is a Prebid Native Creative. There are many like it, but this one is mine.', + 'sponsored': 'Prebid.org', + 'icon': { + 'url': 'http://vcdn.adnxs.com/p/creative-image/1a/3e/e9/5b/1a3ee95b-06cd-4260-98c7-0258627c9197.png', + 'width': 127, + 'height': 83, + 'prevent_crop': false + }, + 'main_img': { + 'url': 'http://vcdn.adnxs.com/p/creative-image/f8/7f/0f/13/f87f0f13-230c-4f05-8087-db9216e393de.jpg', + 'width': 989, + 'height': 742, + 'prevent_crop': false + }, + 'link': { + 'url': 'http://prebid.org/dev-docs/show-native-ads.html', + 'click_trackers': ['http://sin3-ib.adnxs.com/click?AAAAAAAAJEAAAAAAAAAkQAAAAAAAACRAAAAAAAAAJEAAAAAAAAAkQPgzkbBtDWxUKnKSKrrb42HQbOZdAAAAAOLoyQBtJAAAbSQAAAIAAAC8pM8FnPgWAAAAAABVU0QAVVNEAAEAAQBNXQAAAAABAQQCAAAAALoAJhcX3AAAAAA./bcr=AAAAAAAA8D8=/cnd=%21oQ93OQj8-LwKELzJvi4YnPFbIAQoADEAAAAAAAAkQDoJU0lOMzo0NzQyQOYWSQAAAAAAAPA_UQAAAAAAAAAAWQAAAAAAAAAAYQAAAAAAAAAAaQAAAAAAAAAAcQAAAAAAAAAAeAA./cca=OTMyNSNTSU4zOjQ3NDI=/bn=89169/'] + }, + 'impression_trackers': ['http://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2Ftest%2Fpages%2Fnative.html&e=wqT_3QLpB6DpAwAAAwDWAAUBCNDZme8FEPjnxITbrYO2VBiq5MnUovf28WEqNgkAAAECCCRAEQEHEAAAJEAZEQkAIREJACkRCQAxEQmoMOLRpwY47UhA7UhIAlC8yb4uWJzxW2AAaM26dXjRuAWAAQGKAQNVU0SSAQEG8FKYAQGgAQGoAQGwAQC4AQHAAQTIAQLQAQDYAQDgAQDwAQCKAjt1ZignYScsIDI1Mjk4ODUsIDE1NzUzODIyMjQpO3VmKCdyJywgOTc0OTQyMDQsIC4eAPDQkgKpAiFiVHc5ZkFqOC1Md0tFTHpKdmk0WUFDQ2M4VnN3QURnQVFBUkk3VWhRNHRHbkJsZ0FZSUlDYUFCd0FIZ0FnQUdtQVlnQl9GLVFBUUNZQVFDZ0FRR29BUU93QVFDNUFmT3RhcVFBQUNSQXdRSHpyV3FrQUFBa1FNa0J5V2ZiMFh5YjFUX1pBUUFBQUFBQUFQQV80QUVBOVFFQUFBQUFtQUlBb0FJQXRRSUFBQUFBdlFJQUFBQUE0QUlBNkFJQS1BSUFnQU1CbUFNQnFBUDgBxIh1Z01KVTBsT016bzBOelF5NEFQbUZvZ0VBSkFFQUpnRUFjRQldBQEIREpCBQgJARgyQVFBOFFRCQ0BAVRQZ0VBSWdGaGlVLpoCiQEhb1E5M09RNi0BJG5QRmJJQVFvQUQVWAxrUURvMoUAEFFPWVdTEVgMUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDKBlQUEu2AIA4AKtmEjqAjFodHRwOi8vdGVzdC5sb2NhbGhvc3Q6OTk5OQUU8LwvcGFnZXMvbmF0aXZlLmh0bWyAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My9wcmViaWSYBACiBAsxMC43NS43NC42OagE67gCsgQOCAAQARgAIAAoADAAOAK4BADABADIBADSBA45MzI1I1NJTjM6NDc0MtoEAggB4AQB8AS8yb4uiAUBmAUAoAX___________8BwAUAyQUAAAAAAADwP9IFCQkJDHgAANgFAeAFAfAFmfQh-gUECAAQAJAGAZgGALgGAMEGCSU48D_IBgDQBvUv2gYWChAAOgEAUBAAGADgBgzyBgIIAIAHAYgHAKAHQQ..&s=5c316c116b6e2bdb19f3950c4c769821e735688e'], + 'id': 97494204 + } + } + }] + }] + } + } + } +} diff --git a/test/mock-server/expectations/request-response-pairs/outstream/index.js b/test/mock-server/expectations/request-response-pairs/outstream/index.js new file mode 100644 index 00000000000..be5f4654b9f --- /dev/null +++ b/test/mock-server/expectations/request-response-pairs/outstream/index.js @@ -0,0 +1,162 @@ +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 + * + */ + +/** + * 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': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 13232385, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'video': { + 'skippable': true, + 'playback_method': ['auto_play_sound_off'] + } + }, { + 'sizes': [{ + 'width': 640, + 'height': 480 + }], + 'primary_size': { + 'width': 640, + 'height': 480 + }, + 'ad_types': ['video'], + 'id': 13232385, + 'allow_smaller_sizes': false, + 'use_pmt_rule': false, + 'prebid': true, + 'disable_psa': true, + 'video': { + 'skippable': true, + 'playback_method': ['auto_play_sound_off'] + } + }], + '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': '223e8549781f2e', + 'tag_id': 13232385, + 'auction_id': '527250675737245396', + 'nobid': false, + 'no_ad_url': 'http://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2Ftest%2Fpages%2Foutstream.html&e=wqT_3QKwCKAwBAAAAwDWAAUBCOiWpO8FENTtnJej9sqoBxiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQgkQCEJCQgAACkRCQAxCQnwaSRAMIHSpwY47UhA7UhIAFAAWJzxW2AAaOWljwF4AIABAYoBAJIBA1VTRJgBAaABAagBAbABALgBA8ABAMgBAtABANgBAOABAPABAIoCO3VmKCdhJywgMjUyOTg4NSwgMTU3NTU1Mzg5NikFHTRyJywgOTc1MTc3NzEsIC4eAPCakgK1AiFUenpuS1FqWS1Md0tFTXVCd0M0WUFDQ2M4VnN3QURnQVFBUkk3VWhRZ2RLbkJsZ0FZSUlDYUFCd0FIZ0FnQUhBQVlnQkFKQUJBSmdCQUtBQkFhZ0JBN0FCQUxrQjg2MXFwQUFBSkVEQkFmT3RhcVFBQUNSQXlRSG5NQW5aODYzalA5a0JBQUFBQUFBQThEX2dBUUQxQVEBDyxDWUFnQ2dBZ0MxQWcFEAA5CQjwQERnQWdEb0FnRDRBZ0NBQXdHWUF3R29BOWo0dkFxNkF3bFRTVTR6T2pRNE16VGdBX2tXaUFRQWtBUUFtQVFCd1FRAU0JAQhNa0UJCQEBGERZQkFEeEIBCw0BLC1BUUFpQVhpSmFrRg0TOEE4RDgumgKJASFXdzkxSDo5ASRuUEZiSUFRb0FEFVhYa1FEb0pVMGxPTXpvME9ETTBRUGtXU1ENTwxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M8EllQUEuwgI4aHR0cDovL3ByZWJpZC5vcmcvZGV2LWRvY3Mvc2hvdy1vdXRzdHJlYW0tdmlkZW8tYWRzLmh0bWzYAgDgAq2YSOoCNA1DSHRlc3QubG9jYWxob3N0Ojk5OTkFFBgvcGFnZXMvFUkALgE_yIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzLwmj8F6YBACiBAsxMC43NS43NC42OagEmM8CsgQSCAQQBBiABSDgAygBKAIwADgDuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ4MzTaBAIIAOAEAPAEy4HALogFAZgFAKAF_____wUDFAHABQDJBWlyFPA_0gUJCQkMeAAA2AUB4AUB8AXDlQv6BQQIABAAkAYBmAYAuAYAwQYJJTTwv8gGANAG9S_aBhYKEAkUGQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA&s=9953ce4d94992db04897ab580bf81b3e274b2601', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'http://sin3-ib.adnxs.com/vast_track/v2?info=aAAAAAMArgAFAQloC-ldAAAAABHUNucysitRBxloC-ldAAAAACDLgcAuKAAw7Ug47UhA0-hISLuv1AFQgdKnBljDlQtiAi0taAFwAXgAgAECiAEEkAGABZgB4AOgAQCoAcuBwC6wAQE.&s=979aee1106a0bea5609a3c23fdc46153ad6d9eec&event_type=1', + 'usersync_url': 'http%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 97517771, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 10.000000, + 'cpm_publisher_currency': 10.000000, + 'publisher_currency_code': '$', + 'brand_category_id': 36, + 'renderer_url': 'http://acdn.adnxs.com/video/outstream/ANOutstreamVideo.js', + 'renderer_id': 2, + 'renderer_config': '{"skippable":{"videoThreshold":null,"skipLocation":"top-right"}}', + 'client_initiated_ad_counting': true, + 'viewability': { + 'config': 'tv=vh2-121&d=1x1&s=3479483&st=0&vctx=4&ts=1575553896&vc=iab;vid_ccr=1&vjs=http%3A%2F%2Fcdn.adnxs.com%2Fv%2Fvideo%2F182%2Ftrk.js&cb=http%3A%2F%2Fsin3-ib.adnxs.com%2Fvevent%3Fan_audit%3D0%26referrer%3Dhttp%253A%252F%252Ftest.localhost%253A9999%252Ftest%252Fpages%252Foutstream.html%26e%3DwqT_3QK4CKA4BAAAAwDWAAUBCOiWpO8FENTtnJej9sqoBxiq5MnUovf28WEqNgkAAAECCCRAEQEHEAAAJEAZEQkAIREJACkRCQAxEQmoMIHSpwY47UhA7UhIAlDLgcAuWJzxW2AAaOWljwF4urgFgAEBigEDVVNEkgUG8FKYAQGgAQGoAQGwAQC4AQPAAQTIAQLQAQDYAQDgAQDwAQCKAjt1ZignYScsIDI1Mjk4ODUsIDE1NzU1NTM4OTYpO3VmKCdyJywgOTc1MTc3NzEsIC4eAPCakgK1AiFUenpuS1FqWS1Md0tFTXVCd0M0WUFDQ2M4VnN3QURnQVFBUkk3VWhRZ2RLbkJsZ0FZSUlDYUFCd0FIZ0FnQUhBQVlnQkFKQUJBSmdCQUtBQkFhZ0JBN0FCQUxrQjg2MXFwQUFBSkVEQkFmT3RhcVFBQUNSQXlRSG5NQW5aODYzalA5a0JBQUFBQUFBQThEX2dBUUQxQVEBDyxDWUFnQ2dBZ0MxQWcFEAA5CQjwQERnQWdEb0FnRDRBZ0NBQXdHWUF3R29BOWo0dkFxNkF3bFRTVTR6T2pRNE16VGdBX2tXaUFRQWtBUUFtQVFCd1FRAU0JAQhNa0UJCQEBGERZQkFEeEIBCw0BLC1BUUFpQVhpSmFrRg0TOEE4RDgumgKJASFXdzkxSDo5ASRuUEZiSUFRb0FEFVhYa1FEb0pVMGxPTXpvME9ETTBRUGtXU1ENTwxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M8EllQUEuwgI4aHR0cDovL3ByZWJpZC5vcmcvZGV2LWRvY3Mvc2hvdy1vdXRzdHJlYW0tdmlkZW8tYWRzLmh0bWzYAgDgAq2YSOoCNA1DSHRlc3QubG9jYWxob3N0Ojk5OTkFFBgvcGFnZXMvFUkALgE_yIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzLwmj8F6YBACiBAsxMC43NS43NC42OagEmM8CsgQSCAQQBBiABSDgAygBKAIwADgDuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ4MzTaBAIIAeAEAPAEy4HALogFAZgFAKAF_____wUDFAHABQDJBWl6FPA_0gUJCQkMeAAA2AUB4AUB8AXDlQv6BQQIABAAkAYBmAYAuAYAwQYJJTTwP8gGANAG9S_aBhYKEAkUGQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA%26s%3D5adef946cd5f0d8db86d67860914e02ef6f91d6b&cet=0&cecb=&rdcb=http%3A%2F%2Fsin3-ib.adnxs.com%2Frd_log%3Fan_audit%3D0%26referrer%3Dhttp%253A%252F%252Ftest.localhost%253A9999%252Ftest%252Fpages%252Foutstream.html%26e%3DwqT_3QKMCaCMBAAAAwDWAAUBCOiWpO8FENTtnJej9sqoBxiq5MnUovf28WEqNgkAAAECCCRAEQEHEAAAJEAZEQkAIREJACkRCQAxEQmoMIHSpwY47UhA7UhIAlDLgcAuWJzxW2AAaOWljwF4urgFgAEBigEDVVNEkgUG8FKYAQGgAQGoAQGwAQC4AQPAAQTIAQLQAQDYAQDgAQDwAQCKAjt1ZignYScsIDI1Mjk4ODUsIDE1NzU1NTM4OTYpO3VmKCdyJywgOTc1MTc3NzEsIC4eAPCakgK1AiFUenpuS1FqWS1Md0tFTXVCd0M0WUFDQ2M4VnN3QURnQVFBUkk3VWhRZ2RLbkJsZ0FZSUlDYUFCd0FIZ0FnQUhBQVlnQkFKQUJBSmdCQUtBQkFhZ0JBN0FCQUxrQjg2MXFwQUFBSkVEQkFmT3RhcVFBQUNSQXlRSG5NQW5aODYzalA5a0JBQUFBQUFBQThEX2dBUUQxQVEBDyxDWUFnQ2dBZ0MxQWcFEAA5CQjwQERnQWdEb0FnRDRBZ0NBQXdHWUF3R29BOWo0dkFxNkF3bFRTVTR6T2pRNE16VGdBX2tXaUFRQWtBUUFtQVFCd1FRAU0JAQhNa0UJCQEBGERZQkFEeEIBCw0BLC1BUUFpQVhpSmFrRg0TOEE4RDgumgKJASFXdzkxSDo5ASRuUEZiSUFRb0FEFVhYa1FEb0pVMGxPTXpvME9ETTBRUGtXU1ENTwxQQV9VEQwMQUFBVx0MAFkdDABhHQwAYx0M8EllQUEuwgI4aHR0cDovL3ByZWJpZC5vcmcvZGV2LWRvY3Mvc2hvdy1vdXRzdHJlYW0tdmlkZW8tYWRzLmh0bWzYAgDgAq2YSOoCNA1DSHRlc3QubG9jYWxob3N0Ojk5OTkFFBgvcGFnZXMvFUkALgE_aPICEwoPQ1VTVE9NX01PREVMX0lEEgDyAhoKFjIWACBMRUFGX05BTUUBHQgeCho2HQAIQVNUAT7gSUZJRUQSAIADAIgDAZADAJgDF6ADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMBgAQAkgQNL3V0L3YzDffwXpgEAKIECzEwLjc1Ljc0LjY5qASYzwKyBBIIBBAEGIAFIOADKAEoAjAAOAO4BADABADIBADSBA45MzI1I1NJTjM6NDgzNNoEAggB4AQA8ATLgcAuiAUBmAUAoAX_____BQMUAcAFAMkFac4U8D_SBQkJCQx4AADYBQHgBQHwBcOVC_oFBAgAEACQBgGYBgC4BgDBBgklNPA_yAYA0Ab1L9oGFgoQCRQZAVAQABgA4AYE8gYCCACABwGIBwCgB0A.%26s%3Df2a73057b50fb0c9e98a6093141472a4ed2e401e&bridge=1.11.0&rblog=auc=527250675737245396;bm=9325;sm=9325;cr=97517771;pl=13232385&vid_context=anoutstream;anbannerstream;anoverlayplayer' + }, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 30000, + 'playback_methods': ['auto_play_sound_off'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'content': 'adnxs00:00:30.000' + } + } + }] + }, { + 'uuid': '3acfd472dd4bdf', + 'tag_id': 13232385, + 'auction_id': '3449642271543746980', + 'nobid': false, + 'no_ad_url': 'http://sin3-ib.adnxs.com/it?an_audit=0&referrer=http%3A%2F%2Ftest.localhost%3A9999%2Ftest%2Fpages%2Foutstream.html&e=wqT_3QKwCKAwBAAAAwDWAAUBCOiWpO8FEKTDpazn6-XvLxiq5MnUovf28WEqNgkAAAkCABEJBwgAABkJCQgkQCEJCQgAACkRCQAxCQnwaSRAMIHSpwY47UhA7UhIAFAAWJzxW2AAaOWljwF4AIABAYoBAJIBA1VTRJgBAaABAagBAbABALgBA8ABAMgBAtABANgBAOABAPABAIoCO3VmKCdhJywgMjUyOTg4NSwgMTU3NTU1Mzg5NikFHTRyJywgOTc1MTc3NzEsIC4eAPCakgK1AiFvendNV2dqWS1Md0tFTXVCd0M0WUFDQ2M4VnN3QURnQVFBUkk3VWhRZ2RLbkJsZ0FZSUlDYUFCd0FIZ0FnQUhBQVlnQkFKQUJBSmdCQUtBQkFhZ0JBN0FCQUxrQjg2MXFwQUFBSkVEQkFmT3RhcVFBQUNSQXlRSHIwdDF2TTdMaVA5a0JBQUFBQUFBQThEX2dBUUQxQVEBDyxDWUFnQ2dBZ0MxQWcFEAA5CQjwQERnQWdEb0FnRDRBZ0NBQXdHWUF3R29BOWo0dkFxNkF3bFRTVTR6T2pRNE16VGdBX2tXaUFRQWtBUUFtQVFCd1FRAU0JAQhNa0UJCQEBGERZQkFEeEIBCw0BLC1BUUFpQVhpSmFrRg0TPEE4RDgumgKJASFXdzkxSFE2OQEkblBGYklBUW9BRBVYWGtRRG9KVTBsT016bzBPRE0wUVBrV1NRDU8MUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDPBJZUFBLsICOGh0dHA6Ly9wcmViaWQub3JnL2Rldi1kb2NzL3Nob3ctb3V0c3RyZWFtLXZpZGVvLWFkcy5odG1s2AIA4AKtmEjqAjQNQ0h0ZXN0LmxvY2FsaG9zdDo5OTk5BRQYL3BhZ2VzLxVJAC4BP8iAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My8Jo_BemAQAogQLMTAuNzUuNzQuNjmoBJjPArIEEggEEAQYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0ODM02gQCCADgBADwBMuBwC6IBQGYBQCgBf____8FAxQBwAUAyQVpchTwP9IFCQkJDHgAANgFAeAFAfAFw5UL-gUECAAQAJAGAZgGALgGAMEGCSU08L_IBgDQBvUv2gYWChAJFBkBUBAAGADgBgTyBgIIAIAHAYgHAKAHQA..&s=e43b45a2391036da6d93eda546d8808de0169bb1', + 'timeout_ms': 0, + 'ad_profile_id': 1182765, + 'rtb_video_fallback': false, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'video', + 'notify_url': 'http://sin3-ib.adnxs.com/vast_track/v2?info=aAAAAAMArgAFAQloC-ldAAAAABGkYYl1XpffLxloC-ldAAAAACDLgcAuKAAw7Ug47UhA0-hISLuv1AFQgdKnBljDlQtiAi0taAFwAXgAgAECiAEEkAGABZgB4AOgAQCoAcuBwC6wAQE.&s=414834fdc6e268f284292aedf8b01ee525c3e999&event_type=1', + 'usersync_url': 'http%3A%2F%2Facdn.adnxs.com%2Fdmp%2Fasync_usersync.html', + 'buyer_member_id': 9325, + 'advertiser_id': 2529885, + 'creative_id': 97517771, + 'media_type_id': 4, + 'media_subtype_id': 64, + 'cpm': 10.000000, + 'cpm_publisher_currency': 10.000000, + 'publisher_currency_code': '$', + 'brand_category_id': 36, + 'renderer_url': 'http://acdn.adnxs.com/video/outstream/ANOutstreamVideo.js', + 'renderer_id': 2, + 'renderer_config': '{"skippable":{"videoThreshold":null,"skipLocation":"top-right"}}', + 'client_initiated_ad_counting': true, + 'viewability': { + 'config': 'tv=vh2-121&d=1x1&s=3479483&st=0&vctx=4&ts=1575553896&vc=iab;vid_ccr=1&vjs=http%3A%2F%2Fcdn.adnxs.com%2Fv%2Fvideo%2F182%2Ftrk.js&cb=http%3A%2F%2Fsin3-ib.adnxs.com%2Fvevent%3Fan_audit%3D0%26referrer%3Dhttp%253A%252F%252Ftest.localhost%253A9999%252Ftest%252Fpages%252Foutstream.html%26e%3DwqT_3QK4CKA4BAAAAwDWAAUBCOiWpO8FEKTDpazn6-XvLxiq5MnUovf28WEqNgkAAAECCCRAEQEHEAAAJEAZEQkAIREJACkRCQAxEQmoMIHSpwY47UhA7UhIAlDLgcAuWJzxW2AAaOWljwF4urgFgAEBigEDVVNEkgUG8FKYAQGgAQGoAQGwAQC4AQPAAQTIAQLQAQDYAQDgAQDwAQCKAjt1ZignYScsIDI1Mjk4ODUsIDE1NzU1NTM4OTYpO3VmKCdyJywgOTc1MTc3NzEsIC4eAPCakgK1AiFvendNV2dqWS1Md0tFTXVCd0M0WUFDQ2M4VnN3QURnQVFBUkk3VWhRZ2RLbkJsZ0FZSUlDYUFCd0FIZ0FnQUhBQVlnQkFKQUJBSmdCQUtBQkFhZ0JBN0FCQUxrQjg2MXFwQUFBSkVEQkFmT3RhcVFBQUNSQXlRSHIwdDF2TTdMaVA5a0JBQUFBQUFBQThEX2dBUUQxQVEBDyxDWUFnQ2dBZ0MxQWcFEAA5CQjwQERnQWdEb0FnRDRBZ0NBQXdHWUF3R29BOWo0dkFxNkF3bFRTVTR6T2pRNE16VGdBX2tXaUFRQWtBUUFtQVFCd1FRAU0JAQhNa0UJCQEBGERZQkFEeEIBCw0BLC1BUUFpQVhpSmFrRg0TPEE4RDgumgKJASFXdzkxSFE2OQEkblBGYklBUW9BRBVYWGtRRG9KVTBsT016bzBPRE0wUVBrV1NRDU8MUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDPBJZUFBLsICOGh0dHA6Ly9wcmViaWQub3JnL2Rldi1kb2NzL3Nob3ctb3V0c3RyZWFtLXZpZGVvLWFkcy5odG1s2AIA4AKtmEjqAjQNQ0h0ZXN0LmxvY2FsaG9zdDo5OTk5BRQYL3BhZ2VzLxVJAC4BP8iAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92My8Jo_BemAQAogQLMTAuNzUuNzQuNjmoBJjPArIEEggEEAQYgAUg4AMoASgCMAA4A7gEAMAEAMgEANIEDjkzMjUjU0lOMzo0ODM02gQCCAHgBADwBMuBwC6IBQGYBQCgBf____8FAxQBwAUAyQVpehTwP9IFCQkJDHgAANgFAeAFAfAFw5UL-gUECAAQAJAGAZgGALgGAMEGCSU08D_IBgDQBvUv2gYWChAJFBkBUBAAGADgBgTyBgIIAIAHAYgHAKAHQA..%26s%3Dc2a8dac8959d9366981afc868ec5b54853090944&cet=0&cecb=&rdcb=http%3A%2F%2Fsin3-ib.adnxs.com%2Frd_log%3Fan_audit%3D0%26referrer%3Dhttp%253A%252F%252Ftest.localhost%253A9999%252Ftest%252Fpages%252Foutstream.html%26e%3DwqT_3QKMCaCMBAAAAwDWAAUBCOiWpO8FEKTDpazn6-XvLxiq5MnUovf28WEqNgkAAAECCCRAEQEHEAAAJEAZEQkAIREJACkRCQAxEQmoMIHSpwY47UhA7UhIAlDLgcAuWJzxW2AAaOWljwF4urgFgAEBigEDVVNEkgUG8FKYAQGgAQGoAQGwAQC4AQPAAQTIAQLQAQDYAQDgAQDwAQCKAjt1ZignYScsIDI1Mjk4ODUsIDE1NzU1NTM4OTYpO3VmKCdyJywgOTc1MTc3NzEsIC4eAPCakgK1AiFvendNV2dqWS1Md0tFTXVCd0M0WUFDQ2M4VnN3QURnQVFBUkk3VWhRZ2RLbkJsZ0FZSUlDYUFCd0FIZ0FnQUhBQVlnQkFKQUJBSmdCQUtBQkFhZ0JBN0FCQUxrQjg2MXFwQUFBSkVEQkFmT3RhcVFBQUNSQXlRSHIwdDF2TTdMaVA5a0JBQUFBQUFBQThEX2dBUUQxQVEBDyxDWUFnQ2dBZ0MxQWcFEAA5CQjwQERnQWdEb0FnRDRBZ0NBQXdHWUF3R29BOWo0dkFxNkF3bFRTVTR6T2pRNE16VGdBX2tXaUFRQWtBUUFtQVFCd1FRAU0JAQhNa0UJCQEBGERZQkFEeEIBCw0BLC1BUUFpQVhpSmFrRg0TPEE4RDgumgKJASFXdzkxSFE2OQEkblBGYklBUW9BRBVYWGtRRG9KVTBsT016bzBPRE0wUVBrV1NRDU8MUEFfVREMDEFBQVcdDABZHQwAYR0MAGMdDPBJZUFBLsICOGh0dHA6Ly9wcmViaWQub3JnL2Rldi1kb2NzL3Nob3ctb3V0c3RyZWFtLXZpZGVvLWFkcy5odG1s2AIA4AKtmEjqAjQNQ0h0ZXN0LmxvY2FsaG9zdDo5OTk5BRQYL3BhZ2VzLxVJAC4BP2jyAhMKD0NVU1RPTV9NT0RFTF9JRBIA8gIaChYyFgAgTEVBRl9OQU1FAR0IHgoaNh0ACEFTVAE-4ElGSUVEEgCAAwCIAwGQAwCYAxegAwGqAwDAA-CoAcgDANgDAOADAOgDAPgDAYAEAJIEDS91dC92Mw338F6YBACiBAsxMC43NS43NC42OagEmM8CsgQSCAQQBBiABSDgAygBKAIwADgDuAQAwAQAyAQA0gQOOTMyNSNTSU4zOjQ4MzTaBAIIAeAEAPAEy4HALogFAZgFAKAF_____wUDFAHABQDJBWnOFPA_0gUJCQkMeAAA2AUB4AUB8AXDlQv6BQQIABAAkAYBmAYAuAYAwQYJJTTwP8gGANAG9S_aBhYKEAkUGQFQEAAYAOAGBPIGAggAgAcBiAcAoAdA%26s%3D4e9e218d8f075cb19c4a4e8da2a7e716fa15d3c5&bridge=1.11.0&rblog=auc=3449642271543746980;bm=9325;sm=9325;cr=97517771;pl=13232385&vid_context=anoutstream;anbannerstream;anoverlayplayer' + }, + 'rtb': { + 'video': { + 'player_width': 640, + 'player_height': 480, + 'duration_ms': 30000, + 'playback_methods': ['auto_play_sound_off'], + 'frameworks': ['vpaid_1_0', 'vpaid_2_0'], + 'content': 'adnxs00:00:30.000' + } + } + }] + }] + } + } + } +} diff --git a/test/mock-server/index.js b/test/mock-server/index.js index 30ead952fcc..9a97ca5e0a0 100644 --- a/test/mock-server/index.js +++ b/test/mock-server/index.js @@ -1,3 +1,4 @@ +/* eslint-disable no-console */ const express = require('express'); const argv = require('yargs').argv; const app = module.exports = express(); diff --git a/test/mock-server/request-middlewares/prebid-request.js b/test/mock-server/request-middlewares/prebid-request.js index 6e2d03487cf..b14c3119247 100644 --- a/test/mock-server/request-middlewares/prebid-request.js +++ b/test/mock-server/request-middlewares/prebid-request.js @@ -39,7 +39,7 @@ module.exports = function (req, res, next) { // 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 => { + ['sdk', 'referrer_detection', 'brand_category_uniqueness', 'gdpr_consent'].forEach(prop => { if (reqBody && reqBody[prop]) { delete reqBody[prop]; } diff --git a/test/mocks/adloaderStub.js b/test/mocks/adloaderStub.js index 9b9e62a4c3b..b52ca5e9280 100644 --- a/test/mocks/adloaderStub.js +++ b/test/mocks/adloaderStub.js @@ -1,23 +1,23 @@ -import * as adloader from 'src/adloader'; +import * as adloader from 'src/adloader.js'; -let sandbox; +// this export is for adloader's tests against actual implementation +export let loadExternalScript = adloader.loadExternalScript; -export let loadScript; -export let loadExternalScript; -export let loadScriptStub; -export let loadExternalScriptStub; +let stub = createStub(); -beforeEach(function() { - sandbox = sinon.sandbox.create(); - loadScript = adloader.loadScript; - loadExternalScript = adloader.loadExternalScript; - loadScriptStub = sandbox.stub(adloader, 'loadScript').callsFake((...args) => { - args[1](); +function createStub() { + return sinon.stub(adloader, 'loadExternalScript').callsFake((...args) => { + if (typeof args[2] === 'function') { + args[2](); + } else if (typeof args[3] === 'function') { + args[3](); + } + return document.createElement('script'); }); - loadExternalScriptStub = sandbox.stub(adloader, 'loadExternalScript'); -}); +} -afterEach(function() { - sandbox.restore(); +beforeEach(function() { + stub.restore(); + stub = createStub(); }); diff --git a/test/mocks/videoCacheStub.js b/test/mocks/videoCacheStub.js index 39f5d67b6a9..7ce899cae35 100644 --- a/test/mocks/videoCacheStub.js +++ b/test/mocks/videoCacheStub.js @@ -1,4 +1,4 @@ -import * as videoCache from 'src/videoCache'; +import * as videoCache from 'src/videoCache.js'; /** * Function which can be called from unit tests to stub out the video cache. diff --git a/test/mocks/xhr.js b/test/mocks/xhr.js new file mode 100644 index 00000000000..9fb8fe87fa0 --- /dev/null +++ b/test/mocks/xhr.js @@ -0,0 +1,9 @@ + +export let server = sinon.createFakeServer(); +export let xhr = global.XMLHttpRequest; + +beforeEach(function() { + server.restore(); + server = sinon.createFakeServer(); + xhr = global.XMLHttpRequest; +}); diff --git a/test/pages/bidderSettings.html b/test/pages/bidderSettings.html new file mode 100644 index 00000000000..a4a718d6497 --- /dev/null +++ b/test/pages/bidderSettings.html @@ -0,0 +1,125 @@ + + + + + + + + + + + + +

Prebid.js Test

+
Div-1
+
+ +
+ + diff --git a/test/pages/consent_mgt_gdpr.html b/test/pages/consent_mgt_gdpr.html new file mode 100644 index 00000000000..a7da17ca2f7 --- /dev/null +++ b/test/pages/consent_mgt_gdpr.html @@ -0,0 +1,206 @@ + + + + + + + + + + + + + +

Prebid.js Test

+
Div-1
+
+ +
+ + diff --git a/test/pages/currency.html b/test/pages/currency.html new file mode 100644 index 00000000000..5214982f67c --- /dev/null +++ b/test/pages/currency.html @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + +

Prebid.js Test

+
Div-1
+
+ +
+ + diff --git a/test/pages/video.html b/test/pages/instream.html similarity index 93% rename from test/pages/video.html rename to test/pages/instream.html index 3fabeb14b94..be7aceb40db 100644 --- a/test/pages/video.html +++ b/test/pages/instream.html @@ -38,7 +38,7 @@ { bidder: 'appnexus', params: { - placementId: '9333431', + placementId: '13232361', video: { skipppable: false, playback_methods: ['auto_play_sound_off'] @@ -50,6 +50,12 @@ pbjs.que.push(function(){ pbjs.addAdUnits(videoAdUnit); + pbjs.setConfig({ + debug: true, + cache: { + url: 'https://prebid.adnxs.com/pbc/v1/cache' + } + }); pbjs.requestBids({ timeout : 700, bidsBackHandler : function(bids) { diff --git a/test/pages/multiple_bidders.html b/test/pages/multiple_bidders.html new file mode 100644 index 00000000000..1cf139fd0b8 --- /dev/null +++ b/test/pages/multiple_bidders.html @@ -0,0 +1,174 @@ + + + + + + + + + + + + + + + + +

Multi-Format Ad Units

+

div-banner

+
+ +
+ +

div-native

+
+

No response

+ +
+ + + + \ No newline at end of file diff --git a/test/pages/priceGranularity.html b/test/pages/priceGranularity.html new file mode 100644 index 00000000000..588b11044fb --- /dev/null +++ b/test/pages/priceGranularity.html @@ -0,0 +1,131 @@ + + + + + + + + + + + + +

Prebid.js Test

+
Div-1
+
+ +
+ + diff --git a/test/pages/sizeConfig.html b/test/pages/sizeConfig.html new file mode 100644 index 00000000000..b62b4a741ab --- /dev/null +++ b/test/pages/sizeConfig.html @@ -0,0 +1,142 @@ + + + + + + + + + + + + +

Prebid.js Test

+
Div-1
+
+ +
+ + diff --git a/test/pages/userSync.html b/test/pages/userSync.html new file mode 100644 index 00000000000..43aeafd46e9 --- /dev/null +++ b/test/pages/userSync.html @@ -0,0 +1,121 @@ + + + + + + + + + + + + +

Prebid.js Test

+
Div-1
+
+ +
+ + diff --git a/test/spec/AnalyticsAdapter_spec.js b/test/spec/AnalyticsAdapter_spec.js index 59138b03e61..4afa430f81e 100644 --- a/test/spec/AnalyticsAdapter_spec.js +++ b/test/spec/AnalyticsAdapter_spec.js @@ -1,6 +1,7 @@ import { expect } from 'chai'; -import events from 'src/events'; +import events from 'src/events.js'; import CONSTANTS from 'src/constants.json'; +import { server } from 'test/mocks/xhr.js'; const REQUEST_BIDS = CONSTANTS.EVENTS.REQUEST_BIDS; const BID_REQUESTED = CONSTANTS.EVENTS.BID_REQUESTED; @@ -12,7 +13,7 @@ const ADD_AD_UNITS = CONSTANTS.EVENTS.ADD_AD_UNITS; const AnalyticsAdapter = require('src/AnalyticsAdapter').default; const config = { - url: 'http://localhost:9999/endpoint', + url: 'https://localhost:9999/endpoint', analyticsType: 'endpoint' }; @@ -20,19 +21,13 @@ describe(` FEATURE: Analytics Adapters API SCENARIO: A publisher enables analytics AND an \`example\` instance of \`AnalyticsAdapter\`\n`, () => { - let xhr; - let requests; let adapter; beforeEach(function () { - xhr = sinon.useFakeXMLHttpRequest(); - requests = []; - xhr.onCreate = (request) => requests.push(request); adapter = new AnalyticsAdapter(config); }); afterEach(function () { - xhr.restore(); adapter.disableAnalytics(); }); @@ -42,7 +37,7 @@ FEATURE: Analytics Adapters API adapter.track({ eventType, args }); - let result = JSON.parse(requests[0].requestBody); + let result = JSON.parse(server.requests[0].requestBody); expect(result).to.deep.equal({args: {some: 'data'}, eventType: 'bidRequested'}); }); @@ -53,7 +48,7 @@ FEATURE: Analytics Adapters API events.emit(eventType, args); adapter.enableAnalytics(); - let result = JSON.parse(requests[0].requestBody); + let result = JSON.parse(server.requests[0].requestBody); expect(result).to.deep.equal({args: {wat: 'wot'}, eventType: 'bidResponse'}); }); @@ -73,7 +68,7 @@ FEATURE: Analytics Adapters API adapter.enableAnalytics(); events.emit(eventType, args); - let result = JSON.parse(requests[0].requestBody); + let result = JSON.parse(server.requests[0].requestBody); expect(result).to.deep.equal({args: {more: 'info'}, eventType: 'bidWon'}); }); @@ -84,7 +79,7 @@ FEATURE: Analytics Adapters API adapter.enableAnalytics(); events.emit(eventType, args); - let result = JSON.parse(requests[0].requestBody); + let result = JSON.parse(server.requests[0].requestBody); expect(result).to.deep.equal({args: {call: 'adRenderFailed'}, eventType: 'adRenderFailed'}); }); @@ -95,7 +90,7 @@ FEATURE: Analytics Adapters API adapter.enableAnalytics(); events.emit(eventType, args); - let result = JSON.parse(requests[0].requestBody); + let result = JSON.parse(server.requests[0].requestBody); expect(result).to.deep.equal({args: {call: 'addAdUnits'}, eventType: 'addAdUnits'}); }); @@ -106,7 +101,7 @@ FEATURE: Analytics Adapters API adapter.enableAnalytics(); events.emit(eventType, args); - let result = JSON.parse(requests[0].requestBody); + let result = JSON.parse(server.requests[0].requestBody); expect(result).to.deep.equal({args: {call: 'request'}, eventType: 'requestBids'}); }); @@ -117,7 +112,7 @@ FEATURE: Analytics Adapters API adapter.enableAnalytics(); events.emit(eventType, args); - let result = JSON.parse(requests[0].requestBody); + let result = JSON.parse(server.requests[0].requestBody); expect(result).to.deep.equal({args: {call: 'request'}, eventType: 'bidRequested'}); }); @@ -128,7 +123,7 @@ FEATURE: Analytics Adapters API adapter.enableAnalytics(); events.emit(eventType, args); - let result = JSON.parse(requests[0].requestBody); + let result = JSON.parse(server.requests[0].requestBody); expect(result).to.deep.equal({args: {call: 'response'}, eventType: 'bidResponse'}); }); @@ -139,7 +134,7 @@ FEATURE: Analytics Adapters API adapter.enableAnalytics(); events.emit(eventType, args); - let result = JSON.parse(requests[0].requestBody); + let result = JSON.parse(server.requests[0].requestBody); expect(result).to.deep.equal({args: {call: 'timeout'}, eventType: 'bidTimeout'}); }); @@ -151,7 +146,7 @@ FEATURE: Analytics Adapters API adapter.enableAnalytics(); events.emit(eventType, args); - expect(requests.length).to.equal(1); + expect(server.requests.length).to.equal(1); }); describe(`AND sampling is enabled\n`, function () { @@ -174,8 +169,8 @@ FEATURE: Analytics Adapters API }); events.emit(eventType, args); - expect(requests.length).to.equal(1); - let result = JSON.parse(requests[0].requestBody); + expect(server.requests.length).to.equal(1); + let result = JSON.parse(server.requests[0].requestBody); expect(result).to.deep.equal({args: {more: 'info'}, eventType: 'bidWon'}); }); @@ -187,7 +182,7 @@ FEATURE: Analytics Adapters API }); events.emit(eventType, args); - expect(requests.length).to.equal(0); + expect(server.requests.length).to.equal(0); }); }); }); diff --git a/test/spec/adapters/adbutler_spec.js b/test/spec/adapters/adbutler_spec.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/spec/adloader_spec.js b/test/spec/adloader_spec.js index 27f574c9c42..0c46cd2f171 100644 --- a/test/spec/adloader_spec.js +++ b/test/spec/adloader_spec.js @@ -1,5 +1,5 @@ -import * as utils from 'src/utils'; -import * as adLoader from 'test/mocks/adloaderStub'; +import * as utils from 'src/utils.js'; +import * as adLoader from 'test/mocks/adloaderStub.js'; describe('adLoader', function () { let utilsinsertElementStub; @@ -27,5 +27,16 @@ describe('adLoader', function () { expect(utilsLogErrorStub.called).to.be.false; expect(utilsinsertElementStub.called).to.be.true; }); + + it('should not load cached script again', function() { + adLoader.loadExternalScript('someURL', 'criteo'); + expect(utilsinsertElementStub.called).to.be.false; + }); + + it('callback function can be passed to the function', function() { + let callback = function() {}; + adLoader.loadExternalScript('someURL1', 'criteo', callback); + expect(utilsinsertElementStub.called).to.be.true; + }); }); }); diff --git a/test/spec/aliasBidder_spec.js b/test/spec/aliasBidder_spec.js index 61a654dcb90..771d7fcdd46 100644 --- a/test/spec/aliasBidder_spec.js +++ b/test/spec/aliasBidder_spec.js @@ -1,4 +1,4 @@ -import { pbjsTestOnly } from 'test/helpers/pbjs-test-only'; +import { pbjsTestOnly } from 'test/helpers/pbjs-test-only.js'; describe('Publisher API _ Alias Bidder', function () { var assert = require('chai').assert; diff --git a/test/spec/auctionmanager_spec.js b/test/spec/auctionmanager_spec.js index 970bc61cc61..3ec3d67e448 100644 --- a/test/spec/auctionmanager_spec.js +++ b/test/spec/auctionmanager_spec.js @@ -1,13 +1,14 @@ -import { getKeyValueTargetingPairs, auctionCallbacks, AUCTION_COMPLETED } from 'src/auction'; +import { getKeyValueTargetingPairs, auctionCallbacks, AUCTION_COMPLETED } from 'src/auction.js'; import CONSTANTS from 'src/constants.json'; -import { adjustBids, getMediaTypeGranularity } from 'src/auction'; -import * as auctionModule from 'src/auction'; -import { registerBidder } from 'src/adapters/bidderFactory'; -import { createBid } from 'src/bidfactory'; -import { config } from 'src/config'; -import * as store from 'src/videoCache'; -import * as ajaxLib from 'src/ajax'; -import find from 'core-js/library/fn/array/find'; +import { adjustBids, getMediaTypeGranularity } from 'src/auction.js'; +import * as auctionModule from 'src/auction.js'; +import { registerBidder } from 'src/adapters/bidderFactory.js'; +import { createBid } from 'src/bidfactory.js'; +import { config } from 'src/config.js'; +import * as store from 'src/videoCache.js'; +import * as ajaxLib from 'src/ajax.js'; +import find from 'core-js/library/fn/array/find.js'; +import { server } from 'test/mocks/xhr.js'; var assert = require('assert'); @@ -766,7 +767,6 @@ describe('auctionmanager.js', function () { describe('when auction timeout is 20', function () { let eventsEmitSpy; - let server; before(function () { bids = [mockBid(), mockBid({ bidderCode: BIDDER_CODE1 })]; @@ -776,8 +776,6 @@ describe('auctionmanager.js', function () { }); beforeEach(function () { - server = sinon.createFakeServer(); - adUnits = [{ code: ADUNIT_CODE, bids: [ @@ -789,7 +787,6 @@ describe('auctionmanager.js', function () { eventsEmitSpy = sinon.spy(events, 'emit'); }); afterEach(function () { - server.restore(); events.emit.restore(); }); @@ -985,6 +982,103 @@ describe('auctionmanager.js', function () { }); }); + describe('addBidRequests', function () { + let createAuctionStub; + let adUnits; + let adUnitCodes; + let spec; + let spec1; + let auction; + let ajaxStub; + let logMessageStub; + let logInfoStub; + let logWarnStub; + let logErrorStub; + + let bids = TEST_BIDS; + let bids1 = [mockBid({ bidderCode: BIDDER_CODE1 })]; + + before(function () { + logMessageStub = sinon.stub(utils, 'logMessage'); + logInfoStub = sinon.stub(utils, 'logInfo'); + logWarnStub = sinon.stub(utils, 'logWarn'); + logErrorStub = sinon.stub(utils, 'logError'); + let bidRequests = [ + mockBidRequest(bids[0]), + mockBidRequest(bids1[0], { adUnitCode: ADUNIT_CODE1 }) + ]; + let makeRequestsStub = sinon.stub(adapterManager, 'makeBidRequests'); + makeRequestsStub.returns(bidRequests); + + ajaxStub = sinon.stub(ajaxLib, 'ajaxBuilder').callsFake(mockAjaxBuilder); + }); + + after(function () { + logMessageStub.restore(); + logInfoStub.restore(); + logWarnStub.restore(); + logErrorStub.restore(); + ajaxStub.restore(); + adapterManager.makeBidRequests.restore(); + }); + + beforeEach(function () { + config.setConfig({ + debugging: { + enabled: true, + bidRequests: [{ + bidderCode: BIDDER_CODE, + adUnitCode: ADUNIT_CODE, + storedAuctionResponse: '11111' + }] + } + }); + + adUnits = [{ + code: ADUNIT_CODE, + bids: [ + {bidder: BIDDER_CODE, params: {placementId: 'id'}}, + ] + }, { + code: ADUNIT_CODE1, + bids: [ + {bidder: BIDDER_CODE1, params: {placementId: 'id'}}, + ] + }]; + adUnitCodes = adUnits.map(({ code }) => code); + auction = auctionModule.newAuction({adUnits, adUnitCodes, callback: function() {}, cbTimeout: 3000}); + createAuctionStub = sinon.stub(auctionModule, 'newAuction'); + createAuctionStub.returns(auction); + + spec = mockBidder(BIDDER_CODE, bids); + spec1 = mockBidder(BIDDER_CODE1, bids1); + + registerBidder(spec); + registerBidder(spec1); + }); + + afterEach(function () { + logMessageStub.resetHistory(); + logInfoStub.resetHistory(); + logWarnStub.resetHistory(); + logErrorStub.resetHistory(); + auctionModule.newAuction.restore(); + config.resetConfig(); + }); + + it('should override bidRequest properties when config debugging has a matching bidRequest defined', function () { + auction.callBids(); + const auctionBidRequests = auction.getBidRequests(); + assert.equal(auctionBidRequests.length > 0, true); + assert.equal(Array.isArray(auctionBidRequests[0].bids), true); + + const bid = find(auctionBidRequests[0].bids, bid => bid.adUnitCode === ADUNIT_CODE); + assert.equal(typeof bid !== 'undefined', true); + assert.equal(bid.hasOwnProperty('storedAuctionResponse'), true); + assert.equal(bid.storedAuctionResponse, '11111'); + }); + }); + describe('getMediaTypeGranularity', function () { it('video', function () { let bidReq = { @@ -1058,8 +1152,6 @@ describe('auctionmanager.js', function () { describe('auctionCallbacks', function() { let bids = TEST_BIDS; let bidRequests; - let xhr; - let requests; let doneSpy; let auction = { getBidRequests: () => bidRequests, @@ -1070,9 +1162,6 @@ describe('auctionmanager.js', function () { beforeEach(() => { doneSpy = sinon.spy(); - xhr = sinon.useFakeXMLHttpRequest(); - requests = []; - xhr.onCreate = (request) => requests.push(request); config.setConfig({ cache: { url: 'https://prebid.adnxs.com/pbc/v1/cache' @@ -1082,7 +1171,6 @@ describe('auctionmanager.js', function () { afterEach(() => { doneSpy.resetHistory(); - xhr.restore(); config.resetConfig(); }); @@ -1132,7 +1220,7 @@ describe('auctionmanager.js', function () { assert.equal(doneSpy.callCount, 0); const uuid = 'c488b101-af3e-4a99-b538-00423e5a3371'; const responseBody = `{"responses":[{"uuid":"${uuid}"}]}`; - requests[0].respond(200, { 'Content-Type': 'application/json' }, responseBody); + server.requests[0].respond(200, { 'Content-Type': 'application/json' }, responseBody); assert.equal(doneSpy.callCount, 1); }) }); diff --git a/test/spec/config_spec.js b/test/spec/config_spec.js index 8166b0f6d42..be5b4bbb78b 100644 --- a/test/spec/config_spec.js +++ b/test/spec/config_spec.js @@ -1,6 +1,6 @@ import { expect } from 'chai'; import { assert } from 'chai'; -import { newConfig } from 'src/config'; +import { newConfig } from 'src/config.js'; const utils = require('src/utils'); @@ -33,7 +33,7 @@ describe('config API', function () { expect(getConfig()).to.be.a('object'); }); - it('sets and gets arbitrary configuarion properties', function () { + it('sets and gets arbitrary configuration properties', function () { setConfig({ baz: 'qux' }); expect(getConfig('baz')).to.equal('qux'); }); @@ -139,7 +139,6 @@ describe('config API', function () { it('set mediaTypePriceGranularity', function () { const customPriceGranularityVideo = { 'buckets': [{ - 'min': 0, 'max': 3, 'increment': 0.01, 'cap': true @@ -169,7 +168,6 @@ describe('config API', function () { it('sets priceGranularity and customPriceBucket', function () { const goodConfig = { 'buckets': [{ - 'min': 0, 'max': 3, 'increment': 0.01, 'cap': true @@ -180,6 +178,23 @@ describe('config API', function () { expect(getConfig('customPriceBucket')).to.equal(goodConfig); }); + it('sets deviceAccess', function () { + // When the deviceAccess flag config option is not set, cookies may be read and set + expect(getConfig('deviceAccess')).to.be.equal(true); + + // When the deviceAccess flag config option is set to false, no cookies are read or set + setConfig({ + 'deviceAccess': false + }); + expect(getConfig('deviceAccess')).to.be.equal(false); + + // When the deviceAccess flag config option is set to true, cookies may be read and set + setConfig({ + 'deviceAccess': true + }); + expect(getConfig('deviceAccess')).to.be.equal(true); + }); + it('should log error for invalid priceGranularity', function () { setConfig({ priceGranularity: '' }); const error = 'Prebid Error: no value passed to `setPriceGranularity()`'; diff --git a/test/spec/cpmBucketManager_spec.js b/test/spec/cpmBucketManager_spec.js index 88e04be9ad6..0b8635a4e3b 100644 --- a/test/spec/cpmBucketManager_spec.js +++ b/test/spec/cpmBucketManager_spec.js @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import {getPriceBucketString, isValidPriceConfig} from 'src/cpmBucketManager'; +import {getPriceBucketString, isValidPriceConfig} from 'src/cpmBucketManager.js'; let cpmFixtures = require('test/fixtures/cpmInputsOutputs.json'); describe('cpmBucketManager', function () { @@ -17,13 +17,11 @@ describe('cpmBucketManager', function () { let customConfig = { 'buckets': [{ 'precision': 4, - 'min': 0, 'max': 3, 'increment': 0.01, }, { 'precision': 4, - 'min': 3, 'max': 18, 'increment': 0.05, 'cap': true @@ -40,13 +38,11 @@ describe('cpmBucketManager', function () { let customConfig = { 'buckets': [{ 'precision': 4, - 'min': 0, 'max': 4, 'increment': 0.01, }, { 'precision': 4, - 'min': 4, 'max': 18, 'increment': 0.3, 'cap': true @@ -63,13 +59,11 @@ describe('cpmBucketManager', function () { let customConfig = { 'buckets': [{ 'precision': 4, - 'min': 0, 'max': 3, 'increment': 0.01, }, { 'precision': 4, - 'min': 3, 'max': 18, 'increment': 0.05, 'cap': true @@ -85,7 +79,6 @@ describe('cpmBucketManager', function () { let customConfig = { 'buckets': [{ 'precision': 4, - 'min': 0, 'max': 4, 'increment': 0.10, }] @@ -103,7 +96,6 @@ describe('cpmBucketManager', function () { customConfig = { 'buckets': [{ 'precision': 3, - 'min': 0, 'max': 6, 'increment': 0.08, }] @@ -116,7 +108,6 @@ describe('cpmBucketManager', function () { customConfig = { 'buckets': [{ 'precision': 3, - 'min': 0, 'max': 6, 'increment': 0.05, }] @@ -134,7 +125,6 @@ describe('cpmBucketManager', function () { customConfig = { 'buckets': [{ 'precision': 2, - 'min': 0, 'max': 6, 'increment': 0.01, }] @@ -161,7 +151,6 @@ describe('cpmBucketManager', function () { 'buckets': [ { 'precision': 0, - 'min': 3, 'max': 18, 'increment': 0.05, } @@ -177,7 +166,6 @@ describe('cpmBucketManager', function () { let customConfig = { 'buckets': [ { - 'min': 3, 'max': 18, 'increment': 0.05, } @@ -191,14 +179,12 @@ describe('cpmBucketManager', function () { it('checks whether custom config is valid', function () { let badConfig = { 'buckets': [{ - 'min': 0, 'max': 3, 'increment': 0.01, }, { - // missing min prop 'max': 18, - 'increment': 0.05, + // missing increment prop 'cap': true } ] diff --git a/test/spec/debugging_spec.js b/test/spec/debugging_spec.js index ba9702b0324..bf49a579cbd 100644 --- a/test/spec/debugging_spec.js +++ b/test/spec/debugging_spec.js @@ -1,8 +1,8 @@ import { expect } from 'chai'; -import { sessionLoader, addBidResponseHook, getConfig, disableOverrides, boundHook } from 'src/debugging'; -import { addBidResponse } from 'src/auction'; -import { config } from 'src/config'; +import { sessionLoader, addBidResponseHook, addBidderRequestsHook, getConfig, disableOverrides, addBidResponseBound, addBidderRequestsBound } from 'src/debugging.js'; +import { addBidResponse, addBidderRequests } from 'src/auction.js'; +import { config } from 'src/config.js'; describe('bid overrides', function () { let sandbox; @@ -31,14 +31,16 @@ describe('bid overrides', function () { enabled: true }); - expect(addBidResponse.getHooks().some(hook => hook.hook === boundHook)).to.equal(true); + expect(addBidResponse.getHooks().some(hook => hook.hook === addBidResponseBound)).to.equal(true); + expect(addBidderRequests.getHooks().some(hook => hook.hook === addBidderRequestsBound)).to.equal(true); }); it('should happen when configuration found in sessionStorage', function () { sessionLoader({ getItem: () => ('{"enabled": true}') }); - expect(addBidResponse.getHooks().some(hook => hook.hook === boundHook)).to.equal(true); + expect(addBidResponse.getHooks().some(hook => hook.hook === addBidResponseBound)).to.equal(true); + expect(addBidderRequests.getHooks().some(hook => hook.hook === addBidderRequestsBound)).to.equal(true); }); it('should not throw if sessionStorage is inaccessible', function () { @@ -52,7 +54,7 @@ describe('bid overrides', function () { }); }); - describe('hook', function () { + describe('bidResponse hook', function () { let mockBids; let bids; @@ -84,7 +86,7 @@ describe('bid overrides', function () { let next = (adUnitCode, bid) => { bids.push(bid); }; - addBidResponseHook.bind(overrides)(next, bid.adUnitCode, bid) + addBidResponseHook.bind(overrides)(next, bid.adUnitCode, bid); }); } @@ -141,4 +143,51 @@ describe('bid overrides', function () { expect(bids[1].cpm).to.equal(2); }); }); + + describe('bidRequests hook', function () { + let mockBidRequests; + let bidderRequests; + + beforeEach(function () { + let baseBidderRequest = { + 'bidderCode': 'rubicon', + 'bids': [{ + 'width': 970, + 'height': 250, + 'statusMessage': 'Bid available', + 'mediaType': 'banner', + 'source': 'client', + 'currency': 'USD', + 'cpm': 0.5, + 'ttl': 300, + 'netRevenue': false, + 'adUnitCode': '/19968336/header-bid-tag-0' + }] + }; + mockBidRequests = []; + mockBidRequests.push(baseBidderRequest); + mockBidRequests.push(Object.assign({}, baseBidderRequest, { + bidderCode: 'appnexus' + })); + + bidderRequests = []; + }); + + function run(overrides) { + let next = (b) => { + bidderRequests = b; + }; + addBidderRequestsHook.bind(overrides)(next, mockBidRequests); + } + + it('should allow us to exclude bidders', function () { + run({ + enabled: true, + bidders: ['appnexus'] + }); + + expect(bidderRequests.length).to.equal(1); + expect(bidderRequests[0].bidderCode).to.equal('appnexus'); + }); + }); }); diff --git a/test/spec/e2e/instream/basic_instream_video_ad.spec.js b/test/spec/e2e/instream/basic_instream_video_ad.spec.js new file mode 100644 index 00000000000..034363685d2 --- /dev/null +++ b/test/spec/e2e/instream/basic_instream_video_ad.spec.js @@ -0,0 +1,52 @@ +const expect = require('chai').expect; +const { host, protocol } = require('../../../helpers/testing-utils'); + +const TEST_PAGE_URL = `${protocol}://${host}:9999/test/pages/instream.html?pbjs_debug=true`; +const CREATIVE_IFRAME_CSS_SELECTOR = 'div[class="VPAID-container"] > div > iframe'; + +const EXPECTED_TARGETING_KEYS = { + hb_cache_id: '', + hb_uuid: '', + hb_format: 'video', + hb_source: 'client', + hb_size: '640x480', + hb_pb: '10.00', + hb_bidder: 'appnexus', + hb_format_appnexus: 'video', + hb_source_appnexus: 'client', + hb_size_appnexus: '640x480', + hb_pb_appnexus: '10.00', + hb_bidder_appnexus: 'appnexus' +}; + +describe('Prebid.js Instream Video Ad Test', function () { + before(function loadTestPage() { + browser + .url(TEST_PAGE_URL) + try { + browser.waitForExist(CREATIVE_IFRAME_CSS_SELECTOR, 5000); + // const creativeIframe = $(CREATIVE_IFRAME_CSS_SELECTOR).value; + // browser.frame(creativeIframe); + } catch (e) { + // If creative Iframe didn't load, repeat the steps again! + // Due to some reason if the Ad server doesn't respond, the test case will time out after 60000 ms as defined in file wdio.conf.js + loadTestPage(); + } + }); + + // it('should load the targeting keys with correct values', function () { + // const result = browser.execute(function () { + // console.log('pbjs::', window.top.pbjs); + // return window.top.pbjs.getAdserverTargeting('video1'); + // }); + // console.log('result:::', result); + // const targetingKeys = result.value['vid1']; + // expect(targetingKeys).to.include(EXPECTED_TARGETING_KEYS); + // expect(targetingKeys.hb_adid).to.be.a('string'); + // expect(targetingKeys.hb_adid_appnexus).to.be.a('string'); + // }); + + it('should render the instream ad on the page', function() { + expect(browser.isVisible(CREATIVE_IFRAME_CSS_SELECTOR)); + }); +}); diff --git a/test/spec/e2e/modules/e2e_bidderSettings.spec.js b/test/spec/e2e/modules/e2e_bidderSettings.spec.js new file mode 100644 index 00000000000..d9f1d18725d --- /dev/null +++ b/test/spec/e2e/modules/e2e_bidderSettings.spec.js @@ -0,0 +1,59 @@ +const expect = require('chai').expect; +const { host, protocol } = require('../../../helpers/testing-utils'); + +const TEST_PAGE_URL = `${protocol}://${host}:9999/test/pages/bidderSettings.html?pbjs_debug=true`; +const CREATIVE_IFRAME_CSS_SELECTOR = 'iframe[id="google_ads_iframe_/19968336/header-bid-tag-0_0"]'; + +const EXPECTED_TARGETING_KEYS = { + hb_source: 'client', + hb_source_appnexus: 'client', + hb_pb_appnexus: '10.00', + hb_native_title_appn: 'This is a Prebid Native Creative', + hb_native_linkurl: 'http://prebid.org/dev-docs/show-native-ads.html', + hb_format: 'native', + hb_native_brand: 'Prebid.org', + hb_size: '0x0', + hb_bidder_appnexus: 'appnexus', + hb_native_linkurl_ap: 'http://prebid.org/dev-docs/show-native-ads.html', + hb_native_title: 'This is a Prebid Native Creative', + hb_pb: '10.00', + hb_native_brand_appn: 'Prebid.org', + hb_bidder: 'appnexus', + hb_format_appnexus: 'native', + hb_size_appnexus: '0x0' +} + +describe('Prebid.js Bidder Settings Ad Unit Test', function () { + before(function loadTestPage() { + browser.url(TEST_PAGE_URL).pause(3000); + try { + browser.waitForExist(CREATIVE_IFRAME_CSS_SELECTOR, 2000); + const creativeIframe = $(CREATIVE_IFRAME_CSS_SELECTOR).value; + browser.frame(creativeIframe); + } catch (e) { + // If creative Iframe didn't load, repeat the steps again! + // Due to some reason if the Ad server doesn't respond, the test case will time out after 60000 ms as defined in file wdio.conf.js + loadTestPage(); + } + }); + + it('should load the targeting keys with correct values', function () { + const result = browser.execute(function () { + return window.top.pbjs.getAdserverTargeting('/19968336/prebid_native_example_2'); + }); + + const targetingKeys = result.value['/19968336/prebid_native_example_2']; + expect(targetingKeys).to.include(EXPECTED_TARGETING_KEYS); + expect(targetingKeys.hb_adid).to.be.a('string'); + expect(targetingKeys.hb_native_body).to.be.a('string'); + expect(targetingKeys.hb_native_body_appne).to.be.a('string'); + expect(targetingKeys.hb_native_icon).to.be.a('string'); + expect(targetingKeys.hb_native_icon_appne).to.be.a('string'); + expect(targetingKeys.hb_native_image).to.be.a('string'); + expect(targetingKeys.hb_adid_appnexus).to.be.a('string'); + }); + + it('should render the Banner Ad on the page', function () { + expect(browser.isVisible('body > div[class="GoogleActiveViewElement"] > a > img')).to.be.true; + }); +}); diff --git a/test/spec/e2e/modules/e2e_consent_mgt_gdpr.spec.js b/test/spec/e2e/modules/e2e_consent_mgt_gdpr.spec.js new file mode 100644 index 00000000000..1c11a5432ff --- /dev/null +++ b/test/spec/e2e/modules/e2e_consent_mgt_gdpr.spec.js @@ -0,0 +1,59 @@ +const expect = require('chai').expect; +const { host, protocol } = require('../../../helpers/testing-utils'); + +const TEST_PAGE_URL = `${protocol}://${host}:9999/test/pages/consent_mgt_gdpr.html?pbjs_debug=true`; +const CREATIVE_IFRAME_CSS_SELECTOR = 'iframe[id="google_ads_iframe_/19968336/header-bid-tag-0_0"]'; + +const EXPECTED_TARGETING_KEYS = { + hb_source: 'client', + hb_source_appnexus: 'client', + hb_pb_appnexus: '10.00', + hb_native_title_appn: 'This is a Prebid Native Creative', + hb_native_linkurl: 'http://prebid.org/dev-docs/show-native-ads.html', + hb_format: 'native', + hb_native_brand: 'Prebid.org', + hb_size: '0x0', + hb_bidder_appnexus: 'appnexus', + hb_native_linkurl_ap: 'http://prebid.org/dev-docs/show-native-ads.html', + hb_native_title: 'This is a Prebid Native Creative', + hb_pb: '10.00', + hb_native_brand_appn: 'Prebid.org', + hb_bidder: 'appnexus', + hb_format_appnexus: 'native', + hb_size_appnexus: '0x0' +}; + +describe('Prebid.js GDPR Ad Unit Test', function () { + before(function loadTestPage() { + browser.url(TEST_PAGE_URL).pause(3000); + try { + browser.waitForExist(CREATIVE_IFRAME_CSS_SELECTOR, 2000); + const creativeIframe = $(CREATIVE_IFRAME_CSS_SELECTOR).value; + browser.frame(creativeIframe); + } catch (e) { + // If creative Iframe didn't load, repeat the steps again! + // Due to some reason if the Ad server doesn't respond, the test case will time out after 60000 ms as defined in file wdio.conf.js + loadTestPage(); + } + }); + + it('should load the targeting keys with correct values', function () { + const result = browser.execute(function () { + return window.top.pbjs.getAdserverTargeting('/19968336/prebid_native_example_2'); + }); + + const targetingKeys = result.value['/19968336/prebid_native_example_2']; + expect(targetingKeys).to.include(EXPECTED_TARGETING_KEYS); + expect(targetingKeys.hb_adid).to.be.a('string'); + expect(targetingKeys.hb_native_body).to.be.a('string'); + expect(targetingKeys.hb_native_body_appne).to.be.a('string'); + expect(targetingKeys.hb_native_icon).to.be.a('string'); + expect(targetingKeys.hb_native_icon_appne).to.be.a('string'); + expect(targetingKeys.hb_native_image).to.be.a('string'); + expect(targetingKeys.hb_adid_appnexus).to.be.a('string'); + }); + + it('should render the Banner Ad on the page', function () { + expect(browser.isVisible('body > div[class="GoogleActiveViewElement"] > a > img')).to.be.true; + }); +}); diff --git a/test/spec/e2e/modules/e2e_currency.spec.js b/test/spec/e2e/modules/e2e_currency.spec.js new file mode 100644 index 00000000000..8692b4991bd --- /dev/null +++ b/test/spec/e2e/modules/e2e_currency.spec.js @@ -0,0 +1,59 @@ +const expect = require('chai').expect; +const { host, protocol } = require('../../../helpers/testing-utils'); + +const TEST_PAGE_URL = `${protocol}://${host}:9999/test/pages/currency.html?pbjs_debug=true`; +const CREATIVE_IFRAME_CSS_SELECTOR = 'iframe[id="google_ads_iframe_/19968336/header-bid-tag-0_0"]'; + +const EXPECTED_TARGETING_KEYS = { + hb_source: 'client', + hb_source_appnexus: 'client', + hb_pb_appnexus: '7.50', + hb_native_title_appn: 'This is a Prebid Native Creative', + hb_native_linkurl: 'http://prebid.org/dev-docs/show-native-ads.html', + hb_format: 'native', + hb_native_brand: 'Prebid.org', + hb_size: '0x0', + hb_bidder_appnexus: 'appnexus', + hb_native_linkurl_ap: 'http://prebid.org/dev-docs/show-native-ads.html', + hb_native_title: 'This is a Prebid Native Creative', + hb_pb: '7.50', + hb_native_brand_appn: 'Prebid.org', + hb_bidder: 'appnexus', + hb_format_appnexus: 'native', + hb_size_appnexus: '0x0' +} + +describe('Prebid.js Currency Ad Unit Test', function () { + before(function loadTestPage() { + browser.url(TEST_PAGE_URL).pause(3000); + try { + browser.waitForExist(CREATIVE_IFRAME_CSS_SELECTOR, 2000); + const creativeIframe = $(CREATIVE_IFRAME_CSS_SELECTOR).value; + browser.frame(creativeIframe); + } catch (e) { + // If creative Iframe didn't load, repeat the steps again! + // Due to some reason if the Ad server doesn't respond, the test case will time out after 60000 ms as defined in file wdio.conf.js + loadTestPage(); + } + }); + + it('should load the targeting keys with correct values', function () { + const result = browser.execute(function () { + return window.top.pbjs.getAdserverTargeting('/19968336/prebid_native_example_2'); + }); + + const targetingKeys = result.value['/19968336/prebid_native_example_2']; + expect(targetingKeys).to.include(EXPECTED_TARGETING_KEYS); + expect(targetingKeys.hb_adid).to.be.a('string'); + expect(targetingKeys.hb_native_body).to.be.a('string'); + expect(targetingKeys.hb_native_body_appne).to.be.a('string'); + expect(targetingKeys.hb_native_icon).to.be.a('string'); + expect(targetingKeys.hb_native_icon_appne).to.be.a('string'); + expect(targetingKeys.hb_native_image).to.be.a('string'); + expect(targetingKeys.hb_adid_appnexus).to.be.a('string'); + }); + + it('should render the Banner Ad on the page', function () { + expect(browser.isVisible('body > div[class="GoogleActiveViewElement"] > a > img')).to.be.true; + }); +}); diff --git a/test/spec/e2e/modules/e2e_priceGranularity.spec.js b/test/spec/e2e/modules/e2e_priceGranularity.spec.js new file mode 100644 index 00000000000..1042ab491fb --- /dev/null +++ b/test/spec/e2e/modules/e2e_priceGranularity.spec.js @@ -0,0 +1,59 @@ +const expect = require('chai').expect; +const { host, protocol } = require('../../../helpers/testing-utils'); + +const TEST_PAGE_URL = `${protocol}://${host}:9999/test/pages/priceGranularity.html?pbjs_debug=true`; +const CREATIVE_IFRAME_CSS_SELECTOR = 'iframe[id="google_ads_iframe_/19968336/header-bid-tag-0_0"]'; + +const EXPECTED_TARGETING_KEYS = { + hb_source: 'client', + hb_source_appnexus: 'client', + hb_pb_appnexus: '10.00', + hb_native_title_appn: 'This is a Prebid Native Creative', + hb_native_linkurl: 'http://prebid.org/dev-docs/show-native-ads.html', + hb_format: 'native', + hb_native_brand: 'Prebid.org', + hb_size: '0x0', + hb_bidder_appnexus: 'appnexus', + hb_native_linkurl_ap: 'http://prebid.org/dev-docs/show-native-ads.html', + hb_native_title: 'This is a Prebid Native Creative', + hb_pb: '10.00', + hb_native_brand_appn: 'Prebid.org', + hb_bidder: 'appnexus', + hb_format_appnexus: 'native', + hb_size_appnexus: '0x0' +} + +describe('Prebid.js Price Granularity Ad Unit Test', function () { + before(function loadTestPage() { + browser.url(TEST_PAGE_URL).pause(3000); + try { + browser.waitForExist(CREATIVE_IFRAME_CSS_SELECTOR, 2000); + const creativeIframe = $(CREATIVE_IFRAME_CSS_SELECTOR).value; + browser.frame(creativeIframe); + } catch (e) { + // If creative Iframe didn't load, repeat the steps again! + // Due to some reason if the Ad server doesn't respond, the test case will time out after 60000 ms as defined in file wdio.conf.js + loadTestPage(); + } + }); + + it('should load the targeting keys with correct values', function () { + const result = browser.execute(function () { + return window.top.pbjs.getAdserverTargeting('/19968336/prebid_native_example_2'); + }); + + const targetingKeys = result.value['/19968336/prebid_native_example_2']; + expect(targetingKeys).to.include(EXPECTED_TARGETING_KEYS); + expect(targetingKeys.hb_adid).to.be.a('string'); + expect(targetingKeys.hb_native_body).to.be.a('string'); + expect(targetingKeys.hb_native_body_appne).to.be.a('string'); + expect(targetingKeys.hb_native_icon).to.be.a('string'); + expect(targetingKeys.hb_native_icon_appne).to.be.a('string'); + expect(targetingKeys.hb_native_image).to.be.a('string'); + expect(targetingKeys.hb_adid_appnexus).to.be.a('string'); + }); + + it('should render the Banner Ad on the page', function () { + expect(browser.isVisible('body > div[class="GoogleActiveViewElement"] > a > img')).to.be.true; + }); +}); diff --git a/test/spec/e2e/modules/e2e_sizeConfig.spec.js b/test/spec/e2e/modules/e2e_sizeConfig.spec.js new file mode 100644 index 00000000000..1eb3fad8dea --- /dev/null +++ b/test/spec/e2e/modules/e2e_sizeConfig.spec.js @@ -0,0 +1,59 @@ +const expect = require('chai').expect; +const { host, protocol } = require('../../../helpers/testing-utils'); + +const TEST_PAGE_URL = `${protocol}://${host}:9999/test/pages/sizeConfig.html?pbjs_debug=true`; +const CREATIVE_IFRAME_CSS_SELECTOR = 'iframe[id="google_ads_iframe_/19968336/header-bid-tag-0_0"]'; + +const EXPECTED_TARGETING_KEYS = { + hb_source: 'client', + hb_source_appnexus: 'client', + hb_pb_appnexus: '10.00', + hb_native_title_appn: 'This is a Prebid Native Creative', + hb_native_linkurl: 'http://prebid.org/dev-docs/show-native-ads.html', + hb_format: 'native', + hb_native_brand: 'Prebid.org', + hb_size: '0x0', + hb_bidder_appnexus: 'appnexus', + hb_native_linkurl_ap: 'http://prebid.org/dev-docs/show-native-ads.html', + hb_native_title: 'This is a Prebid Native Creative', + hb_pb: '10.00', + hb_native_brand_appn: 'Prebid.org', + hb_bidder: 'appnexus', + hb_format_appnexus: 'native', + hb_size_appnexus: '0x0' +} + +describe('Prebid.js Size Config Ad Unit Test', function () { + before(function loadTestPage() { + browser.url(TEST_PAGE_URL).pause(3000); + try { + browser.waitForExist(CREATIVE_IFRAME_CSS_SELECTOR, 2000); + const creativeIframe = $(CREATIVE_IFRAME_CSS_SELECTOR).value; + browser.frame(creativeIframe); + } catch (e) { + // If creative Iframe didn't load, repeat the steps again! + // Due to some reason if the Ad server doesn't respond, the test case will time out after 60000 ms as defined in file wdio.conf.js + loadTestPage(); + } + }); + + it('should load the targeting keys with correct values', function () { + const result = browser.execute(function () { + return window.top.pbjs.getAdserverTargeting('/19968336/prebid_native_example_2'); + }); + + const targetingKeys = result.value['/19968336/prebid_native_example_2']; + expect(targetingKeys).to.include(EXPECTED_TARGETING_KEYS); + expect(targetingKeys.hb_adid).to.be.a('string'); + expect(targetingKeys.hb_native_body).to.be.a('string'); + expect(targetingKeys.hb_native_body_appne).to.be.a('string'); + expect(targetingKeys.hb_native_icon).to.be.a('string'); + expect(targetingKeys.hb_native_icon_appne).to.be.a('string'); + expect(targetingKeys.hb_native_image).to.be.a('string'); + expect(targetingKeys.hb_adid_appnexus).to.be.a('string'); + }); + + it('should render the Banner Ad on the page', function () { + expect(browser.isVisible('body > div[class="GoogleActiveViewElement"] > a > img')).to.be.true; + }); +}); diff --git a/test/spec/e2e/modules/e2e_userSync.spec.js b/test/spec/e2e/modules/e2e_userSync.spec.js new file mode 100644 index 00000000000..3957f3cdfef --- /dev/null +++ b/test/spec/e2e/modules/e2e_userSync.spec.js @@ -0,0 +1,59 @@ +const expect = require('chai').expect; +const { host, protocol } = require('../../../helpers/testing-utils'); + +const TEST_PAGE_URL = `${protocol}://${host}:9999/test/pages/userSync.html?pbjs_debug=true`; +const CREATIVE_IFRAME_CSS_SELECTOR = 'iframe[id="google_ads_iframe_/19968336/header-bid-tag-0_0"]'; + +const EXPECTED_TARGETING_KEYS = { + hb_source: 'client', + hb_source_appnexus: 'client', + hb_pb_appnexus: '10.00', + hb_native_title_appn: 'This is a Prebid Native Creative', + hb_native_linkurl: 'http://prebid.org/dev-docs/show-native-ads.html', + hb_format: 'native', + hb_native_brand: 'Prebid.org', + hb_size: '0x0', + hb_bidder_appnexus: 'appnexus', + hb_native_linkurl_ap: 'http://prebid.org/dev-docs/show-native-ads.html', + hb_native_title: 'This is a Prebid Native Creative', + hb_pb: '10.00', + hb_native_brand_appn: 'Prebid.org', + hb_bidder: 'appnexus', + hb_format_appnexus: 'native', + hb_size_appnexus: '0x0' +} + +describe('Prebid.js User Sync Ad Unit Test', function () { + before(function loadTestPage() { + browser.url(TEST_PAGE_URL).pause(3000); + try { + browser.waitForExist(CREATIVE_IFRAME_CSS_SELECTOR, 2000); + const creativeIframe = $(CREATIVE_IFRAME_CSS_SELECTOR).value; + browser.frame(creativeIframe); + } catch (e) { + // If creative Iframe didn't load, repeat the steps again! + // Due to some reason if the Ad server doesn't respond, the test case will time out after 60000 ms as defined in file wdio.conf.js + loadTestPage(); + } + }); + + it('should load the targeting keys with correct values', function () { + const result = browser.execute(function () { + return window.top.pbjs.getAdserverTargeting('/19968336/prebid_native_example_2'); + }); + + const targetingKeys = result.value['/19968336/prebid_native_example_2']; + expect(targetingKeys).to.include(EXPECTED_TARGETING_KEYS); + expect(targetingKeys.hb_adid).to.be.a('string'); + expect(targetingKeys.hb_native_body).to.be.a('string'); + expect(targetingKeys.hb_native_body_appne).to.be.a('string'); + expect(targetingKeys.hb_native_icon).to.be.a('string'); + expect(targetingKeys.hb_native_icon_appne).to.be.a('string'); + expect(targetingKeys.hb_native_image).to.be.a('string'); + expect(targetingKeys.hb_adid_appnexus).to.be.a('string'); + }); + + it('should render the Banner Ad on the page', function () { + expect(browser.isVisible('body > div[class="GoogleActiveViewElement"] > a > img')).to.be.true; + }); +}); diff --git a/test/spec/e2e/multi-format/e2e_multiple_bidders.spec.js b/test/spec/e2e/multi-format/e2e_multiple_bidders.spec.js new file mode 100644 index 00000000000..4ce750bdd96 --- /dev/null +++ b/test/spec/e2e/multi-format/e2e_multiple_bidders.spec.js @@ -0,0 +1,68 @@ +const expect = require('chai').expect; +const { host, protocol } = require('../../../helpers/testing-utils'); + +const TEST_PAGE_URL = `${protocol}://${host}:9999/test/pages/multiple_bidders.html?pbjs_debug=true`; +const CREATIVE_BANNER_CSS_SELECTOR = 'iframe[id="google_ads_iframe_/19968336/prebid_multiformat_test_0"]'; +const CREATIVE_NATIVE_CSS_SELECTOR = 'iframe[id="google_ads_iframe_/19968336/prebid_multiformat_test_1"]'; + +const EXPECTED_TARGETING_KEYS = { + hb_source: 'client', + hb_source_appnexus: 'client', + hb_pb_appnexus: '10.00', + hb_native_title_appn: 'This is a Prebid Native Creative', + hb_native_linkurl: 'http://prebid.org/dev-docs/show-native-ads.html', + hb_format: 'native', + hb_native_brand: 'Prebid.org', + hb_size: '0x0', + hb_bidder_appnexus: 'appnexus', + hb_native_linkurl_ap: 'http://prebid.org/dev-docs/show-native-ads.html', + hb_native_title: 'This is a Prebid Native Creative', + hb_pb: '10.00', + hb_native_brand_appn: 'Prebid.org', + hb_bidder: 'appnexus', + hb_format_appnexus: 'native', + hb_size_appnexus: '0x0' +}; + +describe('Prebid.js Multiple Bidder Ad Unit Test', function () { + before(function loadTestPage() { + browser.url(TEST_PAGE_URL).pause(3000); + try { + browser.waitForExist(CREATIVE_BANNER_CSS_SELECTOR, 3000); + const creativeIframe = $(CREATIVE_BANNER_CSS_SELECTOR).value; + browser.frame(creativeIframe); + } catch (e) { + // If creative Iframe didn't load, repeat the steps again! + // Due to some reason if the Ad server doesn't respond, the test case will time out after 60000 ms as defined in file wdio.conf.js + loadTestPage(); + } + }); + + it('should load the targeting keys with correct values', function () { + const result = browser.execute(function () { + return window.top.pbjs.getAdserverTargeting('/19968336/prebid_native_example_2'); + }); + + const targetingKeys = result.value['/19968336/prebid_native_example_2']; + expect(targetingKeys).to.include(EXPECTED_TARGETING_KEYS); + expect(targetingKeys.hb_adid).to.be.a('string'); + expect(targetingKeys.hb_native_body).to.be.a('string'); + expect(targetingKeys.hb_native_body_appne).to.be.a('string'); + expect(targetingKeys.hb_native_icon).to.be.a('string'); + expect(targetingKeys.hb_native_icon_appne).to.be.a('string'); + expect(targetingKeys.hb_native_image).to.be.a('string'); + expect(targetingKeys.hb_adid_appnexus).to.be.a('string'); + }); + + it('should render the Banner Ad on the page', function () { + expect(browser.isVisible('body > div[class="GoogleActiveViewElement"] > a > img')).to.be.true; + }); + + it('should render the native ad on the page', function () { + browser.frameParent(); + browser.waitForExist(CREATIVE_NATIVE_CSS_SELECTOR, 3000); + const creativeIframe = $(CREATIVE_NATIVE_CSS_SELECTOR).value; + browser.frame(creativeIframe); + expect(browser.isVisible('body > div[class="GoogleActiveViewElement"] > div[class="card"]')).to.be.true; + }); +}); diff --git a/test/spec/e2e/native/basic_native_ad.spec.js b/test/spec/e2e/native/basic_native_ad.spec.js index ed09228b532..8eb9a5940a0 100644 --- a/test/spec/e2e/native/basic_native_ad.spec.js +++ b/test/spec/e2e/native/basic_native_ad.spec.js @@ -37,7 +37,7 @@ describe('Prebid.js Native Ad Unit Test', function () { it('should load the targeting keys with correct values', function () { const result = browser.execute(function () { - return window.pbjs.getAdserverTargeting('/19968336/prebid_native_example_2'); + return window.top.pbjs.getAdserverTargeting('/19968336/prebid_native_example_2'); }); const targetingKeys = result.value['/19968336/prebid_native_example_2']; diff --git a/test/spec/integration/faker/fixtures.js b/test/spec/integration/faker/fixtures.js index 643b531ad42..a11bd126d61 100644 --- a/test/spec/integration/faker/fixtures.js +++ b/test/spec/integration/faker/fixtures.js @@ -1,5 +1,5 @@ import faker from 'faker'; -import { makeSlot } from './googletag'; +import { makeSlot } from './googletag.js'; export function makeAdSlot(overrides = {}) { return Object.assign(makeSlot( diff --git a/test/spec/integration/faker/googletag.js b/test/spec/integration/faker/googletag.js index b043b5321cb..a0ce04402f7 100644 --- a/test/spec/integration/faker/googletag.js +++ b/test/spec/integration/faker/googletag.js @@ -1,5 +1,5 @@ import faker from 'faker'; -import { randomFive } from './fixtures'; +import { randomFive } from './fixtures.js'; var Slot = function Slot({ code, divId }) { code = code || `ad-slot-code-${randomFive()}`; diff --git a/test/spec/modules/1ad4goodBidAdapter_spec.js b/test/spec/modules/1ad4goodBidAdapter_spec.js index 316a5c13233..b9cd86a4cf7 100644 --- a/test/spec/modules/1ad4goodBidAdapter_spec.js +++ b/test/spec/modules/1ad4goodBidAdapter_spec.js @@ -1,9 +1,9 @@ import { expect } from 'chai'; -import { spec } from 'modules/1ad4goodBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; -import * as bidderFactory from 'src/adapters/bidderFactory'; -import { deepClone } from 'src/utils'; -import { config } from 'src/config'; +import { spec } from 'modules/1ad4goodBidAdapter.js'; +import { newBidder } from 'src/adapters/bidderFactory.js'; +import * as bidderFactory from 'src/adapters/bidderFactory.js'; +import { deepClone } from 'src/utils.js'; +import { config } from 'src/config.js'; const ENDPOINT = 'https://hb.1ad4good.org/prebid'; diff --git a/test/spec/modules/33acrossBidAdapter_spec.js b/test/spec/modules/33acrossBidAdapter_spec.js index 5507b9c1cbc..d27cc99b5bc 100644 --- a/test/spec/modules/33acrossBidAdapter_spec.js +++ b/test/spec/modules/33acrossBidAdapter_spec.js @@ -1,9 +1,9 @@ import { expect } from 'chai'; -import * as utils from 'src/utils'; -import { config } from 'src/config'; +import * as utils from 'src/utils.js'; +import { config } from 'src/config.js'; -import { spec } from 'modules/33acrossBidAdapter'; +import { spec } from 'modules/33acrossBidAdapter.js'; describe('33acrossBidAdapter:', function () { const BIDDER_CODE = '33across'; @@ -75,7 +75,7 @@ describe('33acrossBidAdapter:', function () { return this; }; - this.withViewabiliuty = viewability => { + this.withViewability = viewability => { Object.assign(ttxRequest.imp[0].banner, { ext: { ttx: { viewability } @@ -103,6 +103,14 @@ describe('33acrossBidAdapter:', function () { return this; }; + this.withPageUrl = pageUrl => { + Object.assign(ttxRequest.site, { + page: pageUrl + }); + + return this; + }; + this.build = () => ttxRequest; } @@ -267,7 +275,7 @@ describe('33acrossBidAdapter:', function () { context('when element is fully in view', function() { it('returns 100', function() { const ttxRequest = new TtxRequestBuilder() - .withViewabiliuty({amount: 100}) + .withViewability({amount: 100}) .build(); const serverRequest = new ServerRequestBuilder() .withData(ttxRequest) @@ -282,7 +290,7 @@ describe('33acrossBidAdapter:', function () { context('when element is out of view', function() { it('returns 0', function() { const ttxRequest = new TtxRequestBuilder() - .withViewabiliuty({amount: 0}) + .withViewability({amount: 0}) .build(); const serverRequest = new ServerRequestBuilder() .withData(ttxRequest) @@ -297,7 +305,7 @@ describe('33acrossBidAdapter:', function () { context('when element is partially in view', function() { it('returns percentage', function() { const ttxRequest = new TtxRequestBuilder() - .withViewabiliuty({amount: 75}) + .withViewability({amount: 75}) .build(); const serverRequest = new ServerRequestBuilder() .withData(ttxRequest) @@ -313,7 +321,7 @@ describe('33acrossBidAdapter:', function () { it('try to use alternative values', function() { const ttxRequest = new TtxRequestBuilder() .withSizes([{ w: 800, h: 2400, ext: {} }]) - .withViewabiliuty({amount: 25}) + .withViewability({amount: 25}) .build(); const serverRequest = new ServerRequestBuilder() .withData(ttxRequest) @@ -329,7 +337,7 @@ describe('33acrossBidAdapter:', function () { context('when nested iframes', function() { it('returns \'nm\'', function() { const ttxRequest = new TtxRequestBuilder() - .withViewabiliuty({amount: spec.NON_MEASURABLE}) + .withViewability({amount: spec.NON_MEASURABLE}) .build(); const serverRequest = new ServerRequestBuilder() .withData(ttxRequest) @@ -349,7 +357,7 @@ describe('33acrossBidAdapter:', function () { context('when tab is inactive', function() { it('returns 0', function() { const ttxRequest = new TtxRequestBuilder() - .withViewabiliuty({amount: 0}) + .withViewability({amount: 0}) .build(); const serverRequest = new ServerRequestBuilder() .withData(ttxRequest) @@ -445,6 +453,45 @@ describe('33acrossBidAdapter:', function () { expect(builtServerRequests).to.deep.equal([serverRequest]); }); }); + + context('when referer value is available', function() { + it('returns corresponding server requests with site.page set', function() { + const bidderRequest = { + refererInfo: { + referer: 'http://foo.com/bar' + } + }; + + const ttxRequest = new TtxRequestBuilder() + .withPageUrl('http://foo.com/bar') + .build(); + const serverRequest = new ServerRequestBuilder() + .withData(ttxRequest) + .build(); + + const builtServerRequests = spec.buildRequests(bidRequests, bidderRequest); + + expect(builtServerRequests).to.deep.equal([serverRequest]); + }); + }); + + context('when referer value is not available', function() { + it('returns corresponding server requests without site.page set', function() { + const bidderRequest = { + refererInfo: {} + }; + + const ttxRequest = new TtxRequestBuilder() + .build(); + const serverRequest = new ServerRequestBuilder() + .withData(ttxRequest) + .build(); + + const builtServerRequests = spec.buildRequests(bidRequests, bidderRequest); + + expect(builtServerRequests).to.deep.equal([serverRequest]); + }); + }); }); describe('interpretResponse', function() { @@ -454,11 +501,11 @@ describe('33acrossBidAdapter:', function () { ttxRequest = new TtxRequestBuilder() .withSite({ id: SITE_ID, - page: 'http://test-url.com' + page: 'https://test-url.com' }) .build(); serverRequest = new ServerRequestBuilder() - .withUrl('//staging-ssc.33across.com/api/v1/hb') + .withUrl('https://staging-ssc.33across.com/api/v1/hb') .withData(ttxRequest) .withOptions({ contentType: 'text/plain', diff --git a/test/spec/modules/7xbidBidAdapter_spec.js b/test/spec/modules/7xbidBidAdapter_spec.js index 4f32e96ce93..bed2c604349 100644 --- a/test/spec/modules/7xbidBidAdapter_spec.js +++ b/test/spec/modules/7xbidBidAdapter_spec.js @@ -1,7 +1,6 @@ import {expect} from 'chai'; -import {spec, _getUrlVars} from 'modules/7xbidBidAdapter'; -import * as utils from 'src/utils'; -import {config} from 'src/config'; +import {spec, _getUrlVars} from 'modules/7xbidBidAdapter.js'; +import * as utils from 'src/utils.js'; const BASE_URI = '//bidder.7xbid.com/api/v1/prebid/banner' const NATIVE_BASE_URI = '//bidder.7xbid.com/api/v1/prebid/native' diff --git a/test/spec/modules/a4gBidAdapter_spec.js b/test/spec/modules/a4gBidAdapter_spec.js deleted file mode 100644 index f5aa1014702..00000000000 --- a/test/spec/modules/a4gBidAdapter_spec.js +++ /dev/null @@ -1,149 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/a4gBidAdapter'; - -describe('a4gAdapterTests', function () { - describe('bidRequestValidity', function () { - it('bidRequest with zoneId and deliveryUrl params', function () { - expect(spec.isBidRequestValid({ - bidder: 'a4g', - params: { - zoneId: 59304, - deliveryUrl: 'http://dev01.ad4game.com/v1/bid' - } - })).to.equal(true); - }); - - it('bidRequest with only zoneId', function () { - expect(spec.isBidRequestValid({ - bidder: 'a4g', - params: { - zoneId: 59304 - } - })).to.equal(true); - }); - - it('bidRequest with only deliveryUrl', function () { - expect(spec.isBidRequestValid({ - bidder: 'a4g', - params: { - deliveryUrl: 'http://dev01.ad4game.com/v1/bid' - } - })).to.equal(false); - }); - }); - - describe('bidRequest', function () { - const bidRequests = [{ - 'bidder': 'a4g', - 'bidId': '51ef8751f9aead', - 'params': { - 'zoneId': 59304, - }, - 'adUnitCode': 'div-gpt-ad-1460505748561-0', - 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', - 'sizes': [[320, 50], [300, 250], [300, 600]], - 'bidderRequestId': '418b37f85e772c', - 'auctionId': '18fd8b8b0bd757' - }, { - 'bidder': 'a4g', - 'bidId': '51ef8751f9aead', - 'params': { - 'zoneId': 59354, - 'deliveryUrl': '//dev01.ad4game.com/v1/bid' - }, - 'adUnitCode': 'div-gpt-ad-1460505748561-0', - 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', - 'sizes': [[320, 50], [300, 250], [300, 600]], - 'bidderRequestId': '418b37f85e772c', - 'auctionId': '18fd8b8b0bd757' - }]; - - it('bidRequest method', function () { - const request = spec.buildRequests(bidRequests); - expect(request.method).to.equal('GET'); - }); - - it('bidRequest url', function () { - const request = spec.buildRequests(bidRequests); - expect(request.url).to.match(new RegExp(`${bidRequests[1].params.deliveryUrl}`)); - }); - - it('bidRequest data', function () { - const request = spec.buildRequests(bidRequests); - expect(request.data).to.exist; - }); - - it('bidRequest zoneIds', function () { - const request = spec.buildRequests(bidRequests); - expect(request.data.zoneId).to.equal('59304;59354'); - }); - - it('bidRequest gdpr consent', function () { - const consentString = 'consentString'; - const bidderRequest = { - bidderCode: 'a4g', - 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', function () { - const bidRequest = [{ - 'bidder': 'a4g', - 'bidId': '51ef8751f9aead', - 'params': { - 'zoneId': 59304, - }, - 'adUnitCode': 'div-gpt-ad-1460505748561-0', - 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', - 'sizes': [[320, 50], [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', function () { - 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/aardvarkBidAdapter_spec.js b/test/spec/modules/aardvarkBidAdapter_spec.js index b532fa4264a..9671f961407 100644 --- a/test/spec/modules/aardvarkBidAdapter_spec.js +++ b/test/spec/modules/aardvarkBidAdapter_spec.js @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import * as utils from 'src/utils'; -import { spec, resetUserSync } from 'modules/aardvarkBidAdapter'; +import * as utils from 'src/utils.js'; +import { spec, resetUserSync } from 'modules/aardvarkBidAdapter.js'; describe('aardvarkAdapterTest', function () { describe('forming valid bidRequests', function () { @@ -58,7 +58,7 @@ describe('aardvarkAdapterTest', function () { const bidderRequest = { refererInfo: { - referer: 'http://example.com' + referer: 'https://example.com' } }; @@ -72,7 +72,7 @@ describe('aardvarkAdapterTest', function () { it('should call the correct bidRequest url', function () { const requests = spec.buildRequests(bidRequests, bidderRequest); expect(requests.length).to.equal(1); - expect(requests[0].url).to.match(new RegExp('^\/\/adzone.pub.com/xiby/TdAx_RAZd/aardvark\?')); + expect(requests[0].url).to.match(new RegExp('^https:\/\/adzone.pub.com/xiby/TdAx_RAZd/aardvark\?')); }); it('should have correct data', function () { @@ -125,7 +125,7 @@ describe('aardvarkAdapterTest', function () { const bidderRequest = { refererInfo: { - referer: 'http://example.com' + referer: 'https://example.com' } }; @@ -138,9 +138,9 @@ describe('aardvarkAdapterTest', function () { it('should call the correct bidRequest urls for each auction', function () { const requests = spec.buildRequests(bidRequests, bidderRequest); - expect(requests[0].url).to.match(new RegExp('^\/\/bidder.rtk.io/Toby/TdAx/aardvark\?')); + expect(requests[0].url).to.match(new RegExp('^https:\/\/bidder.rtk.io/Toby/TdAx/aardvark\?')); expect(requests[0].data.categories.length).to.equal(2); - expect(requests[1].url).to.match(new RegExp('^\/\/adzone.pub.com/xiby/RAZd/aardvark\?')); + expect(requests[1].url).to.match(new RegExp('^https:\/\/adzone.pub.com/xiby/RAZd/aardvark\?')); }); it('should have correct data', function () { @@ -187,7 +187,7 @@ describe('aardvarkAdapterTest', function () { gdprApplies: true }, refererInfo: { - referer: 'http://example.com' + referer: 'https://example.com' } }; @@ -217,7 +217,7 @@ describe('aardvarkAdapterTest', function () { const bidderRequest = { gdprConsent: undefined, refererInfo: { - referer: 'http://example.com' + referer: 'https://example.com' } }; @@ -229,13 +229,61 @@ describe('aardvarkAdapterTest', function () { }); }); + describe('CCPA conformity', function () { + const bidRequests = [{ + bidder: 'aardvark', + params: { + ai: 'xiby', + sc: 'TdAx', + }, + adUnitCode: 'aaa', + transactionId: '1b8389fe-615c-482d-9f1a-177fb8f7d5b0', + sizes: [300, 250], + bidId: '1abgs362e0x48a8', + bidderRequestId: '70deaff71c281d', + auctionId: '5c66da22-426a-4bac-b153-77360bef5337' + }]; + + it('should transmit us_privacy data', function () { + const usp = '1NY-'; + const bidderRequest = { + gdprConsent: { + consentString: 'awefasdfwefasdfasd', + gdprApplies: true + }, + refererInfo: { + referer: 'http://example.com' + }, + uspConsent: usp + }; + const requests = spec.buildRequests(bidRequests, bidderRequest); + expect(requests.length).to.equal(1); + expect(requests[0].data.gdpr).to.equal(true); + expect(requests[0].data.consent).to.equal('awefasdfwefasdfasd'); + expect(requests[0].data.us_privacy).to.equal(usp); + }); + + it('should not send us_privacy', function () { + const bidderRequest = { + refererInfo: { + referer: 'http://example.com' + } + }; + const requests = spec.buildRequests(bidRequests, bidderRequest); + expect(requests.length).to.equal(1); + expect(requests[0].data.gdpr).to.be.undefined; + expect(requests[0].data.consent).to.be.undefined; + expect(requests[0].data.us_privacy).to.be.undefined; + }); + }); + describe('interpretResponse', function () { it('should handle bid responses', function () { const serverResponse = { body: [ { media: 'banner', - nurl: 'http://www.nurl.com/0', + nurl: 'https://www.nurl.com/0', cpm: 0.09, width: 300, height: 250, @@ -246,7 +294,7 @@ describe('aardvarkAdapterTest', function () { }, { media: 'banner', - nurl: 'http://www.nurl.com/1', + nurl: 'https://www.nurl.com/1', cpm: 0.19, width: 300, height: 250, @@ -307,7 +355,7 @@ describe('aardvarkAdapterTest', function () { const syncs = spec.getUserSyncs(syncOptions); expect(syncs.length).to.equal(1); expect(syncs[0].type).to.equal('iframe'); - expect(syncs[0].url).to.equal('//sync.rtk.io/cs'); + expect(syncs[0].url).to.equal('https://sync.rtk.io/cs'); }); it('should return empty, as we sync only once', function () { @@ -341,7 +389,16 @@ describe('aardvarkAdapterTest', function () { const syncs = spec.getUserSyncs(syncOptions, null, gdprConsent); expect(syncs.length).to.equal(1); expect(syncs[0].type).to.equal('iframe'); - expect(syncs[0].url).to.equal('//sync.rtk.io/cs?g=1&c=BOEFEAyOEFEAyAHABDENAI4AAAB9vABAASA'); + expect(syncs[0].url).to.equal('https://sync.rtk.io/cs?g=1&c=BOEFEAyOEFEAyAHABDENAI4AAAB9vABAASA'); + }); + + it('should produce sync url with ccpa params', function () { + resetUserSync(); + + const syncs = spec.getUserSyncs(syncOptions, null, {}, '1YYN'); + expect(syncs.length).to.equal(1); + expect(syncs[0].type).to.equal('iframe'); + expect(syncs[0].url).to.equal('https://sync.rtk.io/cs?us_privacy=1YYN'); }); }); @@ -366,7 +423,7 @@ describe('aardvarkAdapterTest', function () { const bidderRequest = { refererInfo: { - referer: 'http://example.com' + referer: 'https://example.com' } }; @@ -419,4 +476,94 @@ describe('aardvarkAdapterTest', function () { }); }); }); + + describe('schain support', function() { + const nodePropsOrder = ['asi', 'sid', 'hp', 'rid', 'name', 'domain']; + let schainConfig = { + ver: '1.0', + complete: 1, + nodes: [ + { + asi: 'rtk.io', + sid: '1234', + hp: 1, + rid: 'bid-request-1', + name: 'first pub', + domain: 'first.com' + }, + { + asi: 'rtk.io', + sid: '5678', + hp: 1, + rid: 'bid-request-2', + name: 'second pub', + domain: 'second.com' + } + ] + }; + + const bidRequests = [{ + bidder: 'aardvark', + params: { + ai: 'xiby', + sc: 'TdAx', + }, + adUnitCode: 'aaa', + transactionId: '1b8389fe-615c-482d-9f1a-177fb8f7d5b0', + sizes: [300, 250], + bidId: '1abgs362e0x48a8', + bidderRequestId: '70deaff71c281d', + auctionId: '5c66da22-426a-4bac-b153-77360bef5337', + schain: schainConfig, + }]; + + const bidderRequest = { + gdprConsent: undefined, + refererInfo: { + referer: 'https://example.com' + } + }; + + it('should properly serialize schain object with correct delimiters', () => { + const results = spec.buildRequests(bidRequests, bidderRequest); + const numNodes = schainConfig.nodes.length; + + const schain = results[0].data.schain; + + // each node serialization should start with an ! + expect(schain.match(/!/g).length).to.equal(numNodes); + + // 5 commas per node plus 1 for version + expect(schain.match(/,/g).length).to.equal(numNodes * 5 + 1); + }); + + it('should send the proper version for the schain', () => { + const results = spec.buildRequests(bidRequests, bidderRequest); + const schain = decodeURIComponent(results[0].data.schain).split('!'); + const version = schain.shift().split(',')[0]; + expect(version).to.equal(bidRequests[0].schain.ver); + }); + + it('should send the correct value for complete in schain', () => { + const results = spec.buildRequests(bidRequests, bidderRequest); + const schain = decodeURIComponent(results[0].data.schain).split('!'); + const complete = schain.shift().split(',')[1]; + expect(complete).to.equal(String(bidRequests[0].schain.complete)); + }); + + it('should send available params in the right order', () => { + const results = spec.buildRequests(bidRequests, bidderRequest); + const schain = decodeURIComponent(results[0].data.schain).split('!'); + schain.shift(); + + schain.forEach((serializeNode, nodeIndex) => { + const nodeProps = serializeNode.split(','); + nodeProps.forEach((nodeProp, propIndex) => { + const node = schainConfig.nodes[nodeIndex]; + const key = nodePropsOrder[propIndex]; + expect(nodeProp).to.equal(node[key] ? String(node[key]) : ''); + }); + }); + }); + }); }); diff --git a/test/spec/modules/ablidaBidAdapter_spec.js b/test/spec/modules/ablidaBidAdapter_spec.js index 8e0424aee23..ca4fd4ab0be 100644 --- a/test/spec/modules/ablidaBidAdapter_spec.js +++ b/test/spec/modules/ablidaBidAdapter_spec.js @@ -1,6 +1,6 @@ import {assert, expect} from 'chai'; -import {spec} from 'modules/ablidaBidAdapter'; -import {newBidder} from 'src/adapters/bidderFactory'; +import {spec} from 'modules/ablidaBidAdapter.js'; +import {newBidder} from 'src/adapters/bidderFactory.js'; const ENDPOINT_URL = 'https://bidder.ablida.net/prebid'; diff --git a/test/spec/modules/adagioAnalyticsAdapter_spec.js b/test/spec/modules/adagioAnalyticsAdapter_spec.js index 75b476f67af..aee85412104 100644 --- a/test/spec/modules/adagioAnalyticsAdapter_spec.js +++ b/test/spec/modules/adagioAnalyticsAdapter_spec.js @@ -1,23 +1,18 @@ -import adagioAnalyticsAdapter from 'modules/adagioAnalyticsAdapter'; +import adagioAnalyticsAdapter from 'modules/adagioAnalyticsAdapter.js'; import { expect } from 'chai'; -import * as utils from 'src/utils'; +import * as utils from 'src/utils.js'; let adapterManager = require('src/adapterManager').default; let events = require('src/events'); let constants = require('src/constants.json'); describe('adagio analytics adapter', () => { - let xhr; - let requests; - let sandbox + let sandbox; let adagioQueuePushSpy; beforeEach(() => { sandbox = sinon.createSandbox(); - xhr = sandbox.useFakeXMLHttpRequest(); - requests = []; - xhr.onCreate = request => requests.push(request); sandbox.stub(events, 'getEvents').returns([]); const w = utils.getWindowTop(); diff --git a/test/spec/modules/adagioBidAdapter_spec.js b/test/spec/modules/adagioBidAdapter_spec.js index 6c804418d03..8996b288576 100644 --- a/test/spec/modules/adagioBidAdapter_spec.js +++ b/test/spec/modules/adagioBidAdapter_spec.js @@ -1,13 +1,13 @@ import { expect } from 'chai'; -import { getAdagioScript, spec } from 'modules/adagioBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; -import * as utils from 'src/utils'; +import { adagioScriptFromLocalStorageCb, spec } from 'modules/adagioBidAdapter.js'; +import { newBidder } from 'src/adapters/bidderFactory.js'; +import * as utils from 'src/utils.js'; describe('adagioAdapter', () => { let utilsMock; const adapter = newBidder(spec); const ENDPOINT = 'https://mp.4dex.io/prebid'; - const VERSION = '2.0.0'; + const VERSION = '2.2.1'; beforeEach(function() { localStorage.removeItem('adagioScript'); @@ -301,7 +301,29 @@ describe('adagioAdapter', () => { 'gdprConsent': { consentString: consentString, gdprApplies: true, - allowAuctionWithoutConsent: true + allowAuctionWithoutConsent: true, + apiVersion: 1, + }, + 'refererInfo': { + 'numIframes': 0, + 'reachedTop': true, + 'referer': 'http://test.io/index.html?pbjs_debug=true' + } + }; + + let bidderRequestTCF2 = { + 'bidderCode': 'adagio', + 'auctionId': '12jejebn', + 'bidderRequestId': 'hehehehbeheh', + 'timeout': 3000, + 'gdprConsent': { + consentString: consentString, + vendorData: { + tcString: consentString, + gdprApplies: true + }, + gdprApplies: true, + apiVersion: 2 }, 'refererInfo': { 'numIframes': 0, @@ -330,11 +352,11 @@ describe('adagioAdapter', () => { expect(request.data.prebidVersion).to.equal('$prebid.version$'); }); - it('features params must be empty if param adUnitElementId is not found', () => { + it('features params "adunit_position" must be empty if adUnitElement is not found in the DOM', () => { const requests = spec.buildRequests([Object.assign({}, bidRequests[0], {params: {adUnitElementId: 'does-not-exist'}})], bidderRequest); const request = requests[0]; - const expected = {} - expect(request.data.adUnits[0].features).to.deep.equal(expected); + expect(request.data.adUnits[0].features).to.exist; + expect(request.data.adUnits[0].features.adunit_position).to.deep.equal(''); }); it('features params "adunit_position" should be computed even if DOM element is display:none', () => { @@ -380,6 +402,7 @@ describe('adagioAdapter', () => { let request = requests[0]; expect(request.data.adUnits[0].features).to.exist; expect(request.data.adUnits[0].params.outerAdUnitElementId).to.exist; + top.ADAGIO.pbjsAdUnits = undefined; }); it('generates a pageviewId if missing', () => { @@ -414,7 +437,16 @@ describe('adagioAdapter', () => { const requests = spec.buildRequests([bidRequests[0]], bidderRequest); const request = requests[0]; expect(request.data.adUnits[0].features.print_number).to.equal('2'); - }) + }); + + it('organizationId param key must be a string', () => { + const requests = spec.buildRequests([Object.assign({}, bidRequests[0], {params: {organizationId: 1010}})], bidderRequest); + const request = requests[0]; + expect(request.data.adUnits[0].params).to.exist; + expect(request.data.adUnits[0].params.organizationId).to.deep.equal('1010'); + expect(request.data.organizationId).to.exist; + expect(request.data.organizationId).to.deep.equal('1010'); + }); it('GDPR consent is applied', () => { const requests = spec.buildRequests(bidRequests, bidderRequest); @@ -423,6 +455,17 @@ describe('adagioAdapter', () => { expect(request.data.gdpr).to.exist; expect(request.data.gdpr.consentString).to.exist.and.to.equal(consentString); expect(request.data.gdpr.consentRequired).to.exist.and.to.equal(1); + expect(request.data.gdpr.apiVersion).to.exist.and.to.equal(1); + }); + + it('GDPR consent is applied w/ TCF2', () => { + const requests = spec.buildRequests(bidRequests, bidderRequestTCF2); + expect(requests).to.have.lengthOf(2); + const request = requests[0]; + expect(request.data.gdpr).to.exist; + expect(request.data.gdpr.consentString).to.exist.and.to.equal(consentString); + expect(request.data.gdpr.consentRequired).to.exist.and.to.equal(1); + expect(request.data.gdpr.apiVersion).to.exist.and.to.equal(2); }); it('GDPR consent is not applied', () => { @@ -433,6 +476,18 @@ describe('adagioAdapter', () => { expect(request.data.gdpr).to.exist; expect(request.data.gdpr.consentString).to.exist.and.to.equal(consentString); expect(request.data.gdpr.consentRequired).to.exist.and.to.equal(0); + expect(request.data.gdpr.apiVersion).to.exist.and.to.equal(1); + }); + + it('GDPR consent is not applied w/ TCF2', () => { + bidderRequestTCF2.gdprConsent.gdprApplies = false; + const requests = spec.buildRequests(bidRequests, bidderRequestTCF2); + expect(requests).to.have.lengthOf(2); + const request = requests[0]; + expect(request.data.gdpr).to.exist; + expect(request.data.gdpr.consentString).to.exist.and.to.equal(consentString); + expect(request.data.gdpr.consentRequired).to.exist.and.to.equal(0); + expect(request.data.gdpr.apiVersion).to.exist.and.to.equal(2); }); it('GDPR consent is undefined', () => { @@ -446,6 +501,20 @@ describe('adagioAdapter', () => { expect(request.data.gdpr).to.not.have.property('consentString'); expect(request.data.gdpr).to.not.have.property('gdprApplies'); expect(request.data.gdpr).to.not.have.property('allowAuctionWithoutConsent'); + expect(request.data.gdpr.apiVersion).to.exist.and.to.equal(1); + }); + + it('GDPR consent is undefined w/ TCF2', () => { + delete bidderRequestTCF2.gdprConsent.consentString; + delete bidderRequestTCF2.gdprConsent.gdprApplies; + delete bidderRequestTCF2.gdprConsent.vendorData; + const requests = spec.buildRequests(bidRequests, bidderRequestTCF2); + expect(requests).to.have.lengthOf(2); + const request = requests[0]; + expect(request.data.gdpr).to.exist; + expect(request.data.gdpr).to.not.have.property('consentString'); + expect(request.data.gdpr).to.not.have.property('gdprApplies'); + expect(request.data.gdpr.apiVersion).to.exist.and.to.equal(2); }); it('GDPR consent bidderRequest does not have gdprConsent', () => { @@ -470,6 +539,40 @@ describe('adagioAdapter', () => { }); expect(requests).to.be.empty; }); + + it('Should add the schain if available at bidder level', () => { + const bidRequest = Object.assign({}, bidRequests[0], { + schain: { + ver: '1.0', + complete: 1, + nodes: [{ + asi: 'ssp.test', + sid: '00001', + hp: 1 + }] + } + }); + + const requests = spec.buildRequests([bidRequest], bidderRequest); + const request = requests[0]; + + expect(request.data.schain).to.exist; + expect(request.data.schain).to.deep.equal({ + ver: '1.0', + complete: 1, + nodes: [{ + asi: 'ssp.test', + sid: '00001', + hp: 1 + }] + }); + }); + + it('Schain should not be added to the request', () => { + const requests = spec.buildRequests([bidRequests[0]], bidderRequest); + const request = requests[0]; + expect(request.data.schain).to.not.exist; + }); }); describe('interpretResponse', () => { @@ -635,7 +738,7 @@ describe('adagioAdapter', () => { }); }); - describe('getAdagioScript', () => { + describe('adagioScriptFromLocalStorageCb', () => { const VALID_HASH = 'Lddcw3AADdQDrPtbRJkKxvA+o1CtScGDIMNRpHB3NnlC/FYmy/9RKXelKrYj/sjuWusl5YcOpo+lbGSkk655i8EKuDiOvK6ae/imxSrmdziIp+S/TA6hTFJXcB8k1Q9OIp4CMCT52jjXgHwX6G0rp+uYoCR25B1jHaHnpH26A6I='; const INVALID_HASH = 'invalid'; const VALID_SCRIPT_CONTENT = 'var _ADAGIO=function(){};(_ADAGIO)();\n'; @@ -649,7 +752,7 @@ describe('adagioAdapter', () => { utilsMock.expects('logWarn').withExactArgs('No hash found in Adagio script').never(); utilsMock.expects('logWarn').withExactArgs('Invalid Adagio script found').never(); - getAdagioScript(); + adagioScriptFromLocalStorageCb(localStorage.getItem(ADAGIO_LOCALSTORAGE_KEY)); expect(localStorage.getItem(ADAGIO_LOCALSTORAGE_KEY)).to.equals('// hash: ' + VALID_HASH + '\n' + VALID_SCRIPT_CONTENT); utilsMock.verify(); @@ -662,7 +765,7 @@ describe('adagioAdapter', () => { utilsMock.expects('logWarn').withExactArgs('No hash found in Adagio script').never(); utilsMock.expects('logWarn').withExactArgs('Invalid Adagio script found').once(); - getAdagioScript(); + adagioScriptFromLocalStorageCb(localStorage.getItem(ADAGIO_LOCALSTORAGE_KEY)); expect(localStorage.getItem(ADAGIO_LOCALSTORAGE_KEY)).to.be.null; utilsMock.verify(); @@ -675,7 +778,7 @@ describe('adagioAdapter', () => { utilsMock.expects('logWarn').withExactArgs('No hash found in Adagio script').never(); utilsMock.expects('logWarn').withExactArgs('Invalid Adagio script found').once(); - getAdagioScript(); + adagioScriptFromLocalStorageCb(localStorage.getItem(ADAGIO_LOCALSTORAGE_KEY)); expect(localStorage.getItem(ADAGIO_LOCALSTORAGE_KEY)).to.be.null; utilsMock.verify(); @@ -688,7 +791,7 @@ describe('adagioAdapter', () => { utilsMock.expects('logWarn').withExactArgs('No hash found in Adagio script').once(); utilsMock.expects('logWarn').withExactArgs('Invalid Adagio script found').never(); - getAdagioScript(); + adagioScriptFromLocalStorageCb(localStorage.getItem(ADAGIO_LOCALSTORAGE_KEY)); expect(localStorage.getItem(ADAGIO_LOCALSTORAGE_KEY)).to.be.null; utilsMock.verify(); diff --git a/test/spec/modules/adbutlerBidAdapter_spec.js b/test/spec/modules/adbutlerBidAdapter_spec.js index cf6b52f70e5..a9b56ade79e 100644 --- a/test/spec/modules/adbutlerBidAdapter_spec.js +++ b/test/spec/modules/adbutlerBidAdapter_spec.js @@ -1,5 +1,5 @@ import {expect} from 'chai'; -import {spec} from 'modules/adbutlerBidAdapter'; +import {spec} from 'modules/adbutlerBidAdapter.js'; describe('AdButler adapter', function () { let bidRequests; @@ -16,7 +16,11 @@ describe('AdButler adapter', function () { maxCPM: '5.00' }, placementCode: '/19968336/header-bid-tag-1', - sizes: [[300, 250], [300, 600]], + mediaTypes: { + banner: { + sizes: [[300, 250], [300, 600]], + }, + }, bidId: '23acc48ad47af5', auctionId: '0fb4905b-9456-4152-86be-c6f6d259ba99', bidderRequestId: '1c56ad30b9b8ca8', @@ -79,7 +83,7 @@ describe('AdButler adapter', function () { let [domain] = request.url.split('/adserve/'); - expect(domain).to.equal('http://servedbyadbutler.com'); + expect(domain).to.equal('https://servedbyadbutler.com'); }); it('should set the keyword parameter', function () { @@ -97,7 +101,6 @@ describe('AdButler adapter', function () { params: { accountID: '107878', zoneID: '86133', - domain: 'servedbyadbutler.com.dan.test' } }, { sizes: [[300, 250]], @@ -105,7 +108,6 @@ describe('AdButler adapter', function () { params: { accountID: '107878', zoneID: '86133', - domain: 'servedbyadbutler.com.dan.test' } }, ], @@ -151,11 +153,13 @@ describe('AdButler adapter', function () { it('should return empty bid response', function () { let serverResponse = { - status: 'NO_ELIGIBLE_ADS', - zone_id: 210083, - width: 300, - height: 250, - place: 0 + body: { + status: 'NO_ELIGIBLE_ADS', + zone_id: 210083, + width: 300, + height: 250, + place: 0 + } }, bids = spec.interpretResponse(serverResponse, {'bidRequest': bidRequests[0]}); @@ -164,13 +168,15 @@ describe('AdButler adapter', function () { it('should return empty bid response on incorrect size', function () { let serverResponse = { - status: 'SUCCESS', - account_id: 167283, - zone_id: 210083, - cpm: 1.5, - width: 728, - height: 90, - place: 0 + body: { + status: 'SUCCESS', + account_id: 167283, + zone_id: 210083, + cpm: 1.5, + width: 728, + height: 90, + place: 0 + } }, bids = spec.interpretResponse(serverResponse, {'bidRequest': bidRequests[0]}); @@ -179,13 +185,15 @@ describe('AdButler adapter', function () { it('should return empty bid response with CPM too low', function () { let serverResponse = { - status: 'SUCCESS', - account_id: 167283, - zone_id: 210093, - cpm: 0.75, - width: 300, - height: 250, - place: 0 + body: { + status: 'SUCCESS', + account_id: 167283, + zone_id: 210093, + cpm: 0.75, + width: 300, + height: 250, + place: 0 + } }, bids = spec.interpretResponse(serverResponse, {'bidRequest': bidRequests[0]}); @@ -194,13 +202,15 @@ describe('AdButler adapter', function () { it('should return empty bid response with CPM too high', function () { let serverResponse = { - status: 'SUCCESS', - account_id: 167283, - zone_id: 210093, - cpm: 7.00, - width: 300, - height: 250, - place: 0 + body: { + status: 'SUCCESS', + account_id: 167283, + zone_id: 210093, + cpm: 7, + width: 300, + height: 250, + place: 0 + } }, bids = spec.interpretResponse(serverResponse, {'bidRequest': bidRequests[0]}); diff --git a/test/spec/modules/huddledmassesBidAdapter_spec.js b/test/spec/modules/adfinityBidAdapter_spec.js similarity index 74% rename from test/spec/modules/huddledmassesBidAdapter_spec.js rename to test/spec/modules/adfinityBidAdapter_spec.js index 7823ae53c12..479a2303dd5 100644 --- a/test/spec/modules/huddledmassesBidAdapter_spec.js +++ b/test/spec/modules/adfinityBidAdapter_spec.js @@ -1,36 +1,63 @@ import {expect} from 'chai'; -import {spec} from '../../../modules/huddledmassesBidAdapter'; +import {spec} from '../../../modules/adfinityBidAdapter.js'; -describe('HuddledmassesAdapter', function () { +describe('AdfinityAdapter', function () { let bid = { bidId: '2dd581a2b6281d', - bidder: 'huddledmasses', + bidder: 'adfinity', bidderRequestId: '145e1d6a7837c9', params: { placement_id: 0 }, placementCode: 'placementid_0', auctionId: '74f78609-a92d-4cf1-869f-1b244bbfb5d2', - sizes: [[300, 250]], - transactionId: '3bb2f6da-87a6-4029-aeb0-bfe951372e62' + mediaTypes: { + banner: { + sizes: [[300, 250]] + } + }, + transactionId: '3bb2f6da-87a6-4029-aeb0-bfe951372e62', + schain: { + ver: '1.0', + complete: 1, + nodes: [ + { + asi: 'example.com', + sid: '0', + hp: 1, + rid: 'bidrequestid', + domain: 'example.com' + } + ] + } }; + let bidderRequest = { + bidderCode: 'adfinity', + 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, and when at least one of the sizes passed is allowed', 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.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]); + 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; @@ -41,8 +68,9 @@ describe('HuddledmassesAdapter', function () { expect(serverRequest.method).to.equal('POST'); }); it('Returns valid URL', function () { - expect(serverRequest.url).to.equal('//huddledmassessupply.com/?c=o&m=multi'); + expect(serverRequest.url).to.equal('https://stat.adfinity.pro/?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'); @@ -56,9 +84,11 @@ describe('HuddledmassesAdapter', 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', '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'); expect(placement.sizes).to.be.an('array'); } }); @@ -72,6 +102,7 @@ describe('HuddledmassesAdapter', function () { let resObject = { body: [ { requestId: '123', + mediaType: 'banner', cpm: 0.3, width: 320, height: 50, @@ -88,7 +119,7 @@ describe('HuddledmassesAdapter', function () { 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'); + 'netRevenue', 'currency', 'mediaType'); expect(dataItem.requestId).to.be.a('string'); expect(dataItem.cpm).to.be.a('number'); expect(dataItem.width).to.be.a('number'); @@ -98,6 +129,7 @@ describe('HuddledmassesAdapter', function () { 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'); @@ -113,7 +145,7 @@ describe('HuddledmassesAdapter', 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('//huddledmassessupply.com/?c=o&m=cookie'); + expect(userSync[0].url).to.be.equal('https://stat.adfinity.pro/?c=o&m=cookie'); }); }); }); diff --git a/test/spec/modules/adformBidAdapter_spec.js b/test/spec/modules/adformBidAdapter_spec.js index 80f89614c5e..9233ca1dd7a 100644 --- a/test/spec/modules/adformBidAdapter_spec.js +++ b/test/spec/modules/adformBidAdapter_spec.js @@ -1,8 +1,7 @@ import {assert, expect} from 'chai'; -import * as url from 'src/url'; -import {spec} from 'modules/adformBidAdapter'; -import { BANNER, VIDEO } from 'src/mediaTypes'; -import { config } from 'src/config'; +import {spec} from 'modules/adformBidAdapter.js'; +import { BANNER, VIDEO } from 'src/mediaTypes.js'; +import { config } from 'src/config.js'; describe('Adform adapter', function () { let serverResponse, bidRequest, bidResponses; @@ -38,7 +37,7 @@ describe('Adform adapter', function () { let parsedUrl = parseUrl(spec.buildRequests([bids[0]]).url); let query = parsedUrl.query; - assert.equal(parsedUrl.path, '//newDomain/adx'); + assert.equal(parsedUrl.path, 'https://newDomain/adx'); assert.equal(query.tid, 45); assert.equal(query.rp, 4); assert.equal(query.fd, 1); diff --git a/test/spec/modules/adformOpenRTBBidAdapter_spec.js b/test/spec/modules/adformOpenRTBBidAdapter_spec.js index 32795c24ef6..77dbc17cdb2 100644 --- a/test/spec/modules/adformOpenRTBBidAdapter_spec.js +++ b/test/spec/modules/adformOpenRTBBidAdapter_spec.js @@ -1,9 +1,8 @@ // jshint esversion: 6, es3: false, node: true import {assert, expect} from 'chai'; -import * as url from 'src/url'; -import {spec} from 'modules/adformOpenRTBBidAdapter'; -import { NATIVE } from 'src/mediaTypes'; -import { config } from 'src/config'; +import {spec} from 'modules/adformOpenRTBBidAdapter.js'; +import { NATIVE } from 'src/mediaTypes.js'; +import { config } from 'src/config.js'; describe('AdformOpenRTB adapter', function () { let serverResponse, bidRequest, bidResponses; @@ -39,7 +38,7 @@ describe('AdformOpenRTB adapter', function () { let request = spec.buildRequests(validBidRequests, { refererInfo: { referer: 'page' } }); assert.equal(request.method, 'POST'); - assert.equal(request.url, '//10.8.57.207/adx/openrtb'); + assert.equal(request.url, 'https://10.8.57.207/adx/openrtb'); assert.deepEqual(request.options, {contentType: 'application/json'}); assert.ok(request.data); }); diff --git a/test/spec/modules/adgenerationBidAdapter_spec.js b/test/spec/modules/adgenerationBidAdapter_spec.js index 2b8834f1e1d..927e7910723 100644 --- a/test/spec/modules/adgenerationBidAdapter_spec.js +++ b/test/spec/modules/adgenerationBidAdapter_spec.js @@ -1,13 +1,13 @@ import {expect} from 'chai'; -import {spec} from 'modules/adgenerationBidAdapter'; -import {newBidder} from 'src/adapters/bidderFactory'; -import {NATIVE} from 'src/mediaTypes'; -import {config} from 'src/config'; +import {spec} from 'modules/adgenerationBidAdapter.js'; +import {newBidder} from 'src/adapters/bidderFactory.js'; +import {NATIVE} from 'src/mediaTypes.js'; +import {config} from 'src/config.js'; import prebid from '../../../package.json'; describe('AdgenerationAdapter', function () { const adapter = newBidder(spec); - const ENDPOINT = ['http://api-test.scaleout.jp/adsv/v1', 'https://d.socdm.com/adsv/v1']; + const ENDPOINT = ['https://api-test.scaleout.jp/adsv/v1', 'https://d.socdm.com/adsv/v1']; describe('inherited functions', function () { it('exists and is a function', function () { @@ -88,13 +88,13 @@ describe('AdgenerationAdapter', function () { ]; const bidderRequest = { refererInfo: { - referer: 'http://example.com' + referer: 'https://example.com' } }; const data = { - banner: `posall=SSPLOC&id=58278&sdktype=0&hb=true&t=json3&sizes=300x250%2C320x100¤cy=JPY&pbver=${prebid.version}&sdkname=prebidjs&adapterver=1.0.1&imark=1&tp=http%3A%2F%2Fexample.com`, - bannerUSD: `posall=SSPLOC&id=58278&sdktype=0&hb=true&t=json3&sizes=300x250%2C320x100¤cy=USD&pbver=${prebid.version}&sdkname=prebidjs&adapterver=1.0.1&imark=1&tp=http%3A%2F%2Fexample.com`, - native: 'posall=SSPLOC&id=58278&sdktype=0&hb=true&t=json3&sizes=1x1¤cy=JPY&pbver=' + prebid.version + '&sdkname=prebidjs&adapterver=1.0.1&tp=http%3A%2F%2Fexample.com' + banner: `posall=SSPLOC&id=58278&sdktype=0&hb=true&t=json3&sizes=300x250%2C320x100¤cy=JPY&pbver=${prebid.version}&sdkname=prebidjs&adapterver=1.0.1&imark=1&tp=https%3A%2F%2Fexample.com`, + bannerUSD: `posall=SSPLOC&id=58278&sdktype=0&hb=true&t=json3&sizes=300x250%2C320x100¤cy=USD&pbver=${prebid.version}&sdkname=prebidjs&adapterver=1.0.1&imark=1&tp=https%3A%2F%2Fexample.com`, + native: 'posall=SSPLOC&id=58278&sdktype=0&hb=true&t=json3&sizes=1x1¤cy=JPY&pbver=' + prebid.version + '&sdkname=prebidjs&adapterver=1.0.1&tp=https%3A%2F%2Fexample.com' }; it('sends bid request to ENDPOINT via GET', function () { const request = spec.buildRequests(bidRequests, bidderRequest)[0]; @@ -215,7 +215,7 @@ describe('AdgenerationAdapter', function () { dealid: 'fd5sa5fa7f', ttl: 1000, results: [ - {ad: '
'}, + {ad: '
'}, ] }, native: { diff --git a/test/spec/modules/adglareBidAdapter_spec.js b/test/spec/modules/adglareBidAdapter_spec.js new file mode 100644 index 00000000000..d0dbe891f9d --- /dev/null +++ b/test/spec/modules/adglareBidAdapter_spec.js @@ -0,0 +1,138 @@ +import {expect} from 'chai'; +import {spec} from 'modules/adglareBidAdapter.js'; + +describe('AdGlare Adapter Tests', function () { + let bidRequests; + + beforeEach(function () { + bidRequests = [ + { + bidder: 'adglare', + params: { + domain: 'try.engine.adglare.net', + zID: '475579334', + type: 'banner' + }, + mediaTypes: { + banner: { + sizes: [[300, 250], [300, 600]], + }, + }, + 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 () { + let validBid = { + bidder: 'adglare', + params: { + domain: 'try.engine.adglare.net', + zID: '475579334', + type: 'banner' + } + }, + isValid = spec.isBidRequestValid(validBid); + + expect(isValid).to.equal(true); + }); + + it('should reject invalid bid', function () { + let invalidBid = { + bidder: 'adglare', + params: { + domain: 'somedomain.com', + zID: 'not an integer', + type: 'unsupported' + } + }, + isValid = spec.isBidRequestValid(invalidBid); + + expect(isValid).to.equal(false); + }); + + it('should build a valid endpoint URL', function () { + let bidRequests = [ + { + bidder: 'adglare', + params: { + domain: 'try.engine.adglare.net', + zID: '475579334', + type: 'banner' + }, + mediaTypes: { + banner: { + sizes: [[300, 250], [300, 600]], + }, + }, + bidId: '23acc48ad47af5', + auctionId: '0fb4905b-9456-4152-86be-c6f6d259ba99', + bidderRequestId: '1c56ad30b9b8ca8', + transactionId: '92489f71-1bf2-49a0-adf9-000cea934729' + } + ], + bidderRequest = { + bidderCode: 'adglare', + auctionID: '0fb4905b-9456-4152-86be-c6f6d259ba99', + bidderRequestId: '1c56ad30b9b8ca8', + auctionStart: 1581497568252, + timeout: 5000, + refererInfo: { + referer: 'https://www.somedomain.com', + reachedTop: true, + numFrames: 0 + }, + start: 1581497568254 + }, + requests = spec.buildRequests(bidRequests, bidderRequest), + requestURL = requests[0].url; + + expect(requestURL).to.have.string('https://try.engine.adglare.net/?475579334'); + }); + }); + + describe('bid responses', function () { + it('should return complete bid response', function () { + let serverResponse = { + body: { + status: 'OK', + zID: 475579334, + cID: 501658124, + crID: 442123173, + cpm: 1.5, + ttl: 3600, + currency: 'USD', + width: 300, + height: 250, + adhtml: 'I am an ad.' + } + }, + bids = spec.interpretResponse(serverResponse, {'bidRequest': bidRequests[0]}); + + expect(bids).to.be.lengthOf(1); + expect(bids[0].bidderCode).to.equal('adglare'); + 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].currency).to.equal('USD'); + expect(bids[0].netRevenue).to.equal(true); + }); + + it('should return empty bid response', function () { + let serverResponse = { + body: { + status: 'NOADS' + } + }, + bids = spec.interpretResponse(serverResponse, {'bidRequest': bidRequests[0]}); + + expect(bids).to.be.lengthOf(0); + }); + }); + }); +}); diff --git a/test/spec/modules/adheseBidAdapter_spec.js b/test/spec/modules/adheseBidAdapter_spec.js index 32658e2bb27..7392ecd8f4e 100644 --- a/test/spec/modules/adheseBidAdapter_spec.js +++ b/test/spec/modules/adheseBidAdapter_spec.js @@ -1,5 +1,5 @@ import {expect} from 'chai'; -import {spec} from 'modules/adheseBidAdapter'; +import {spec} from 'modules/adheseBidAdapter.js'; const BID_ID = 456; const TTL = 360; @@ -120,6 +120,7 @@ describe('AdheseAdapter', function () { origin: 'APPNEXUS', originInstance: '', ext: 'js', + slotID: '10', slotName: '_main_page_-leaderboard', adType: 'leaderboard', originData: { @@ -155,12 +156,15 @@ describe('AdheseAdapter', function () { ttl: TTL, adhese: { originData: { + adType: 'leaderboard', seatbid: [ { bid: [ { crid: '60613369', dealid: null } ], seat: '958' } - ] + ], + slotId: '10', + slotName: '_main_page_-leaderboard' } } }]; @@ -249,12 +253,16 @@ describe('AdheseAdapter', function () { adhese: { originData: { adFormat: 'largeleaderboard', + adId: '742898', adType: 'largeleaderboard', adspaceId: '162363', libId: '90511', orderProperty: undefined, priority: undefined, - viewableImpressionCounter: undefined + viewableImpressionCounter: undefined, + slotId: '29306', + slotName: '_main_page_-leaderboard', + advertiserId: '2081' } }, cpm: 5.96, @@ -304,12 +312,16 @@ describe('AdheseAdapter', function () { adhese: { originData: { adFormat: '', + adId: '742470', adType: 'preroll', adspaceId: '164196', libId: '89860', orderProperty: undefined, priority: undefined, - viewableImpressionCounter: undefined + viewableImpressionCounter: undefined, + slotId: '41711', + slotName: '_main_page_-leaderboard', + advertiserId: '2263', } }, cpm: 0, diff --git a/test/spec/modules/adkernelAdnAnalyticsAdapter_spec.js b/test/spec/modules/adkernelAdnAnalytics_spec.js similarity index 98% rename from test/spec/modules/adkernelAdnAnalyticsAdapter_spec.js rename to test/spec/modules/adkernelAdnAnalytics_spec.js index 26fd13afd1f..e7ef831080c 100644 --- a/test/spec/modules/adkernelAdnAnalyticsAdapter_spec.js +++ b/test/spec/modules/adkernelAdnAnalytics_spec.js @@ -1,6 +1,6 @@ -import analyticsAdapter, {ExpiringQueue, getUmtSource, storage} from 'modules/adkernelAdnAnalyticsAdapter'; +import analyticsAdapter, {ExpiringQueue, getUmtSource, storage} from 'modules/adkernelAdnAnalyticsAdapter.js'; import {expect} from 'chai'; -import adapterManager from 'src/adapterManager'; +import adapterManager from 'src/adapterManager.js'; import CONSTANTS from 'src/constants.json'; const events = require('../../../src/events'); diff --git a/test/spec/modules/adkernelAdnBidAdapter_spec.js b/test/spec/modules/adkernelAdnBidAdapter_spec.js index 277faf2a351..3d3e64aeec9 100644 --- a/test/spec/modules/adkernelAdnBidAdapter_spec.js +++ b/test/spec/modules/adkernelAdnBidAdapter_spec.js @@ -1,5 +1,5 @@ import {expect} from 'chai'; -import {spec} from 'modules/adkernelAdnBidAdapter'; +import {spec} from 'modules/adkernelAdnBidAdapter.js'; describe('AdkernelAdn adapter', function () { const bid1_pub1 = { @@ -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 = { @@ -243,17 +243,18 @@ describe('AdkernelAdn adapter', function () { expect(tagRequest).to.not.have.property('user'); }); - it('shouldn\'t contain gdpr-related information for default request', function () { + it('shouldn\'t contain gdpr nor ccpa information for default request', function () { let [_, tagRequests] = buildRequest([bid1_pub1]); expect(tagRequests[0]).to.not.have.property('user'); }); - it('should contain gdpr-related information if consent is configured', function () { + it('should contain gdpr and ccpa information if consent is configured', function () { let [_, bidRequests] = buildRequest([bid1_pub1], - {gdprConsent: {gdprApplies: true, consentString: 'test-consent-string'}}); + {gdprConsent: {gdprApplies: true, consentString: 'test-consent-string'}, uspConsent: '1YNN'}); expect(bidRequests[0]).to.have.property('user'); expect(bidRequests[0].user).to.have.property('gdpr', 1); expect(bidRequests[0].user).to.have.property('consent', 'test-consent-string'); + expect(bidRequests[0].user).to.have.property('us_privacy', '1YNN'); }); it('should\'t contain consent string if gdpr isn\'t applied', function () { @@ -323,8 +324,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 +366,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 5b3d76ef071..ef95febf13d 100644 --- a/test/spec/modules/adkernelBidAdapter_spec.js +++ b/test/spec/modules/adkernelBidAdapter_spec.js @@ -1,6 +1,7 @@ import {expect} from 'chai'; -import {spec} from 'modules/adkernelBidAdapter'; -import * as utils from 'src/utils'; +import {spec} from 'modules/adkernelBidAdapter.js'; +import * as utils from 'src/utils.js'; +import {NATIVE, BANNER, VIDEO} from 'src/mediaTypes'; describe('Adkernel adapter', function () { const bid1_zone1 = { @@ -105,6 +106,57 @@ describe('Adkernel adapter', function () { bidId: 'Bid_01', bidderRequestId: 'req-001', auctionId: 'auc-001' + }, bid_native = { + bidder: 'adkernel', + params: {zoneId: 1, host: 'rtb.adkernel.com'}, + mediaTypes: { + native: { + title: { + required: true, + len: 80 + }, + body: { + required: true + }, + body2: { + required: true + }, + icon: { + required: true, + aspect_ratios: [{min_width: 50, min_height: 50}] + }, + image: { + required: true, + sizes: [300, 200] + }, + clickUrl: { + required: true + }, + rating: { + required: false + }, + price: { + required: false + }, + privacyLink: { + required: false + }, + cta: { + required: false + }, + sponsoredBy: { + required: false + }, + displayUrl: { + required: false + } + } + }, + adUnitCode: 'ad-unit-1', + transactionId: 'f82c64b8-c602-42a4-9791-4a268f6559ed', + bidId: 'Bid_01', + bidderRequestId: 'req-001', + auctionId: 'auc-001' }; const bidResponse1 = { @@ -123,22 +175,8 @@ describe('Adkernel adapter', function () { }], cur: 'USD', ext: { - adk_usersync: ['http://adk.sync.com/sync'] + adk_usersync: ['https://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: [{ @@ -156,8 +194,38 @@ describe('Adkernel adapter', function () { }, usersyncOnlyResponse = { id: 'nobid1', ext: { - adk_usersync: ['http://adk.sync.com/sync'] + adk_usersync: ['https://adk.sync.com/sync'] } + }, nativeResponse = { + id: '56fbc713-b737-4651-9050-13376aed9818', + seatbid: [{ + bid: [{ + id: 'someid_01', + impid: 'Bid_01', + price: 2.25, + adid: '4', + adm: JSON.stringify({ + native: { + assets: [ + {id: 0, title: {text: 'Title'}}, + {id: 3, data: {value: 'Description'}}, + {id: 4, data: {value: 'Additional description'}}, + {id: 1, img: {url: 'http://rtb.com/thumbnail?i=pTuOlf5KHUo_0&imgt=icon', w: 50, h: 50}}, + {id: 2, img: {url: 'http://rtb.com/thumbnail?i=pTuOlf5KHUo_0', w: 300, h: 200}}, + {id: 5, data: {value: 'Sponsor.com'}}, + {id: 14, data: {value: 'displayurl.com'}} + ], + link: {url: 'http://rtb.com/click?i=pTuOlf5KHUo_0'}, + imptrackers: ['http://rtb.com/win?i=pTuOlf5KHUo_0&f=imp'] + } + }), + adomain: ['displayurl.com'], + cid: '1', + crid: '4' + }] + }], + bidid: 'pTuOlf5KHUo', + cur: 'USD' }; function buildBidderRequest(url = 'https://example.com/index.html', params = {}) { @@ -191,6 +259,10 @@ describe('Adkernel adapter', function () { it('empty request shouldn\'t generate exception', function () { expect(spec.isBidRequestValid(bid_with_wrong_zoneId)).to.be.equal(false); }); + + it('valid native requests should pass', () => { + expect(spec.isBidRequestValid(bid_native)).to.be.equal(true); + }) }); describe('banner request building', function () { @@ -238,7 +310,7 @@ describe('Adkernel adapter', function () { expect(bidRequest.device).to.have.property('dnt', 1); }); - it('shouldn\'t contain gdpr-related information for default request', function () { + it('shouldn\'t contain gdpr nor ccpa information for default request', function () { let [_, bidRequests] = buildRequest([bid1_zone1]); expect(bidRequests[0]).to.not.have.property('regs'); expect(bidRequests[0]).to.not.have.property('user'); @@ -246,11 +318,11 @@ 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', - {gdprConsent: {gdprApplies: true, consentString: 'test-consent-string', vendorData: {}}})); + buildBidderRequest('https://example.com/index.html', + {gdprConsent: {gdprApplies: true, consentString: 'test-consent-string', vendorData: {}}, uspConsent: '1YNN'})); let bidRequest = bidRequests[0]; expect(bidRequest).to.have.property('regs'); - expect(bidRequest.regs.ext).to.be.eql({'gdpr': 1}); + expect(bidRequest.regs.ext).to.be.eql({'gdpr': 1, 'us_privacy': '1YNN'}); expect(bidRequest).to.have.property('user'); expect(bidRequest.user.ext).to.be.eql({'consent': 'test-consent-string'}); }); @@ -270,7 +342,6 @@ describe('Adkernel adapter', function () { 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); }); }); @@ -320,8 +391,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 () { @@ -343,7 +414,7 @@ describe('Adkernel adapter', function () { 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('mediaType', BANNER); expect(resp).to.have.property('ad'); expect(resp.ad).to.have.string(''); }); @@ -352,7 +423,7 @@ describe('Adkernel adapter', function () { let [pbRequests, _] = buildRequest([bid_video]); let resp = spec.interpretResponse({body: videoBidResponse}, pbRequests[0])[0]; expect(resp).to.have.property('requestId', 'Bid_Video'); - expect(resp.mediaType).to.equal('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); @@ -378,7 +449,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'); }); }); @@ -388,4 +459,49 @@ describe('Adkernel adapter', function () { expect(spec.aliases).to.include.members(['headbidding', 'adsolut', 'oftmediahb', 'audiencemedia', 'waardex_ak', 'roqoon']); }); }); + + describe('native support', () => { + let _, bidRequests; + before(function () { + [_, bidRequests] = buildRequest([bid_native]); + }); + + it('native request building', () => { + expect(bidRequests[0].imp).to.have.length(1); + expect(bidRequests[0].imp[0]).to.have.property('native'); + expect(bidRequests[0].imp[0].native).to.have.property('request'); + let request = JSON.parse(bidRequests[0].imp[0].native.request); + expect(request).to.have.property('ver', '1.1'); + expect(request.assets).to.have.length(10); + expect(request.assets[0]).to.be.eql({id: 0, required: 1, title: {len: 80}}); + expect(request.assets[1]).to.be.eql({id: 3, required: 1, data: {type: 2}}); + expect(request.assets[2]).to.be.eql({id: 4, required: 1, data: {type: 10}}); + expect(request.assets[3]).to.be.eql({id: 1, required: 1, img: {wmin: 50, hmin: 50, type: 1}}); + expect(request.assets[4]).to.be.eql({id: 2, required: 1, img: {w: 300, h: 200, type: 3}}); + expect(request.assets[5]).to.be.eql({id: 11, required: 0, data: {type: 3}}); + expect(request.assets[6]).to.be.eql({id: 8, required: 0, data: {type: 6}}); + expect(request.assets[7]).to.be.eql({id: 10, required: 0, data: {type: 12}}); + expect(request.assets[8]).to.be.eql({id: 5, required: 0, data: {type: 1}}); + expect(request.assets[9]).to.be.eql({id: 14, required: 0, data: {type: 11}}); + }); + + it('native response processing', () => { + let [pbRequests, _] = buildRequest([bid_native]); + let resp = spec.interpretResponse({body: nativeResponse}, pbRequests[0])[0]; + expect(resp).to.have.property('requestId', 'Bid_01'); + expect(resp).to.have.property('cpm', 2.25); + expect(resp).to.have.property('currency', 'USD'); + expect(resp).to.have.property('mediaType', NATIVE); + expect(resp).to.have.property('native'); + expect(resp.native).to.have.property('clickUrl', 'http://rtb.com/click?i=pTuOlf5KHUo_0'); + expect(resp.native.impressionTrackers).to.be.eql(['http://rtb.com/win?i=pTuOlf5KHUo_0&f=imp']); + expect(resp.native).to.have.property('title', 'Title'); + expect(resp.native).to.have.property('body', 'Description'); + expect(resp.native).to.have.property('body2', 'Additional description'); + expect(resp.native.icon).to.be.eql({url: 'http://rtb.com/thumbnail?i=pTuOlf5KHUo_0&imgt=icon', width: 50, height: 50}); + expect(resp.native.image).to.be.eql({url: 'http://rtb.com/thumbnail?i=pTuOlf5KHUo_0', width: 300, height: 200}); + expect(resp.native).to.have.property('sponsoredBy', 'Sponsor.com'); + expect(resp.native).to.have.property('displayUrl', 'displayurl.com'); + }); + }); }); diff --git a/test/spec/modules/adliveBidAdapter_spec.js b/test/spec/modules/adliveBidAdapter_spec.js index 0048fc028b8..ddf8f82f20f 100644 --- a/test/spec/modules/adliveBidAdapter_spec.js +++ b/test/spec/modules/adliveBidAdapter_spec.js @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import { spec } from 'modules/adliveBidAdapter'; +import { spec } from 'modules/adliveBidAdapter.js'; describe('adliveBidAdapterTests', function() { let bidRequestData = { diff --git a/test/spec/modules/admanBidAdapter_spec.js b/test/spec/modules/admanBidAdapter_spec.js index 37a097427d5..f3212dec2f5 100644 --- a/test/spec/modules/admanBidAdapter_spec.js +++ b/test/spec/modules/admanBidAdapter_spec.js @@ -1,215 +1,231 @@ 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'); +import {spec} from '../../../modules/admanBidAdapter.js'; + +describe('AdmanMediaBidAdapter', function () { + let bid = { + bidId: '23fhj33i987f', + bidder: 'adman', + 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('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); + 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('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('Returns POST method', function () { + expect(serverRequest.method).to.equal('POST'); }); - - 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); + it('Returns valid URL', function () { + expect(serverRequest.url).to.equal('https://pub.admanmedia.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', 'sizes'); + 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('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'); - }) + 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', 'mediaType'); + 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 send GDPR to endpoint and honor gdprApplies value', function() { - let consentString = 'bogusConsent'; - let bidderRequest = { - 'gdprConsent': { - 'consentString': consentString, - 'gdprApplies': true - } + 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' + }] }; - - 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 - } + 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', 'mediaType'); + 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', + 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', + }] }; - - 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); + 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', 'ttl', 'creativeId', 'netRevenue', 'currency', 'mediaType', 'native'); + expect(dataItem.native).to.have.keys('clickUrl', 'impressionTrackers', 'title', 'image') + expect(dataItem.requestId).to.equal('23fhj33i987f'); + expect(dataItem.cpm).to.equal(0.4); + expect(dataItem.native.clickUrl).to.equal('test.com'); + expect(dataItem.native.title).to.equal('Test'); + expect(dataItem.native.image).to.equal('test.com'); + expect(dataItem.native.impressionTrackers).to.be.an('array').that.is.not.empty; + expect(dataItem.native.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'); }); - }); - - 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 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' }] - } - }; - - 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])); + let serverResponses = spec.interpretResponse(invBanner); + expect(serverResponses).to.be.an('array').that.is.empty; }); - - it('handles nobid responses', function() { - let bids = { - 'body': { - 'bids': [] - } + 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 result = spec.interpretResponse(bids); - expect(result.length).to.equal(0); + 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', () => { - it('should get correct user sync iframe url', function() { - expect(spec.getUserSyncs({ - iframeEnabled: true - }, [{}])).to.deep.equal([{ - type: 'iframe', - url: USER_SYNC_IFRAME_URL - }]); + 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('https://pub.admanmedia.com/?c=o&m=sync'); }); }); }); diff --git a/test/spec/modules/admediaBidAdapter_spec.js b/test/spec/modules/admediaBidAdapter_spec.js index 2e14eee938c..5dc7b9a02a8 100644 --- a/test/spec/modules/admediaBidAdapter_spec.js +++ b/test/spec/modules/admediaBidAdapter_spec.js @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import { spec } from 'modules/admediaBidAdapter'; +import { spec } from 'modules/admediaBidAdapter.js'; describe('admediaAdapterTests', function () { describe('bidRequestValidity', function () { @@ -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 index 54d0dbee6e4..6d2e3059dc8 100644 --- a/test/spec/modules/admixerBidAdapter_spec.js +++ b/test/spec/modules/admixerBidAdapter_spec.js @@ -1,9 +1,9 @@ import {expect} from 'chai'; -import {spec} from 'modules/admixerBidAdapter'; -import {newBidder} from 'src/adapters/bidderFactory'; +import {spec} from 'modules/admixerBidAdapter.js'; +import {newBidder} from 'src/adapters/bidderFactory.js'; const BIDDER_CODE = 'admixer'; -const ENDPOINT_URL = '//inv-nets.admixer.net/prebid.1.0.aspx'; +const ENDPOINT_URL = 'https://inv-nets.admixer.net/prebid.1.0.aspx'; const ZONE_ID = '2eb6bd58-865c-47ce-af7f-a918108c3fd2'; describe('AdmixerAdapter', function () { @@ -43,7 +43,7 @@ describe('AdmixerAdapter', function () { }); describe('buildRequests', function () { - let bidRequests = [ + let validRequest = [ { 'bidder': BIDDER_CODE, 'params': { @@ -56,16 +56,21 @@ describe('AdmixerAdapter', function () { 'auctionId': '1d1a030790a475', } ]; + let bidderRequest = { + refererInfo: { + referer: 'https://example.com' + } + }; it('should add referrer and imp to be equal bidRequest', function () { - const request = spec.buildRequests(bidRequests); + const request = spec.buildRequests(validRequest, bidderRequest); const payload = JSON.parse(request.data.substr(5)); expect(payload.referrer).to.not.be.undefined; - expect(payload.imps[0]).to.deep.equal(bidRequests[0]); + expect(payload.imps[0]).to.deep.equal(validRequest[0]); }); it('sends bid request to ENDPOINT via GET', function () { - const request = spec.buildRequests(bidRequests); + const request = spec.buildRequests(validRequest, bidderRequest); expect(request.url).to.equal(ENDPOINT_URL); expect(request.method).to.equal('GET'); }); diff --git a/test/spec/modules/adnuntiusBidAdapter_spec.js b/test/spec/modules/adnuntiusBidAdapter_spec.js new file mode 100644 index 00000000000..54ff038c083 --- /dev/null +++ b/test/spec/modules/adnuntiusBidAdapter_spec.js @@ -0,0 +1,119 @@ +// import or require modules necessary for the test, e.g.: +import { expect } from 'chai'; // may prefer 'assert' in place of 'expect' +import { spec } from 'modules/adnuntiusBidAdapter.js'; +import { newBidder } from 'src/adapters/bidderFactory.js'; + +describe('adnuntiusBidAdapter', function () { + const ENDPOINT_URL = 'https://delivery.adnuntius.com/i?tzo=-60&format=json'; + const adapter = newBidder(spec); + const bidRequests = [ + { + bidder: 'adnuntius', + params: { + auId: '8b6bc', + network: 'adnuntius', + }, + bidId: '123' + } + ]; + + const serverResponse = { + body: { + 'adUnits': [ + { + 'auId': '000000000008b6bc', + 'targetId': '', + 'html': '

hi!

', + 'matchedAdCount': 1, + 'responseId': 'adn-rsp-1460129238', + 'ads': [ + { + 'destinationUrlEsc': 'https%3A%2F%2Fdelivery.adnuntius.com%2Fc%2F52AHNuxCqxB_Y9ZP9ERWkMBPCOha4zuV3aKn5cog5jsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLB4-k_fySWECIOOmHKY6iokgHNFH-U57ew_-1QHlKnFr2NT8y4QK1oU5HxnDLbYPz-GmQ3C2JyxLGpKmIb-P-3bm7HYPEreNjPdhjRG51A8NGuc4huUhns7nEUejHuOjOHE5sV1zfYxCRWRx9wPDN9EUCC7KN%3Fct%3D2501%26r%3Dhttp%253A%252F%252Fgoogle.com', + 'assets': { + 'image': { + 'cdnId': 'https://assets.adnuntius.com/oEmZa5uYjxENfA1R692FVn6qIveFpO8wUbpyF2xSOCc.jpg', + 'width': '980', + 'height': '120' + } + }, + 'clickUrl': 'https://delivery.adnuntius.com/c/52AHNuxCqxB_Y9ZP9ERWkMBPCOha4zuV3aKn5cog5jsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLB4-k_fySWECIOOmHKY6iokgHNFH-U57ew_-1QHlKnFr2NT8y4QK1oU5HxnDLbYPz-GmQ3C2JyxLGpKmIb-P-3bm7HYPEreNjPdhjRG51A8NGuc4huUhns7nEUejHuOjOHE5sV1zfYxCRWRx9wPDN9EUCC7KN', + 'urls': { + 'destination': 'https://delivery.adnuntius.com/c/52AHNuxCqxB_Y9ZP9ERWkMBPCOha4zuV3aKn5cog5jsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLB4-k_fySWECIOOmHKY6iokgHNFH-U57ew_-1QHlKnFr2NT8y4QK1oU5HxnDLbYPz-GmQ3C2JyxLGpKmIb-P-3bm7HYPEreNjPdhjRG51A8NGuc4huUhns7nEUejHuOjOHE5sV1zfYxCRWRx9wPDN9EUCC7KN?ct=2501&r=http%3A%2F%2Fgoogle.com' + }, + 'urlsEsc': { + 'destination': 'https%3A%2F%2Fdelivery.adnuntius.com%2Fc%2F52AHNuxCqxB_Y9ZP9ERWkMBPCOha4zuV3aKn5cog5jsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLB4-k_fySWECIOOmHKY6iokgHNFH-U57ew_-1QHlKnFr2NT8y4QK1oU5HxnDLbYPz-GmQ3C2JyxLGpKmIb-P-3bm7HYPEreNjPdhjRG51A8NGuc4huUhns7nEUejHuOjOHE5sV1zfYxCRWRx9wPDN9EUCC7KN%3Fct%3D2501%26r%3Dhttp%253A%252F%252Fgoogle.com' + }, + 'destinationUrls': { + 'destination': 'http://google.com' + }, + 'cpm': { 'amount': 5.0, 'currency': 'NOK' }, + 'bid': { 'amount': 0.005, 'currency': 'NOK' }, + 'cost': { 'amount': 0.005, 'currency': 'NOK' }, + 'impressionTrackingUrls': [], + 'impressionTrackingUrlsEsc': [], + 'adId': 'adn-id-1347343135', + 'selectedColumn': '0', + 'selectedColumnPosition': '0', + 'renderedPixel': 'https://delivery.adnuntius.com/b/52AHNuxCqxB_Y9ZP9ERWkMBPCOha4zuV3aKn5cog5jsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLB4-k_fySWECIOOmHKY6iokgHNFH-U57ew_-1QHlKnFr2NT8y4QK1oU5HxnDLbYPz-GmQ3C2JyxLGpKmIb-P-3bm7HYPEreNjPdhjRG51A8NGuc4huUhns7nEUejHuOjOHE5sV1zfYxCRWRx9wPDN9EUCC7KN.html', + 'renderedPixelEsc': 'https%3A%2F%2Fdelivery.adnuntius.com%2Fb%2F52AHNuxCqxB_Y9ZP9ERWkMBPCOha4zuV3aKn5cog5jsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLB4-k_fySWECIOOmHKY6iokgHNFH-U57ew_-1QHlKnFr2NT8y4QK1oU5HxnDLbYPz-GmQ3C2JyxLGpKmIb-P-3bm7HYPEreNjPdhjRG51A8NGuc4huUhns7nEUejHuOjOHE5sV1zfYxCRWRx9wPDN9EUCC7KN.html', + 'visibleUrl': 'https://delivery.adnuntius.com/s?rt=52AHNuxCqxB_Y9ZP9ERWkMBPCOha4zuV3aKn5cog5jsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLB4-k_fySWECIOOmHKY6iokgHNFH-U57ew_-1QHlKnFr2NT8y4QK1oU5HxnDLbYPz-GmQ3C2JyxLGpKmIb-P-3bm7HYPEreNjPdhjRG51A8NGuc4huUhns7nEUejHuOjOHE5sV1zfYxCRWRx9wPDN9EUCC7KN', + 'visibleUrlEsc': 'https%3A%2F%2Fdelivery.adnuntius.com%2Fs%3Frt%3D52AHNuxCqxB_Y9ZP9ERWkMBPCOha4zuV3aKn5cog5jsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLB4-k_fySWECIOOmHKY6iokgHNFH-U57ew_-1QHlKnFr2NT8y4QK1oU5HxnDLbYPz-GmQ3C2JyxLGpKmIb-P-3bm7HYPEreNjPdhjRG51A8NGuc4huUhns7nEUejHuOjOHE5sV1zfYxCRWRx9wPDN9EUCC7KN', + 'viewUrl': 'https://delivery.adnuntius.com/v?rt=52AHNuxCqxB_Y9ZP9ERWkMBPCOha4zuV3aKn5cog5jsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLB4-k_fySWECIOOmHKY6iokgHNFH-U57ew_-1QHlKnFr2NT8y4QK1oU5HxnDLbYPz-GmQ3C2JyxLGpKmIb-P-3bm7HYPEreNjPdhjRG51A8NGuc4huUhns7nEUejHuOjOHE5sV1zfYxCRWRx9wPDN9EUCC7KN', + 'viewUrlEsc': 'https%3A%2F%2Fdelivery.adnuntius.com%2Fv%3Frt%3D52AHNuxCqxB_Y9ZP9ERWkMBPCOha4zuV3aKn5cog5jsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLB4-k_fySWECIOOmHKY6iokgHNFH-U57ew_-1QHlKnFr2NT8y4QK1oU5HxnDLbYPz-GmQ3C2JyxLGpKmIb-P-3bm7HYPEreNjPdhjRG51A8NGuc4huUhns7nEUejHuOjOHE5sV1zfYxCRWRx9wPDN9EUCC7KN', + 'rt': '52AHNuxCqxB_Y9ZP9ERWkMBPCOha4zuV3aKn5cog5jsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLB4-k_fySWECIOOmHKY6iokgHNFH-U57ew_-1QHlKnFr2NT8y4QK1oU5HxnDLbYPz-GmQ3C2JyxLGpKmIb-P-3bm7HYPEreNjPdhjRG51A8NGuc4huUhns7nEUejHuOjOHE5sV1zfYxCRWRx9wPDN9EUCC7KN', + 'creativeWidth': '980', + 'creativeHeight': '120', + 'creativeId': 'wgkq587vgtpchsx1', + 'lineItemId': 'scyjdyv3mzgdsnpf', + 'layoutId': 'sw6gtws2rdj1kwby', + 'layoutName': 'Responsive image' + } + ] + } + ] + } + } + + 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(bidRequests[0])).to.equal(true); + }); + }); + + describe('buildRequests', function () { + it('Test requests', function () { + const request = spec.buildRequests(bidRequests); + expect(request.length).to.equal(1); + expect(request[0]).to.have.property('bid'); + const bid = request[0].bid[0] + expect(bid).to.have.property('bidId'); + expect(request[0]).to.have.property('url'); + expect(request[0].url).to.equal(ENDPOINT_URL); + expect(request[0]).to.have.property('data'); + expect(request[0].data).to.equal('{\"adUnits\":[{\"auId\":\"8b6bc\"}]}'); + }); + }); + + describe('interpretResponse', function () { + it('should return valid response when passed valid server response', function () { + const request = spec.buildRequests(bidRequests); + const interpretedResponse = spec.interpretResponse(serverResponse, request[0]); + const ad = serverResponse.body.adUnits[0].ads[0] + expect(interpretedResponse).to.have.lengthOf(1); + expect(interpretedResponse[0].cpm).to.equal(ad.cpm.amount); + expect(interpretedResponse[0].width).to.equal(Number(ad.creativeWidth)); + expect(interpretedResponse[0].height).to.equal(Number(ad.creativeHeight)); + expect(interpretedResponse[0].creativeId).to.equal(ad.creativeId); + expect(interpretedResponse[0].currency).to.equal(ad.cpm.currency); + expect(interpretedResponse[0].netRevenue).to.equal(false); + expect(interpretedResponse[0].ad).to.equal(serverResponse.body.adUnits[0].html); + expect(interpretedResponse[0].ttl).to.equal(360); + }); + }); +}); diff --git a/test/spec/modules/adoceanBidAdapter_spec.js b/test/spec/modules/adoceanBidAdapter_spec.js index 1fd009ce526..1c3383be5aa 100644 --- a/test/spec/modules/adoceanBidAdapter_spec.js +++ b/test/spec/modules/adoceanBidAdapter_spec.js @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import { spec } from 'modules/adoceanBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; +import { spec } from 'modules/adoceanBidAdapter.js'; +import { newBidder } from 'src/adapters/bidderFactory.js'; describe('AdoceanAdapter', function () { const adapter = newBidder(spec); @@ -95,7 +95,7 @@ describe('AdoceanAdapter', function () { it('sends bid request to url via GET', function () { const request = spec.buildRequests(bidRequests, bidderRequest)[0]; expect(request.method).to.equal('GET'); - expect(request.url).to.match(new RegExp(`^https://${bidRequests[0].params.emiter}/ad.json`)); + expect(request.url).to.match(new RegExp(`^https://${bidRequests[0].params.emiter}/_[0-9]*/ad.json`)); }); it('should attach id to url', function () { diff --git a/test/spec/modules/adomikAnalyticsAdapter_spec.js b/test/spec/modules/adomikAnalyticsAdapter_spec.js index 16480d746b7..1414b2402b9 100644 --- a/test/spec/modules/adomikAnalyticsAdapter_spec.js +++ b/test/spec/modules/adomikAnalyticsAdapter_spec.js @@ -1,4 +1,4 @@ -import adomikAnalytics from 'modules/adomikAnalyticsAdapter'; +import adomikAnalytics from 'modules/adomikAnalyticsAdapter.js'; import {expect} from 'chai'; let events = require('src/events'); let adapterManager = require('src/adapterManager').default; @@ -7,6 +7,13 @@ let constants = require('src/constants.json'); describe('Adomik Prebid Analytic', function () { let sendEventStub; let sendWonEventStub; + let clock; + before(function () { + clock = sinon.useFakeTimers(); + }); + after(function () { + clock.restore(); + }); describe('enableAnalytics', function () { beforeEach(function () { @@ -120,7 +127,6 @@ describe('Adomik Prebid Analytic', function () { expect(adomikAnalytics.currentContext.timeouted).to.equal(true); // Step 7: Send auction end event - var clock = sinon.useFakeTimers(); events.emit(constants.EVENTS.AUCTION_END, {}); setTimeout(function() { @@ -130,7 +136,6 @@ describe('Adomik Prebid Analytic', function () { }, 3000); clock.tick(5000); - clock.restore(); sinon.assert.callCount(adomikAnalytics.track, 6); }); diff --git a/test/spec/modules/adotBidAdapter_spec.js b/test/spec/modules/adotBidAdapter_spec.js new file mode 100644 index 00000000000..594fc4ac7b7 --- /dev/null +++ b/test/spec/modules/adotBidAdapter_spec.js @@ -0,0 +1,3118 @@ +import { expect } from 'chai'; +import { executeRenderer } from 'src/Renderer.js'; +import * as utils from 'src/utils.js'; +import { spec } from 'modules/adotBidAdapter.js'; + +const BIDDER_URL = 'https://dsp.adotmob.com/headerbidding/bidrequest'; + +describe('Adot Adapter', function () { + const examples = { + adUnit_banner: { + adUnitCode: 'ad_unit_banner', + bidder: 'adot', + bidderRequestId: 'bid_request_id', + bidId: 'bid_id', + params: {}, + mediaTypes: { + banner: { + sizes: [[300, 250]] + } + } + }, + + adUnit_video_outstream: { + adUnitCode: 'ad_unit_video_outstream', + bidder: 'adot', + bidderRequestId: 'bid_request_id', + bidId: 'bid_id', + params: { + video: { + mimes: ['video/mp4'], + minDuration: 5, + maxDuration: 30, + protocols: [2, 3] + } + }, + mediaTypes: { + video: { + context: 'outstream', + playerSize: [[300, 250]] + } + } + }, + + adUnit_video_instream: { + adUnitCode: 'ad_unit_video_instream', + bidder: 'adot', + bidderRequestId: 'bid_request_id', + bidId: 'bid_id', + params: { + video: { + instreamContext: 'pre-roll', + mimes: ['video/mp4'], + minDuration: 5, + maxDuration: 30, + protocols: [2, 3] + } + }, + mediaTypes: { + video: { + context: 'instream', + playerSize: [[300, 250]] + } + } + }, + + adUnitContext: { + refererInfo: { + referer: 'https://we-are-adot.com/test', + }, + gdprConsent: { + consentString: 'consent_string', + gdprApplies: true + } + }, + + adUnit_position: { + adUnitCode: 'ad_unit_position', + bidder: 'adot', + bidderRequestId: 'bid_request_id', + bidId: 'bid_id', + params: { + position: 1 + }, + mediaTypes: { + banner: { + sizes: [[300, 250]] + } + } + }, + + adUnit_native: { + adUnitCode: 'ad_unit_native', + bidder: 'adot', + bidderRequestId: 'bid_request_id', + bidId: 'bid_id', + params: {}, + mediaTypes: { + native: { + title: {required: true, len: 140}, + icon: {required: true, sizes: [50, 50]}, + image: {required: false, sizes: [320, 200]}, + sponsoredBy: {required: false}, + body: {required: false}, + cta: {required: true} + } + } + }, + + serverRequest_banner: { + method: 'POST', + url: 'https://we-are-adot.com/bidrequest', + data: { + id: 'bid_request_id', + imp: [ + { + id: 'imp_id_banner_0_0', + banner: { + format: [{ + w: 300, + h: 200 + }] + }, + video: null + } + ], + site: { + page: 'https://we-are-adot.com/test', + domain: 'we-are-adot.com', + name: 'we-are-adot.com' + }, + device: { + ua: '', + language: 'en' + }, + user: null, + regs: null, + at: 1, + ext: { + adot: { + 'adapter_version': 'v1.0.0' + } + } + }, + _adot_internal: { + impressions: [ + { + impressionId: 'imp_id_banner_0_0', + adUnitCode: 'ad_unit_banner', + bidId: 'imp_id_banner' + } + ] + } + }, + + serverRequest_banner_twoImps: { + method: 'POST', + url: 'https://we-are-adot.com/bidrequest', + data: { + id: 'bid_request_id', + imp: [ + { + id: 'imp_id_banner_0_0', + banner: { + format: [{ + w: 300, + h: 200 + }] + }, + video: null + }, + { + id: 'imp_id_banner_2_0_0', + banner: { + format: [{ + w: 300, + h: 200 + }] + }, + video: null + } + ], + site: { + page: 'https://we-are-adot.com/test', + domain: 'we-are-adot.com', + name: 'we-are-adot.com' + }, + device: { + ua: '', + language: 'en' + }, + user: null, + regs: null, + at: 1, + ext: { + adot: { + 'adapter_version': 'v1.0.0' + } + } + }, + _adot_internal: { + impressions: [ + { + impressionId: 'imp_id_banner_0_0', + adUnitCode: 'ad_unit_banner', + bidId: 'imp_id_banner' + }, + { + impressionId: 'imp_id_banner_2_0_0', + adUnitCode: 'ad_unit_banner_2', + bidId: 'imp_id_banner_2' + } + ] + } + }, + + serverRequest_video_instream: { + method: 'POST', + url: 'https://we-are-adot.com/bidrequest', + data: { + id: 'bid_request_id', + imp: [ + { + id: 'imp_id_video_instream_0', + banner: null, + video: { + mimes: ['video/mp4'], + w: 300, + h: 200, + startdelay: 0, + minduration: 5, + maxduration: 35, + protocols: [2, 3] + } + } + ], + site: { + page: 'https://we-are-adot.com/test', + domain: 'we-are-adot.com', + name: 'we-are-adot.com' + }, + device: { + ua: '', + language: 'en' + }, + user: null, + regs: null, + at: 1, + ext: { + adot: { + 'adapter_version': 'v1.0.0' + } + } + }, + _adot_internal: { + impressions: [ + { + impressionId: 'imp_id_video_instream_0', + adUnitCode: 'ad_unit_video_instream', + bidId: 'imp_id_video_instream' + } + ] + } + }, + + serverRequest_video_outstream: { + method: 'POST', + url: 'https://we-are-adot.com/bidrequest', + data: { + id: 'bid_request_id', + imp: [ + { + id: 'imp_id_video_outstream_0', + banner: null, + video: { + mimes: ['video/mp4'], + w: 300, + h: 200, + startdelay: null, + minduration: 5, + maxduration: 35, + protocols: [2, 3] + } + } + ], + site: { + page: 'https://we-are-adot.com/test', + domain: 'we-are-adot.com', + name: 'we-are-adot.com' + }, + device: { + ua: '', + language: 'en' + }, + user: null, + regs: null, + at: 1, + ext: { + adot: { + 'adapter_version': 'v1.0.0' + } + } + }, + _adot_internal: { + impressions: [ + { + impressionId: 'imp_id_video_outstream_0', + adUnitCode: 'ad_unit_video_outstream', + bidId: 'imp_id_video_outstream' + } + ] + } + }, + + serverRequest_video_instream_outstream: { + method: 'POST', + url: 'https://we-are-adot.com/bidrequest', + data: { + id: 'bid_request_id', + imp: [ + { + id: 'imp_id_video_instream_0', + banner: null, + video: { + mimes: ['video/mp4'], + w: 300, + h: 200, + startdelay: 0, + minduration: 5, + maxduration: 35, + protocols: [2, 3] + } + }, + { + id: 'imp_id_video_outstream_0', + banner: null, + video: { + mimes: ['video/mp4'], + w: 300, + h: 200, + startdelay: null, + minduration: 5, + maxduration: 35, + protocols: [2, 3] + } + } + ], + site: { + page: 'https://we-are-adot.com/test', + domain: 'we-are-adot.com', + name: 'we-are-adot.com' + }, + device: { + ua: '', + language: 'en' + }, + user: null, + regs: null, + at: 1, + ext: { + adot: { + 'adapter_version': 'v1.0.0' + } + } + }, + _adot_internal: { + impressions: [ + { + impressionId: 'imp_id_video_instream_0', + adUnitCode: 'ad_unit_video_instream', + bidId: 'imp_id_video_instream' + }, + { + impressionId: 'imp_id_video_outstream_0', + adUnitCode: 'ad_unit_video_outstream', + bidId: 'imp_id_video_outstream' + } + ] + } + }, + + serverRequest_position: { + method: 'POST', + url: 'https://we-are-adot.com/bidrequest', + data: { + id: 'bid_request_id', + imp: [ + { + id: 'imp_id_banner', + banner: { + format: [{ + w: 300, + h: 200 + }], + position: 1 + }, + video: null + } + ], + site: { + page: 'https://we-are-adot.com/test', + domain: 'we-are-adot.com', + name: 'we-are-adot.com' + }, + device: { + ua: '', + language: 'en' + }, + user: null, + regs: null, + at: 1, + ext: { + adot: { + 'adapter_version': 'v1.0.0' + } + } + }, + _adot_internal: { + impressions: [ + { + impressionId: 'imp_id_banner', + adUnitCode: 'ad_unit_position' + } + ] + } + }, + + serverRequest_native: { + method: 'POST', + url: 'https://we-are-adot.com/bidrequest', + data: { + id: 'bid_request_id', + imp: [ + { + id: 'imp_id_native_0', + native: { + request: { + assets: [ + { + id: 1, + required: true, + title: { + len: 140 + } + }, + { + id: 2, + required: true, + img: { + type: 1, + wmin: 50, + hmin: 50 + } + }, + { + id: 3, + required: false, + img: { + type: 3, + wmin: 320, + hmin: 200 + } + }, + { + id: 4, + required: false, + data: { + type: 1 + } + }, + { + id: 5, + required: false, + data: { + type: 2 + } + }, + { + id: 6, + required: true, + data: { + type: 12 + } + } + ] + } + }, + video: null, + banner: null + } + ], + site: { + page: 'https://we-are-adot.com/test', + domain: 'we-are-adot.com', + name: 'we-are-adot.com' + }, + device: { + ua: '', + language: 'en' + }, + user: null, + regs: null, + at: 1, + ext: { + adot: { + 'adapter_version': 'v1.0.0' + } + } + }, + _adot_internal: { + impressions: [ + { + impressionId: 'imp_id_native_0', + adUnitCode: 'ad_unit_native', + bidId: 'imp_id_native' + } + ] + } + }, + + serverResponse_banner: { + body: { + cur: 'EUR', + seatbid: [ + { + bid: [ + { + impid: 'imp_id_banner_0_0', + crid: 'creative_id', + adm: 'creative_data_${AUCTION_PRICE}', + nurl: 'win_notice_url_${AUCTION_PRICE}', + price: 1.5, + h: 350, + w: 300, + ext: { + adot: { + media_type: 'banner' + } + } + } + ] + } + ] + } + }, + + serverResponse_banner_twoBids: { + body: { + cur: 'EUR', + seatbid: [ + { + bid: [ + { + impid: 'imp_id_banner_0_0', + crid: 'creative_id', + adm: 'creative_data_${AUCTION_PRICE}', + nurl: 'win_notice_url_${AUCTION_PRICE}', + price: 1.5, + h: 350, + w: 300, + ext: { + adot: { + media_type: 'banner' + } + } + }, + { + impid: 'imp_id_banner_2_0_0', + crid: 'creative_id_2', + adm: 'creative_data_2_${AUCTION_PRICE}', + nurl: 'win_notice_url_2_${AUCTION_PRICE}', + price: 2.5, + h: 400, + w: 350, + ext: { + adot: { + media_type: 'banner' + } + } + } + ] + } + ] + } + }, + + serverResponse_video_instream: { + body: { + cur: 'EUR', + seatbid: [ + { + bid: [ + { + impid: 'imp_id_video_instream_0', + crid: 'creative_id', + adm: 'creative_data_${AUCTION_PRICE}', + nurl: 'win_notice_url_${AUCTION_PRICE}', + price: 1.5, + ext: { + adot: { + media_type: 'video' + } + } + } + ] + } + ] + } + }, + + serverResponse_video_outstream: { + body: { + cur: 'EUR', + seatbid: [ + { + bid: [ + { + impid: 'imp_id_video_outstream_0', + crid: 'creative_id', + adm: 'creative_data_${AUCTION_PRICE}', + nurl: 'win_notice_url_${AUCTION_PRICE}', + price: 1.5, + ext: { + adot: { + media_type: 'video' + } + } + } + ] + } + ] + } + }, + + serverResponse_video_instream_outstream: { + body: { + cur: 'EUR', + seatbid: [ + { + bid: [ + { + impid: 'imp_id_video_instream_0', + crid: 'creative_id', + adm: 'creative_data_${AUCTION_PRICE}', + nurl: 'win_notice_url_${AUCTION_PRICE}', + price: 1.5, + ext: { + adot: { + media_type: 'video' + } + } + }, + { + impid: 'imp_id_video_outstream_0', + crid: 'creative_id', + adm: 'creative_data_${AUCTION_PRICE}', + nurl: 'win_notice_url_${AUCTION_PRICE}', + price: 1.5, + ext: { + adot: { + media_type: 'video' + } + } + } + ] + } + ] + } + }, + + serverResponse_native: { + body: { + cur: 'EUR', + seatbid: [ + { + bid: [ + { + impid: 'imp_id_native_0', + crid: 'creative_id', + adm: '{"native":{"assets":[{"id":1,"title":{"len":140,"text":"Hi everyone"}},{"id":2,"img":{"url":"https://adotmob.com","type":1,"w":50,"h":50}},{"id":3,"img":{"url":"https://adotmob.com","type":3,"w":320,"h":200}},{"id":4,"data":{"type":1,"value":"adotmob"}},{"id":5,"data":{"type":2,"value":"This is a test ad"}},{"id":6,"data":{"type":12,"value":"Click to buy"}}],"link":{"url":"https://adotmob.com?auction=${AUCTION_PRICE}"}}}', + nurl: 'win_notice_url_${AUCTION_PRICE}', + price: 1.5, + ext: { + adot: { + media_type: 'native' + } + } + } + ] + } + ] + } + } + }; + + describe('isBidRequestValid', function () { + describe('General', function () { + it('should return false when not given an ad unit', function () { + const adUnit = undefined; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an invalid ad unit', function () { + const adUnit = 'bad_bid'; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit without bidder code', function () { + const adUnit = utils.deepClone(examples.adUnit_banner); + adUnit.bidder = undefined; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit with a bad bidder code', function () { + const adUnit = utils.deepClone(examples.adUnit_banner); + adUnit.bidder = 'unknownBidder'; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit without ad unit code', function () { + const adUnit = utils.deepClone(examples.adUnit_banner); + adUnit.adUnitCode = undefined; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit with an invalid ad unit code', function () { + const adUnit = utils.deepClone(examples.adUnit_banner); + adUnit.adUnitCode = {}; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit without bid request identifier', function () { + const adUnit = utils.deepClone(examples.adUnit_banner); + adUnit.bidderRequestId = undefined; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit with an invalid bid request identifier', function () { + const adUnit = utils.deepClone(examples.adUnit_banner); + adUnit.bidderRequestId = {}; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit without impression identifier', function () { + const adUnit = utils.deepClone(examples.adUnit_banner); + adUnit.bidId = undefined; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit with an invalid impression identifier', function () { + const adUnit = utils.deepClone(examples.adUnit_banner); + adUnit.bidId = {}; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit without media types', function () { + const adUnit = utils.deepClone(examples.adUnit_banner); + adUnit.mediaTypes = undefined; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit with empty media types', function () { + const adUnit = utils.deepClone(examples.adUnit_banner); + adUnit.mediaTypes = {}; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit with invalid media types', function () { + const adUnit = utils.deepClone(examples.adUnit_banner); + adUnit.mediaTypes = 'bad_media_types'; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + }); + + describe('Banner', function () { + it('should return true when given a valid ad unit', function () { + const adUnit = examples.adUnit_banner; + + expect(spec.isBidRequestValid(adUnit)).to.equal(true); + }); + + it('should return true when given a valid ad unit without bidder parameters', function () { + const adUnit = utils.deepClone(examples.adUnit_banner); + adUnit.params = undefined; + + expect(spec.isBidRequestValid(adUnit)).to.equal(true); + }); + + it('should return false when given an ad unit without size', function () { + const adUnit = utils.deepClone(examples.adUnit_banner); + adUnit.mediaTypes.banner.sizes = undefined; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit with an invalid size', function () { + const adUnit = utils.deepClone(examples.adUnit_banner); + adUnit.mediaTypes.banner.sizes = 'bad_banner_size'; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit with an empty size', function () { + const adUnit = utils.deepClone(examples.adUnit_banner); + adUnit.mediaTypes.banner.sizes = []; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit with an invalid size value', function () { + const adUnit = utils.deepClone(examples.adUnit_banner); + adUnit.mediaTypes.banner.sizes = ['bad_banner_size_value']; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit with a size value with less than 2 dimensions', function () { + const adUnit = utils.deepClone(examples.adUnit_banner); + adUnit.mediaTypes.banner.sizes = [[300]]; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit with a size value with more than 2 dimensions', function () { + const adUnit = utils.deepClone(examples.adUnit_banner); + adUnit.mediaTypes.banner.sizes = [[300, 250, 30]]; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit with a negative width value', function () { + const adUnit = utils.deepClone(examples.adUnit_banner); + adUnit.mediaTypes.banner.sizes = [[-300, 250]]; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit with a negative height value', function () { + const adUnit = utils.deepClone(examples.adUnit_banner); + adUnit.mediaTypes.banner.sizes = [[300, -250]]; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit with an invalid width value', function () { + const adUnit = utils.deepClone(examples.adUnit_banner); + adUnit.mediaTypes.banner.sizes = [[false, 250]]; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit with an invalid height value', function () { + const adUnit = utils.deepClone(examples.adUnit_banner); + adUnit.mediaTypes.banner.sizes = [[300, {}]]; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + }); + + describe('Video', function () { + it('should return true when given a valid outstream ad unit', function () { + const adUnit = examples.adUnit_video_outstream; + + expect(spec.isBidRequestValid(adUnit)).to.equal(true); + }); + + it('should return true when given a valid pre-roll instream ad unit', function () { + const adUnit = utils.deepClone(examples.adUnit_video_instream); + adUnit.params.video.instreamContext = 'pre-roll'; + + expect(spec.isBidRequestValid(adUnit)).to.equal(true); + }); + + it('should return true when given a valid mid-roll instream ad unit', function () { + const adUnit = utils.deepClone(examples.adUnit_video_instream); + adUnit.params.video.instreamContext = 'mid-roll'; + + expect(spec.isBidRequestValid(adUnit)).to.equal(true); + }); + + it('should return true when given a valid post-roll instream ad unit', function () { + const adUnit = utils.deepClone(examples.adUnit_video_instream); + adUnit.params.video.instreamContext = 'post-roll'; + + expect(spec.isBidRequestValid(adUnit)).to.equal(true); + }); + + it('should return true when given an ad unit without size', function () { + const adUnit = utils.deepClone(examples.adUnit_video_outstream); + adUnit.mediaTypes.video.playerSize = undefined; + + expect(spec.isBidRequestValid(adUnit)).to.equal(true); + }); + + it('should return true when given an ad unit with an empty size', function () { + const adUnit = utils.deepClone(examples.adUnit_video_outstream); + adUnit.mediaTypes.video.playerSize = []; + + expect(spec.isBidRequestValid(adUnit)).to.equal(true); + }); + + it('should return true when given an ad unit without minimum duration parameter', function () { + const adUnit = utils.deepClone(examples.adUnit_video_outstream); + adUnit.params.video.minDuration = undefined; + + expect(spec.isBidRequestValid(adUnit)).to.equal(true); + }); + + it('should return true when given an ad unit without maximum duration parameter', function () { + const adUnit = utils.deepClone(examples.adUnit_video_outstream); + adUnit.params.video.maxDuration = undefined; + + expect(spec.isBidRequestValid(adUnit)).to.equal(true); + }); + + it('should return false when given an ad unit without bidder parameters', function () { + const adUnit = utils.deepClone(examples.adUnit_video_outstream); + adUnit.params = undefined; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit with invalid bidder parameters', function () { + const adUnit = utils.deepClone(examples.adUnit_video_outstream); + adUnit.params = 'bad_bidder_parameters'; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit without video parameters', function () { + const adUnit = utils.deepClone(examples.adUnit_video_outstream); + adUnit.params.video = undefined; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit with invalid video parameters', function () { + const adUnit = utils.deepClone(examples.adUnit_video_outstream); + adUnit.params.video = 'bad_bidder_parameters'; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit without mime types parameter', function () { + const adUnit = utils.deepClone(examples.adUnit_video_outstream); + adUnit.params.video.mimes = undefined; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit with an invalid mime types parameter', function () { + const adUnit = utils.deepClone(examples.adUnit_video_outstream); + adUnit.params.video.mimes = 'bad_mime_types'; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit with an empty mime types parameter', function () { + const adUnit = utils.deepClone(examples.adUnit_video_outstream); + adUnit.params.video.mimes = []; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit with an invalid mime types parameter value', function () { + const adUnit = utils.deepClone(examples.adUnit_video_outstream); + adUnit.params.video.mimes = [200]; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit with an invalid minimum duration parameter', function () { + const adUnit = utils.deepClone(examples.adUnit_video_outstream); + adUnit.params.video.minDuration = 'bad_min_duration'; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit with an invalid maximum duration parameter', function () { + const adUnit = utils.deepClone(examples.adUnit_video_outstream); + adUnit.params.video.maxDuration = 'bad_max_duration'; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit without protocols parameter', function () { + const adUnit = utils.deepClone(examples.adUnit_video_outstream); + adUnit.params.video.protocols = undefined; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit with an invalid protocols parameter', function () { + const adUnit = utils.deepClone(examples.adUnit_video_outstream); + adUnit.params.video.protocols = 'bad_protocols'; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit with an empty protocols parameter', function () { + const adUnit = utils.deepClone(examples.adUnit_video_outstream); + adUnit.params.video.protocols = []; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit with an invalid protocols parameter value', function () { + const adUnit = utils.deepClone(examples.adUnit_video_outstream); + adUnit.params.video.protocols = ['bad_protocols_value']; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an instream ad unit without instream context', function () { + const adUnit = utils.deepClone(examples.adUnit_video_instream); + adUnit.params.video.instreamContext = undefined; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an instream ad unit with an invalid instream context', function () { + const adUnit = utils.deepClone(examples.adUnit_video_instream); + adUnit.params.video.instreamContext = 'bad_instream_context'; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit without context', function () { + const adUnit = utils.deepClone(examples.adUnit_video_outstream); + adUnit.mediaTypes.video.context = undefined; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit with an invalid context', function () { + const adUnit = utils.deepClone(examples.adUnit_video_outstream); + adUnit.mediaTypes.video.context = []; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an adpod ad unit', function () { + const adUnit = utils.deepClone(examples.adUnit_video_outstream); + adUnit.mediaTypes.video.context = 'adpod'; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit with an unknown context', function () { + const adUnit = utils.deepClone(examples.adUnit_video_outstream); + adUnit.mediaTypes.video.context = 'invalid_context'; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit with an invalid size', function () { + const adUnit = utils.deepClone(examples.adUnit_video_outstream); + adUnit.mediaTypes.video.playerSize = 'bad_video_size'; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit with an invalid size value', function () { + const adUnit = utils.deepClone(examples.adUnit_video_outstream); + adUnit.mediaTypes.video.playerSize = ['bad_video_size_value']; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit with a size value with less than 2 dimensions', function () { + const adUnit = utils.deepClone(examples.adUnit_video_outstream); + adUnit.mediaTypes.video.playerSize = [[300]]; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit with a size value with more than 2 dimensions', function () { + const adUnit = utils.deepClone(examples.adUnit_video_outstream); + adUnit.mediaTypes.video.playerSize = [[300, 250, 30]]; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit with a negative width value', function () { + const adUnit = utils.deepClone(examples.adUnit_video_outstream); + adUnit.mediaTypes.video.playerSize = [[-300, 250]]; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit with a negative height value', function () { + const adUnit = utils.deepClone(examples.adUnit_video_outstream); + adUnit.mediaTypes.video.playerSize = [[300, -250]]; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit with an invalid width value', function () { + const adUnit = utils.deepClone(examples.adUnit_video_outstream); + adUnit.mediaTypes.video.playerSize = [[false, 250]]; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + + it('should return false when given an ad unit with an invalid height value', function () { + const adUnit = utils.deepClone(examples.adUnit_video_outstream); + adUnit.mediaTypes.video.playerSize = [[300, {}]]; + + expect(spec.isBidRequestValid(adUnit)).to.equal(false); + }); + }); + }); + + describe('buildRequests', function () { + describe('ServerRequest', function () { + it('should return a server request when given a valid ad unit and a valid ad unit context', function () { + const adUnits = [examples.adUnit_banner]; + + const serverRequests = spec.buildRequests(adUnits, examples.adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.length(1); + expect(serverRequests[0].method).to.exist.and.to.be.a('string').and.to.equal('POST'); + expect(serverRequests[0].url).to.exist.and.to.be.a('string').and.to.equal(BIDDER_URL); + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0]._adot_internal).to.exist.and.to.be.an('object'); + expect(serverRequests[0]._adot_internal.impressions).to.exist.and.to.be.an('array').and.to.have.length(1); + expect(serverRequests[0]._adot_internal.impressions[0]).to.exist.and.to.be.an('object'); + expect(serverRequests[0]._adot_internal.impressions[0].impressionId).to.exist.and.to.be.a('string').and.to.equal(`${adUnits[0].bidId}_0_0`); + expect(serverRequests[0]._adot_internal.impressions[0].adUnitCode).to.exist.and.to.be.a('string').and.to.equal(adUnits[0].adUnitCode); + }); + + it('should return a server request containing a position when given a valid ad unit and a valid ad unit context and a position in the bidder params', function () { + const adUnits = [examples.adUnit_position]; + + const serverRequests = spec.buildRequests(adUnits, examples.adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.length(1); + expect(serverRequests[0].method).to.exist.and.to.be.a('string').and.to.equal('POST'); + expect(serverRequests[0].url).to.exist.and.to.be.a('string').and.to.equal(BIDDER_URL); + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0]._adot_internal).to.exist.and.to.be.an('object'); + expect(serverRequests[0]._adot_internal.impressions).to.exist.and.to.be.an('array').and.to.have.length(1); + expect(serverRequests[0]._adot_internal.impressions[0]).to.exist.and.to.be.an('object'); + expect(serverRequests[0]._adot_internal.impressions[0].impressionId).to.exist.and.to.be.a('string').and.to.equal(`${adUnits[0].bidId}_0_0`); + expect(serverRequests[0]._adot_internal.impressions[0].adUnitCode).to.exist.and.to.be.a('string').and.to.equal(adUnits[0].adUnitCode); + expect(serverRequests[0].data.imp[0].banner.pos).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].params.position); + }); + + it('should return a server request when given two valid ad units and a valid ad unit context', function () { + const adUnits_1 = utils.deepClone(examples.adUnit_banner); + adUnits_1.bidId = 'bid_id_1'; + adUnits_1.adUnitCode = 'ad_unit_banner_1'; + + const adUnits_2 = utils.deepClone(examples.adUnit_banner); + adUnits_2.bidId = 'bid_id_2'; + adUnits_2.adUnitCode = 'ad_unit_banner_2'; + + const adUnits = [adUnits_1, adUnits_2]; + + const serverRequests = spec.buildRequests(adUnits, examples.adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.length(1); + expect(serverRequests[0].method).to.exist.and.to.be.a('string').and.to.equal('POST'); + expect(serverRequests[0].url).to.exist.and.to.be.a('string').and.to.equal(BIDDER_URL); + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0]._adot_internal).to.exist.and.to.be.an('object'); + expect(serverRequests[0]._adot_internal.impressions).to.exist.and.to.be.an('array').and.to.have.length(2); + expect(serverRequests[0]._adot_internal.impressions[0]).to.exist.and.to.be.an('object'); + expect(serverRequests[0]._adot_internal.impressions[0].impressionId).to.exist.and.to.be.a('string').and.to.equal(`${adUnits[0].bidId}_0_0`); + expect(serverRequests[0]._adot_internal.impressions[0].adUnitCode).to.exist.and.to.be.a('string').and.to.equal(adUnits[0].adUnitCode); + expect(serverRequests[0]._adot_internal.impressions[1]).to.exist.and.to.be.an('object'); + expect(serverRequests[0]._adot_internal.impressions[1].impressionId).to.exist.and.to.be.a('string').and.to.equal(`${adUnits[1].bidId}_0_0`); + expect(serverRequests[0]._adot_internal.impressions[1].adUnitCode).to.exist.and.to.be.a('string').and.to.equal(adUnits[1].adUnitCode); + }); + + it('should return an empty server request list when given an empty ad unit list and a valid ad unit context', function () { + const adUnits = []; + + const serverRequests = spec.buildRequests(adUnits, examples.adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.length(0); + }); + + it('should not return a server request when given no ad unit and a valid ad unit context', function () { + const serverRequests = spec.buildRequests(null, examples.adUnitContext); + + expect(serverRequests).to.equal(null); + }); + + it('should not return a server request when given a valid ad unit and no ad unit context', function () { + const adUnits = [examples.adUnit_banner]; + + const serverRequests = spec.buildRequests(adUnits, null); + + expect(serverRequests).to.be.an('array').and.to.have.length(1); + }); + + it('should not return a server request when given a valid ad unit and an invalid ad unit context', function () { + const adUnits = [examples.adUnit_banner]; + + const serverRequests = spec.buildRequests(adUnits, {}); + + expect(serverRequests).to.be.an('array').and.to.have.length(1); + }); + }); + + describe('BidRequest', function () { + it('should return a valid server request when given a valid ad unit', function () { + const adUnits = [examples.adUnit_banner]; + + const serverRequests = spec.buildRequests(adUnits, examples.adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data.id).to.exist.and.to.be.a('string').and.to.equal(adUnits[0].bidderRequestId); + expect(serverRequests[0].data.at).to.exist.and.to.be.a('number').and.to.equal(1); + expect(serverRequests[0].data.ext).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.ext.adot).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.ext.adot.adapter_version).to.exist.and.to.be.a('string').and.to.equal('v1.0.0'); + }); + + it('should return one server request when given one valid ad unit', function () { + const adUnits = [examples.adUnit_banner]; + + const serverRequests = spec.buildRequests(adUnits, examples.adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data.id).to.exist.and.to.be.a('string').and.to.equal(adUnits[0].bidderRequestId); + }); + + it('should return one server request when given two valid ad units with different impression identifiers', function () { + const adUnit_1 = utils.deepClone(examples.adUnit_banner); + adUnit_1.bidId = 'bid_id_1'; + + const adUnit_2 = utils.deepClone(examples.adUnit_banner); + adUnit_2.bidId = 'bid_id_2'; + + const adUnits = [adUnit_1, adUnit_2]; + + const serverRequests = spec.buildRequests(adUnits, examples.adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data.id).to.exist.and.to.be.a('string').and.to.equal(adUnits[0].bidderRequestId); + expect(serverRequests[0].data.id).to.exist.and.to.be.a('string').and.to.equal(adUnits[1].bidderRequestId); + }); + + it('should return two server requests when given two valid ad units with different bid request identifiers', function () { + const adUnit_1 = utils.deepClone(examples.adUnit_banner); + adUnit_1.bidderRequestId = 'bidder_request_id_1'; + + const adUnit_2 = utils.deepClone(examples.adUnit_banner); + adUnit_2.bidderRequestId = 'bidder_request_id_2'; + + const adUnits = [adUnit_1, adUnit_2]; + + const serverRequests = spec.buildRequests(adUnits, examples.adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(2); + expect(serverRequests[0].data.id).to.exist.and.to.be.a('string').and.to.equal(adUnits[0].bidderRequestId); + expect(serverRequests[1].data.id).to.exist.and.to.be.a('string').and.to.equal(adUnits[1].bidderRequestId); + }); + }); + + describe('Impression', function () { + describe('Banner', function () { + it('should return a server request with one impression when given a valid ad unit', function () { + const adUnits = [examples.adUnit_banner]; + + const serverRequests = spec.buildRequests(adUnits, examples.adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); + + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp).to.exist.and.to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data.imp[0]).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp[0].id).to.exist.and.to.be.a('string').and.to.equal(`${adUnits[0].bidId}_0_0`); + expect(serverRequests[0].data.imp[0].banner).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp[0].banner.w).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].mediaTypes.banner.sizes[0][0]); + expect(serverRequests[0].data.imp[0].banner.h).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].mediaTypes.banner.sizes[0][1]); + expect(serverRequests[0].data.imp[0].banner.format).to.exist.and.to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data.imp[0].banner.format[0]).to.exist.and.to.be.an('object').and.to.deep.equal({ + w: adUnits[0].mediaTypes.banner.sizes[0][0], + h: adUnits[0].mediaTypes.banner.sizes[0][1] + }); + }); + + it('should return a server request with two impressions containing one banner formats when given a valid ad unit with two banner sizes', function () { + const adUnit = utils.deepClone(examples.adUnit_banner); + adUnit.mediaTypes.banner.sizes = [ + [300, 250], + [350, 300] + ]; + + const adUnits = [adUnit]; + + const serverRequests = spec.buildRequests(adUnits, examples.adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); + + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp).to.exist.and.to.be.an('array').and.to.have.lengthOf(2); + + expect(serverRequests[0].data.imp[0]).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp[0].id).to.exist.and.to.be.a('string').and.to.equal(`${adUnits[0].bidId}_0_0`); + expect(serverRequests[0].data.imp[0].banner).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp[0].banner.w).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].mediaTypes.banner.sizes[0][0]); + expect(serverRequests[0].data.imp[0].banner.h).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].mediaTypes.banner.sizes[0][1]); + expect(serverRequests[0].data.imp[0].banner.format).to.exist.and.to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data.imp[0].banner.format[0]).to.exist.and.to.be.an('object').and.to.deep.equal({ + w: adUnits[0].mediaTypes.banner.sizes[0][0], + h: adUnits[0].mediaTypes.banner.sizes[0][1] + }); + + expect(serverRequests[0].data.imp[1]).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp[1].id).to.exist.and.to.be.a('string').and.to.equal(`${adUnits[0].bidId}_0_1`); + expect(serverRequests[0].data.imp[1].banner).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp[1].banner.w).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].mediaTypes.banner.sizes[1][0]); + expect(serverRequests[0].data.imp[1].banner.h).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].mediaTypes.banner.sizes[1][1]); + expect(serverRequests[0].data.imp[1].banner.format).to.exist.and.to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data.imp[1].banner.format[0]).to.exist.and.to.be.an('object').and.to.deep.equal({ + w: adUnits[0].mediaTypes.banner.sizes[1][0], + h: adUnits[0].mediaTypes.banner.sizes[1][1] + }); + }); + + it('should return a server request with two impressions when given two valid ad units with different impression identifiers', function () { + const adUnit_1 = utils.deepClone(examples.adUnit_banner); + adUnit_1.bidId = 'bid_id_1'; + + const adUnit_2 = utils.deepClone(examples.adUnit_banner); + adUnit_2.bidId = 'bid_id_2'; + + const adUnits = [adUnit_1, adUnit_2]; + + const serverRequests = spec.buildRequests(adUnits, examples.adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); + + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp).to.exist.and.to.be.an('array').and.to.have.lengthOf(2); + expect(serverRequests[0].data.imp[0]).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp[0].id).to.exist.and.to.be.a('string').and.to.equal(`${adUnits[0].bidId}_0_0`); + expect(serverRequests[0].data.imp[0].banner).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp[0].banner.w).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].mediaTypes.banner.sizes[0][0]); + expect(serverRequests[0].data.imp[0].banner.h).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].mediaTypes.banner.sizes[0][1]); + expect(serverRequests[0].data.imp[0].banner.format).to.exist.and.to.be.an('array'); + expect(serverRequests[0].data.imp[0].banner.format[0]).to.exist.and.to.be.an('object').and.to.deep.equal({ + w: adUnits[0].mediaTypes.banner.sizes[0][0], + h: adUnits[0].mediaTypes.banner.sizes[0][1] + }); + expect(serverRequests[0].data.imp[1]).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp[1].id).to.exist.and.to.be.a('string').and.to.equal(`${adUnits[1].bidId}_0_0`); + expect(serverRequests[0].data.imp[1].banner).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp[1].banner.w).to.exist.and.to.be.a('number').and.to.equal(adUnits[1].mediaTypes.banner.sizes[0][0]); + expect(serverRequests[0].data.imp[1].banner.h).to.exist.and.to.be.a('number').and.to.equal(adUnits[1].mediaTypes.banner.sizes[0][1]); + expect(serverRequests[0].data.imp[1].banner.format).to.exist.and.to.be.an('array'); + expect(serverRequests[0].data.imp[1].banner.format[0]).to.exist.and.to.be.an('object').and.to.deep.equal({ + w: adUnits[1].mediaTypes.banner.sizes[0][0], + h: adUnits[1].mediaTypes.banner.sizes[0][1] + }); + }); + + it('should return a server request with one overriden impression when given two valid ad units with identical identifiers', function () { + const adUnit_1 = utils.deepClone(examples.adUnit_banner); + adUnit_1.mediaTypes.banner.sizes = [[300, 250]]; + + const adUnit_2 = utils.deepClone(examples.adUnit_banner); + adUnit_2.mediaTypes.banner.sizes = [[350, 300]]; + + const adUnits = [adUnit_1, adUnit_2]; + + const serverRequests = spec.buildRequests(adUnits, examples.adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp).to.exist.and.to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data.imp[0]).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp[0].id).to.exist.and.to.be.a('string').and.to.equal(`${adUnits[1].bidId}_0_0`); + expect(serverRequests[0].data.imp[0].banner).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp[0].banner.w).to.exist.and.to.be.a('number').and.to.equal(adUnits[1].mediaTypes.banner.sizes[0][0]); + expect(serverRequests[0].data.imp[0].banner.h).to.exist.and.to.be.a('number').and.to.equal(adUnits[1].mediaTypes.banner.sizes[0][1]); + expect(serverRequests[0].data.imp[0].banner.format).to.exist.and.to.be.an('array'); + expect(serverRequests[0].data.imp[0].banner.format[0]).to.exist.and.to.be.an('object').and.to.deep.equal({ + w: adUnits[1].mediaTypes.banner.sizes[0][0], + h: adUnits[1].mediaTypes.banner.sizes[0][1] + }); + }); + + it('should return two server requests with one impression when given two valid ad units with different bid request identifiers', function () { + const adUnit_1 = utils.deepClone(examples.adUnit_banner); + adUnit_1.bidderRequestId = 'bidder_request_id_1'; + + const adUnit_2 = utils.deepClone(examples.adUnit_banner); + adUnit_2.bidderRequestId = 'bidder_request_id_2'; + + const adUnits = [adUnit_1, adUnit_2]; + + const serverRequests = spec.buildRequests(adUnits, examples.adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(2); + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp).to.exist.and.to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data.imp[0]).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp[0].id).to.exist.and.to.be.a('string').and.to.equal(`${adUnits[0].bidId}_0_0`); + expect(serverRequests[0].data.imp[0].banner).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp[0].banner.w).to.exist.and.to.be.a('number').and.to.equal(adUnits[1].mediaTypes.banner.sizes[0][0]); + expect(serverRequests[0].data.imp[0].banner.h).to.exist.and.to.be.a('number').and.to.equal(adUnits[1].mediaTypes.banner.sizes[0][1]); + expect(serverRequests[0].data.imp[0].banner.format).to.exist.and.to.be.an('array'); + expect(serverRequests[0].data.imp[0].banner.format[0]).to.exist.and.to.be.an('object').and.to.deep.equal({ + w: adUnits[0].mediaTypes.banner.sizes[0][0], + h: adUnits[0].mediaTypes.banner.sizes[0][1] + }); + expect(serverRequests[1].data).to.exist.and.to.be.an('object'); + expect(serverRequests[1].data.id).to.exist.and.to.be.an('string').and.to.equal(adUnits[1].bidderRequestId); + expect(serverRequests[1].data.imp).to.exist.and.to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[1].data.imp[0]).to.exist.and.to.be.an('object'); + expect(serverRequests[1].data.imp[0].id).to.exist.and.to.be.a('string').and.to.equal(`${adUnits[1].bidId}_0_0`); + expect(serverRequests[1].data.imp[0].banner).to.exist.and.to.be.an('object'); + expect(serverRequests[1].data.imp[0].banner.w).to.exist.and.to.be.a('number').and.to.equal(adUnits[1].mediaTypes.banner.sizes[0][0]); + expect(serverRequests[1].data.imp[0].banner.h).to.exist.and.to.be.a('number').and.to.equal(adUnits[1].mediaTypes.banner.sizes[0][1]); + expect(serverRequests[1].data.imp[0].banner.format).to.exist.and.to.be.an('array'); + expect(serverRequests[1].data.imp[0].banner.format[0]).to.exist.and.to.be.an('object').and.to.deep.equal({ + w: adUnits[1].mediaTypes.banner.sizes[0][0], + h: adUnits[1].mediaTypes.banner.sizes[0][1] + }); + }); + }); + + describe('Video', function () { + it('should return a server request with one impression when given a valid outstream ad unit', function () { + const adUnit = examples.adUnit_video_outstream; + + const adUnits = [adUnit]; + + const serverRequests = spec.buildRequests(adUnits, examples.adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); + + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp).to.exist.and.to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data.imp[0]).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp[0].id).to.exist.and.to.be.a('string').and.to.equal(`${adUnits[0].bidId}_0`); + expect(serverRequests[0].data.imp[0].video).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp[0].video.mimes).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].params.video.mimes); + expect(serverRequests[0].data.imp[0].video.startdelay).to.equal(null); + expect(serverRequests[0].data.imp[0].video.w).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].mediaTypes.video.playerSize[0][0]); + expect(serverRequests[0].data.imp[0].video.h).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].mediaTypes.video.playerSize[0][1]); + expect(serverRequests[0].data.imp[0].video.minduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].params.video.minDuration); + expect(serverRequests[0].data.imp[0].video.maxduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].params.video.maxDuration); + expect(serverRequests[0].data.imp[0].video.protocols).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].params.video.protocols); + }); + + it('should return a server request with one impression when given a valid pre-roll instream ad unit', function () { + const adUnit = utils.deepClone(examples.adUnit_video_instream); + adUnit.params.video.instreamContext = 'pre-roll'; + + const adUnits = [adUnit]; + + const serverRequests = spec.buildRequests(adUnits, examples.adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); + + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp).to.exist.and.to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data.imp[0]).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp[0].id).to.exist.and.to.be.a('string').and.to.equal(`${adUnits[0].bidId}_0`); + expect(serverRequests[0].data.imp[0].video).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp[0].video.mimes).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].params.video.mimes); + expect(serverRequests[0].data.imp[0].video.startdelay).to.exist.and.to.be.a('number').and.to.equal(0); + expect(serverRequests[0].data.imp[0].video.w).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].mediaTypes.video.playerSize[0][0]); + expect(serverRequests[0].data.imp[0].video.h).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].mediaTypes.video.playerSize[0][1]); + expect(serverRequests[0].data.imp[0].video.minduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].params.video.minDuration); + expect(serverRequests[0].data.imp[0].video.maxduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].params.video.maxDuration); + expect(serverRequests[0].data.imp[0].video.protocols).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].params.video.protocols); + }); + + it('should return a server request with one impression when given a valid mid-roll instream ad unit', function () { + const adUnit = utils.deepClone(examples.adUnit_video_instream); + adUnit.params.video.instreamContext = 'mid-roll'; + + const adUnits = [adUnit]; + + const serverRequests = spec.buildRequests(adUnits, examples.adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); + + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp).to.exist.and.to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data.imp[0]).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp[0].id).to.exist.and.to.be.a('string').and.to.equal(`${adUnits[0].bidId}_0`); + expect(serverRequests[0].data.imp[0].video).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp[0].video.mimes).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].params.video.mimes); + expect(serverRequests[0].data.imp[0].video.startdelay).to.exist.and.to.be.a('number').and.to.equal(-1); + expect(serverRequests[0].data.imp[0].video.w).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].mediaTypes.video.playerSize[0][0]); + expect(serverRequests[0].data.imp[0].video.h).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].mediaTypes.video.playerSize[0][1]); + expect(serverRequests[0].data.imp[0].video.minduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].params.video.minDuration); + expect(serverRequests[0].data.imp[0].video.maxduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].params.video.maxDuration); + expect(serverRequests[0].data.imp[0].video.protocols).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].params.video.protocols); + }); + + it('should return a server request with one impression when given a valid post-roll instream ad unit', function () { + const adUnit = utils.deepClone(examples.adUnit_video_instream); + adUnit.params.video.instreamContext = 'post-roll'; + + const adUnits = [adUnit]; + + const serverRequests = spec.buildRequests(adUnits, examples.adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); + + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp).to.exist.and.to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data.imp[0]).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp[0].id).to.exist.and.to.be.a('string').and.to.equal(`${adUnits[0].bidId}_0`); + expect(serverRequests[0].data.imp[0].video).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp[0].video.mimes).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].params.video.mimes); + expect(serverRequests[0].data.imp[0].video.startdelay).to.exist.and.to.be.a('number').and.to.equal(-2); + expect(serverRequests[0].data.imp[0].video.w).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].mediaTypes.video.playerSize[0][0]); + expect(serverRequests[0].data.imp[0].video.h).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].mediaTypes.video.playerSize[0][1]); + expect(serverRequests[0].data.imp[0].video.minduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].params.video.minDuration); + expect(serverRequests[0].data.imp[0].video.maxduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].params.video.maxDuration); + expect(serverRequests[0].data.imp[0].video.protocols).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].params.video.protocols); + }); + + it('should return a server request with one impression when given a valid ad unit without player size', function () { + const adUnit = utils.deepClone(examples.adUnit_video_outstream); + adUnit.mediaTypes.video.playerSize = undefined; + + const adUnits = [adUnit]; + + const serverRequests = spec.buildRequests(adUnits, examples.adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); + + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp).to.exist.and.to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data.imp[0]).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp[0].id).to.exist.and.to.be.a('string').and.to.equal(`${adUnits[0].bidId}_0`); + expect(serverRequests[0].data.imp[0].video).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp[0].video.mimes).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].params.video.mimes); + expect(serverRequests[0].data.imp[0].video.startdelay).to.equal(null); + expect(serverRequests[0].data.imp[0].video.w).to.equal(null); + expect(serverRequests[0].data.imp[0].video.h).to.equal(null); + expect(serverRequests[0].data.imp[0].video.minduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].params.video.minDuration); + expect(serverRequests[0].data.imp[0].video.maxduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].params.video.maxDuration); + expect(serverRequests[0].data.imp[0].video.protocols).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].params.video.protocols); + }); + + it('should return a server request with one impression when given a valid ad unit with an empty player size', function () { + const adUnit = utils.deepClone(examples.adUnit_video_outstream); + adUnit.mediaTypes.video.playerSize = []; + + const adUnits = [adUnit]; + + const serverRequests = spec.buildRequests(adUnits, examples.adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); + + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp).to.exist.and.to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data.imp[0]).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp[0].id).to.exist.and.to.be.a('string').and.to.equal(`${adUnits[0].bidId}_0`); + expect(serverRequests[0].data.imp[0].video).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp[0].video.mimes).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].params.video.mimes); + expect(serverRequests[0].data.imp[0].video.startdelay).to.equal(null); + expect(serverRequests[0].data.imp[0].video.w).to.equal(null); + expect(serverRequests[0].data.imp[0].video.h).to.equal(null); + expect(serverRequests[0].data.imp[0].video.minduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].params.video.minDuration); + expect(serverRequests[0].data.imp[0].video.maxduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].params.video.maxDuration); + expect(serverRequests[0].data.imp[0].video.protocols).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].params.video.protocols); + }); + + it('should return a server request with one impression when given a valid ad unit with multiple player sizes', function () { + const adUnit = utils.deepClone(examples.adUnit_video_outstream); + adUnit.mediaTypes.video.playerSize = [[350, 300], [400, 350]]; + + const adUnits = [adUnit]; + + const serverRequests = spec.buildRequests(adUnits, examples.adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); + + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp).to.exist.and.to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data.imp[0]).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp[0].id).to.exist.and.to.be.a('string').and.to.equal(`${adUnits[0].bidId}_0`); + expect(serverRequests[0].data.imp[0].video).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp[0].video.mimes).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].params.video.mimes); + expect(serverRequests[0].data.imp[0].video.startdelay).to.equal(null); + expect(serverRequests[0].data.imp[0].video.w).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].mediaTypes.video.playerSize[0][0]); + expect(serverRequests[0].data.imp[0].video.h).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].mediaTypes.video.playerSize[0][1]); + expect(serverRequests[0].data.imp[0].video.minduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].params.video.minDuration); + expect(serverRequests[0].data.imp[0].video.maxduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].params.video.maxDuration); + expect(serverRequests[0].data.imp[0].video.protocols).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].params.video.protocols); + }); + + it('should return a server request with one impression when given a valid ad unit without minimum duration', function () { + const adUnit = utils.deepClone(examples.adUnit_video_outstream); + adUnit.params.video.minDuration = undefined; + + const adUnits = [adUnit]; + + const serverRequests = spec.buildRequests(adUnits, examples.adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); + + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp).to.exist.and.to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data.imp[0]).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp[0].id).to.exist.and.to.be.a('string').and.to.equal(`${adUnits[0].bidId}_0`); + expect(serverRequests[0].data.imp[0].video).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp[0].video.mimes).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].params.video.mimes); + expect(serverRequests[0].data.imp[0].video.startdelay).to.equal(null); + expect(serverRequests[0].data.imp[0].video.w).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].mediaTypes.video.playerSize[0][0]); + expect(serverRequests[0].data.imp[0].video.h).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].mediaTypes.video.playerSize[0][1]); + expect(serverRequests[0].data.imp[0].video.minduration).to.equal(null); + expect(serverRequests[0].data.imp[0].video.maxduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].params.video.maxDuration); + expect(serverRequests[0].data.imp[0].video.protocols).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].params.video.protocols); + }); + + it('should return a server request with one impression when given a valid ad unit without maximum duration', function () { + const adUnit = utils.deepClone(examples.adUnit_video_outstream); + adUnit.params.video.maxDuration = undefined; + + const adUnits = [adUnit]; + + const serverRequests = spec.buildRequests(adUnits, examples.adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); + + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp).to.exist.and.to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data.imp[0]).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp[0].id).to.exist.and.to.be.a('string').and.to.equal(`${adUnits[0].bidId}_0`); + expect(serverRequests[0].data.imp[0].video).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp[0].video.mimes).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].params.video.mimes); + expect(serverRequests[0].data.imp[0].video.startdelay).to.equal(null); + expect(serverRequests[0].data.imp[0].video.w).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].mediaTypes.video.playerSize[0][0]); + expect(serverRequests[0].data.imp[0].video.h).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].mediaTypes.video.playerSize[0][1]); + expect(serverRequests[0].data.imp[0].video.minduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].params.video.minDuration); + expect(serverRequests[0].data.imp[0].video.maxduration).to.equal(null); + expect(serverRequests[0].data.imp[0].video.protocols).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].params.video.protocols); + }); + + it('should return a server request with two impressions when given two valid ad units with different impression identifiers', function () { + const adUnit_1 = utils.deepClone(examples.adUnit_video_outstream); + adUnit_1.bidId = 'bid_id_1'; + + const adUnit_2 = utils.deepClone(examples.adUnit_video_outstream); + adUnit_2.bidId = 'bid_id_2'; + + const adUnits = [adUnit_1, adUnit_2]; + + const serverRequests = spec.buildRequests(adUnits, examples.adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); + + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp).to.exist.and.to.be.an('array').and.to.have.lengthOf(2); + expect(serverRequests[0].data.imp[0]).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp[0].id).to.exist.and.to.be.a('string').and.to.equal(`${adUnits[0].bidId}_0`); + expect(serverRequests[0].data.imp[0].video).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp[0].video.mimes).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].params.video.mimes); + expect(serverRequests[0].data.imp[0].video.startdelay).to.equal(null); + expect(serverRequests[0].data.imp[0].video.w).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].mediaTypes.video.playerSize[0][0]); + expect(serverRequests[0].data.imp[0].video.h).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].mediaTypes.video.playerSize[0][1]); + expect(serverRequests[0].data.imp[0].video.minduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].params.video.minDuration); + expect(serverRequests[0].data.imp[0].video.maxduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].params.video.maxDuration); + expect(serverRequests[0].data.imp[0].video.protocols).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].params.video.protocols); + expect(serverRequests[0].data.imp[1]).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp[1].id).to.exist.and.to.be.a('string').and.to.equal(`${adUnits[1].bidId}_0`); + expect(serverRequests[0].data.imp[1].video).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp[1].video.mimes).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].params.video.mimes); + expect(serverRequests[0].data.imp[1].video.startdelay).to.equal(null); + expect(serverRequests[0].data.imp[1].video.w).to.exist.and.to.be.a('number').and.to.equal(adUnits[1].mediaTypes.video.playerSize[0][0]); + expect(serverRequests[0].data.imp[1].video.h).to.exist.and.to.be.a('number').and.to.equal(adUnits[1].mediaTypes.video.playerSize[0][1]); + expect(serverRequests[0].data.imp[1].video.minduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[1].params.video.minDuration); + expect(serverRequests[0].data.imp[1].video.maxduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[1].params.video.maxDuration); + expect(serverRequests[0].data.imp[1].video.protocols).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[1].params.video.protocols); + }); + + it('should return a server request with one overridden impression when given two valid ad units with identical identifiers', function () { + const adUnit_1 = utils.deepClone(examples.adUnit_video_outstream); + adUnit_1.params.video.minDuration = 10; + + const adUnit_2 = utils.deepClone(examples.adUnit_video_outstream); + adUnit_2.params.video.minDuration = 15; + + const adUnits = [adUnit_1, adUnit_2]; + + const serverRequests = spec.buildRequests(adUnits, examples.adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); + + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp).to.exist.and.to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data.imp[0]).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp[0].id).to.exist.and.to.be.a('string').and.to.equal(`${adUnits[1].bidId}_0`); + expect(serverRequests[0].data.imp[0].video).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp[0].video.mimes).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].params.video.mimes); + expect(serverRequests[0].data.imp[0].video.startdelay).to.equal(null); + expect(serverRequests[0].data.imp[0].video.w).to.exist.and.to.be.a('number').and.to.equal(adUnits[1].mediaTypes.video.playerSize[0][0]); + expect(serverRequests[0].data.imp[0].video.h).to.exist.and.to.be.a('number').and.to.equal(adUnits[1].mediaTypes.video.playerSize[0][1]); + expect(serverRequests[0].data.imp[0].video.minduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[1].params.video.minDuration); + expect(serverRequests[0].data.imp[0].video.maxduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[1].params.video.maxDuration); + expect(serverRequests[0].data.imp[0].video.protocols).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[1].params.video.protocols); + }); + + it('should return two server requests with one impression when given two valid ad units with different bid request identifiers', function () { + const adUnit_1 = utils.deepClone(examples.adUnit_video_outstream); + adUnit_1.bidderRequestId = 'bidder_request_id_1'; + + const adUnit_2 = utils.deepClone(examples.adUnit_video_outstream); + adUnit_2.bidderRequestId = 'bidder_request_id_2'; + + const adUnits = [adUnit_1, adUnit_2]; + + const serverRequests = spec.buildRequests(adUnits, examples.adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(2); + + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp).to.exist.and.to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data.imp[0]).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp[0].id).to.exist.and.to.be.a('string').and.to.equal(`${adUnits[0].bidId}_0`); + expect(serverRequests[0].data.imp[0].video).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp[0].video.mimes).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].params.video.mimes); + expect(serverRequests[0].data.imp[0].video.startdelay).to.equal(null); + expect(serverRequests[0].data.imp[0].video.w).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].mediaTypes.video.playerSize[0][0]); + expect(serverRequests[0].data.imp[0].video.h).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].mediaTypes.video.playerSize[0][1]); + expect(serverRequests[0].data.imp[0].video.minduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].params.video.minDuration); + expect(serverRequests[0].data.imp[0].video.maxduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].params.video.maxDuration); + expect(serverRequests[0].data.imp[0].video.protocols).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].params.video.protocols); + expect(serverRequests[1].data).to.exist.and.to.be.an('object'); + expect(serverRequests[1].data.imp).to.exist.and.to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[1].data.imp[0]).to.exist.and.to.be.an('object'); + expect(serverRequests[1].data.imp[0].id).to.exist.and.to.be.a('string').and.to.equal(`${adUnits[1].bidId}_0`); + expect(serverRequests[1].data.imp[0].video).to.exist.and.to.be.an('object'); + expect(serverRequests[1].data.imp[0].video.mimes).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].params.video.mimes); + expect(serverRequests[1].data.imp[0].video.startdelay).to.equal(null); + expect(serverRequests[1].data.imp[0].video.w).to.exist.and.to.be.a('number').and.to.equal(adUnits[1].mediaTypes.video.playerSize[0][0]); + expect(serverRequests[1].data.imp[0].video.h).to.exist.and.to.be.a('number').and.to.equal(adUnits[1].mediaTypes.video.playerSize[0][1]); + expect(serverRequests[1].data.imp[0].video.minduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[1].params.video.minDuration); + expect(serverRequests[1].data.imp[0].video.maxduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[1].params.video.maxDuration); + expect(serverRequests[1].data.imp[0].video.protocols).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[1].params.video.protocols); + }); + }); + + describe('Native', function () { + it('should return a server request with one impression when given a valid ad unit', function () { + const adUnits = [examples.adUnit_native]; + + const serverRequests = spec.buildRequests(adUnits, examples.adUnit_native); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); + + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp).to.exist.and.to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data.imp[0]).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp[0].id).to.exist.and.to.be.a('string').and.to.equal(`${adUnits[0].bidId}_0`); + expect(serverRequests[0].data.imp[0].native).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.imp[0].native.request).to.exist.and.to.be.a('string').and.to.equal(JSON.stringify(examples.serverRequest_native.data.imp[0].native.request)) + }); + }); + }); + + describe('Site', function () { + it('should return a server request with site information when given a valid ad unit and a valid ad unit context', function () { + const adUnits = [examples.adUnit_banner]; + + const adUnitContext = examples.adUnitContext; + + const serverRequests = spec.buildRequests(adUnits, adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.id).to.exist.and.to.be.an('string').and.to.equal(adUnits[0].bidderRequestId); + expect(serverRequests[0].data.site).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.site.page).to.exist.and.to.be.an('string').and.to.equal(adUnitContext.refererInfo.referer); + expect(serverRequests[0].data.site.id).to.equal(undefined); + expect(serverRequests[0].data.site.domain).to.exist.and.to.be.an('string').and.to.equal('we-are-adot.com'); + expect(serverRequests[0].data.site.name).to.exist.and.to.be.an('string').and.to.equal('we-are-adot.com'); + }); + + it('should return a server request without site information when not given an ad unit context', function () { + const adUnits = [examples.adUnit_banner]; + + const adUnitContext = undefined; + + const serverRequests = spec.buildRequests(adUnits, adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.id).to.exist.and.to.be.an('string').and.to.equal(adUnits[0].bidderRequestId); + expect(serverRequests[0].data.site).to.equal(null); + }); + + it('should return a server request without site information when given an ad unit context without referer information', function () { + const adUnits = [examples.adUnit_banner]; + + const adUnitContext = utils.deepClone(examples.adUnitContext); + adUnitContext.refererInfo = undefined; + + const serverRequests = spec.buildRequests(adUnits, adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.id).to.exist.and.to.be.an('string').and.to.equal(adUnits[0].bidderRequestId); + expect(serverRequests[0].data.site).to.equal(null); + }); + + it('should return a server request without site information when given an ad unit context with invalid referer information', function () { + const adUnits = [examples.adUnit_banner]; + + const adUnitContext = utils.deepClone(examples.adUnitContext); + adUnitContext.refererInfo = 'bad_referer_information'; + + const serverRequests = spec.buildRequests(adUnits, adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.id).to.exist.and.to.be.an('string').and.to.equal(adUnits[0].bidderRequestId); + expect(serverRequests[0].data.site).to.equal(null); + }); + + it('should return a server request without site information when given an ad unit context without referer', function () { + const adUnits = [examples.adUnit_banner]; + + const adUnitContext = utils.deepClone(examples.adUnitContext); + adUnitContext.refererInfo.referer = undefined; + + const serverRequests = spec.buildRequests(adUnits, adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.id).to.exist.and.to.be.an('string').and.to.equal(adUnits[0].bidderRequestId); + expect(serverRequests[0].data.site).to.equal(null); + }); + + it('should return a server request without site information when given an ad unit context with an invalid referer', function () { + const adUnits = [examples.adUnit_banner]; + + const adUnitContext = utils.deepClone(examples.adUnitContext); + adUnitContext.refererInfo.referer = {}; + + const serverRequests = spec.buildRequests(adUnits, adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.id).to.exist.and.to.be.an('string').and.to.equal(adUnits[0].bidderRequestId); + expect(serverRequests[0].data.site).to.equal(null); + }); + + it('should return a server request without site information when given an ad unit context with a misformatted referer', function () { + const adUnits = [examples.adUnit_banner]; + + const adUnitContext = utils.deepClone(examples.adUnitContext); + adUnitContext.refererInfo.referer = 'we-are-adot'; + + const serverRequests = spec.buildRequests(adUnits, adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.id).to.exist.and.to.be.an('string').and.to.equal(adUnits[0].bidderRequestId); + expect(serverRequests[0].data.site).to.equal(null); + }); + }); + + describe('Device', function () { + it('should return a server request with device information when given a valid ad unit and a valid ad unit context', function () { + const adUnits = [examples.adUnit_banner]; + + const serverRequests = spec.buildRequests(adUnits, examples.adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.id).to.exist.and.to.be.an('string').and.to.equal(adUnits[0].bidderRequestId); + expect(serverRequests[0].data.device).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.device.ua).to.exist.and.to.be.a('string'); + expect(serverRequests[0].data.device.language).to.exist.and.to.be.a('string'); + }); + }); + + describe('Regs', function () { + it('should return a server request with regulations information when given a valid ad unit and a valid ad unit context with GDPR applying', function () { + const adUnits = [examples.adUnit_banner]; + + const adUnitContext = examples.adUnitContext; + + const serverRequests = spec.buildRequests(adUnits, adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.id).to.exist.and.to.be.an('string').and.to.equal(adUnits[0].bidderRequestId); + expect(serverRequests[0].data.regs).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.regs.ext).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.regs.ext.gdpr).to.exist.and.to.be.a('boolean').and.to.equal(adUnitContext.gdprConsent.gdprApplies); + }); + + it('should return a server request with regulations information when given a valid ad unit and a valid ad unit context with GDPR not applying', function () { + const adUnits = [examples.adUnit_banner]; + + const adUnitContext = utils.deepClone(examples.adUnitContext); + adUnitContext.gdprConsent.gdprApplies = false; + + const serverRequests = spec.buildRequests(adUnits, adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.id).to.exist.and.to.be.an('string').and.to.equal(adUnits[0].bidderRequestId); + expect(serverRequests[0].data.regs).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.regs.ext).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.regs.ext.gdpr).to.exist.and.to.be.a('boolean').and.to.equal(adUnitContext.gdprConsent.gdprApplies); + }); + + it('should return a server request without regulations information when not given an ad unit context', function () { + const adUnits = [examples.adUnit_banner]; + + const adUnitContext = undefined; + + const serverRequests = spec.buildRequests(adUnits, adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.id).to.exist.and.to.be.an('string').and.to.equal(adUnits[0].bidderRequestId); + expect(serverRequests[0].data.regs).to.equal(null); + }); + + it('should return a server request without regulations information when given an ad unit context without GDPR information', function () { + const adUnits = [examples.adUnit_banner]; + + const adUnitContext = utils.deepClone(examples.adUnitContext); + adUnitContext.gdprConsent = undefined; + + const serverRequests = spec.buildRequests(adUnits, adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.id).to.exist.and.to.be.an('string').and.to.equal(adUnits[0].bidderRequestId); + expect(serverRequests[0].data.regs).to.equal(null); + }); + + it('should return a server request without regulations information when given an ad unit context with invalid GDPR information', function () { + const adUnits = [examples.adUnit_banner]; + + const adUnitContext = utils.deepClone(examples.adUnitContext); + adUnitContext.gdprConsent = 'bad_gdpr_consent'; + + const serverRequests = spec.buildRequests(adUnits, adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.id).to.exist.and.to.be.an('string').and.to.equal(adUnits[0].bidderRequestId); + expect(serverRequests[0].data.regs).to.equal(null); + }); + + it('should return a server request without regulations information when given an ad unit context with invalid GDPR application information', function () { + const adUnits = [examples.adUnit_banner]; + + const adUnitContext = utils.deepClone(examples.adUnitContext); + adUnitContext.gdprConsent.gdprApplies = 'bad_gdpr_applies'; + + const serverRequests = spec.buildRequests(adUnits, adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.id).to.exist.and.to.be.an('string').and.to.equal(adUnits[0].bidderRequestId); + expect(serverRequests[0].data.regs).to.equal(null); + }); + }); + + describe('User', function () { + it('should return a server request with user information when given a valid ad unit and a valid ad unit context', function () { + const adUnits = [examples.adUnit_banner]; + + const adUnitContext = examples.adUnitContext; + + const serverRequests = spec.buildRequests(adUnits, adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.id).to.exist.and.to.be.an('string').and.to.equal(adUnits[0].bidderRequestId); + expect(serverRequests[0].data.user).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.user.ext).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.user.ext.consent).to.exist.and.to.be.a('string').and.to.equal(adUnitContext.gdprConsent.consentString); + }); + + it('should return a server request without user information when not given an ad unit context', function () { + const adUnits = [examples.adUnit_banner]; + + const adUnitContext = undefined; + + const serverRequests = spec.buildRequests(adUnits, adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.id).to.exist.and.to.be.an('string').and.to.equal(adUnits[0].bidderRequestId); + expect(serverRequests[0].data.user).to.equal(null); + }); + + it('should return a server request without user information when given an ad unit context without GDPR information', function () { + const adUnits = [examples.adUnit_banner]; + + const adUnitContext = utils.deepClone(examples.adUnitContext); + adUnitContext.gdprConsent = undefined; + + const serverRequests = spec.buildRequests(adUnits, adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.id).to.exist.and.to.be.an('string').and.to.equal(adUnits[0].bidderRequestId); + expect(serverRequests[0].data.user).to.equal(null); + }); + + it('should return a server request without user information when given an ad unit context with invalid GDPR information', function () { + const adUnits = [examples.adUnit_banner]; + + const adUnitContext = utils.deepClone(examples.adUnitContext); + adUnitContext.gdprConsent = 'bad_gdpr_consent'; + + const serverRequests = spec.buildRequests(adUnits, adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.id).to.exist.and.to.be.an('string').and.to.equal(adUnits[0].bidderRequestId); + expect(serverRequests[0].data.user).to.equal(null); + }); + + it('should return a server request without user information when given an ad unit context with an invalid consent string', function () { + const adUnits = [examples.adUnit_banner]; + + const adUnitContext = utils.deepClone(examples.adUnitContext); + adUnitContext.gdprConsent.consentString = true; + + const serverRequests = spec.buildRequests(adUnits, adUnitContext); + + expect(serverRequests).to.be.an('array').and.to.have.lengthOf(1); + expect(serverRequests[0].data).to.exist.and.to.be.an('object'); + expect(serverRequests[0].data.id).to.exist.and.to.be.an('string').and.to.equal(adUnits[0].bidderRequestId); + expect(serverRequests[0].data.user).to.equal(null); + }); + }); + }); + + describe('interpretResponse', function () { + describe('General', function () { + it('should return an ad when given a valid server response with one bid with USD currency', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.cur = 'USD'; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(1); + expect(ads[0].requestId).to.exist.and.to.be.a('string').and.to.equal(serverRequest._adot_internal.impressions[0].bidId); + expect(ads[0].ad).to.exist.and.to.be.a('string').and.to.have.string(serverResponse.body.seatbid[0].bid[0].adm); + expect(ads[0].adUrl).to.equal(null); + expect(ads[0].vastXml).to.equal(null); + expect(ads[0].vastUrl).to.equal(null); + expect(ads[0].creativeId).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.seatbid[0].bid[0].crid); + expect(ads[0].cpm).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].price); + expect(ads[0].currency).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.cur); + expect(ads[0].netRevenue).to.exist.and.to.be.a('boolean').and.to.equal(true); + expect(ads[0].ttl).to.exist.and.to.be.a('number').and.to.equal(10); + expect(ads[0].height).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].h); + expect(ads[0].width).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].w); + expect(ads[0].mediaType).to.exist.and.to.be.a('string').and.to.equal('banner'); + expect(ads[0].renderer).to.equal(null); + }); + + it('should return two ads when given a valid server response with two bids', function () { + const serverRequest = examples.serverRequest_banner_twoImps; + + const serverResponse = examples.serverResponse_banner_twoBids; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(2); + + expect(ads[0].requestId).to.exist.and.to.be.a('string').and.to.equal(serverRequest._adot_internal.impressions[0].bidId); + expect(ads[0].ad).to.exist.and.to.be.a('string').and.to.have.string(serverResponse.body.seatbid[0].bid[0].adm); + expect(ads[0].adUrl).to.equal(null); + expect(ads[0].vastXml).to.equal(null); + expect(ads[0].vastUrl).to.equal(null); + expect(ads[0].creativeId).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.seatbid[0].bid[0].crid); + expect(ads[0].cpm).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].price); + expect(ads[0].currency).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.cur); + expect(ads[0].netRevenue).to.exist.and.to.be.a('boolean').and.to.equal(true); + expect(ads[0].ttl).to.exist.and.to.be.a('number').and.to.equal(10); + expect(ads[0].height).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].h); + expect(ads[0].width).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].w); + expect(ads[0].mediaType).to.exist.and.to.be.a('string').and.to.equal('banner'); + expect(ads[0].renderer).to.equal(null); + expect(ads[1].requestId).to.exist.and.to.be.a('string').and.to.equal(serverRequest._adot_internal.impressions[1].bidId); + expect(ads[1].ad).to.exist.and.to.be.a('string').and.to.have.string(serverResponse.body.seatbid[0].bid[1].adm); + expect(ads[1].adUrl).to.equal(null); + expect(ads[1].creativeId).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.seatbid[0].bid[1].crid); + expect(ads[1].cpm).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[1].price); + expect(ads[1].currency).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.cur); + expect(ads[1].netRevenue).to.exist.and.to.be.a('boolean').and.to.equal(true); + expect(ads[1].ttl).to.exist.and.to.be.a('number').and.to.equal(10); + expect(ads[1].height).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[1].h); + expect(ads[1].width).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[1].w); + expect(ads[1].mediaType).to.exist.and.to.be.a('string').and.to.equal('banner'); + expect(ads[1].renderer).to.equal(null); + }); + + it('should return no ad when not given a server response', function () { + const ads = spec.interpretResponse(null); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when not given a server response body', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body = undefined; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given an invalid server response body', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body = 'invalid_body'; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a server response without seat bids', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.seatbid = undefined; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a server response with invalid seat bids', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.seatbid = 'invalid_seat_bids'; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a server response with an empty seat bids array', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.seatbid = []; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a server response with an invalid seat bid', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.seatbid[0].bid = 'invalid_bids'; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a server response with an empty bids array', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.seatbid[0].bid = []; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a server response with an invalid bid', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.seatbid[0].bid = ['invalid_bid']; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a server response with a bid without currency', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.cur = undefined; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a server response with a bid with an invalid currency', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.cur = {}; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a server response with a bid without impression identifier', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.seatbid[0].bid[0].impid = undefined; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a server response with a bid with an invalid impression identifier', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.seatbid[0].bid[0].impid = {}; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a server response with a bid without creative identifier', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.seatbid[0].bid[0].crid = undefined; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a server response with a bid with an invalid creative identifier', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.seatbid[0].bid[0].crid = {}; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a server response with a bid without ad markup and ad serving URL', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.seatbid[0].bid[0].adm = undefined; + serverResponse.body.seatbid[0].bid[0].nurl = undefined; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a server response with a bid with an invalid ad markup', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.seatbid[0].bid[0].adm = {}; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a server response with a bid with an ad markup without auction price macro', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.seatbid[0].bid[0].adm = 'creative_data'; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a server response with a bid with an invalid ad serving URL', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.seatbid[0].bid[0].nurl = {}; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a server response with a bid with an ad serving URL without auction price macro', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.seatbid[0].bid[0].nurl = 'win_notice_url'; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a server response with a bid without bid price', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.seatbid[0].bid[0].price = undefined; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a server response with a bid with an invalid bid price', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.seatbid[0].bid[0].price = {}; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a server response with a bid without extension', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.seatbid[0].bid[0].ext = undefined; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a server response with a bid with an invalid extension', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.seatbid[0].bid[0].ext = 'bad_ext'; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a server response with a bid without adot extension', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.seatbid[0].bid[0].ext.adot = undefined; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a server response with a bid with an invalid adot extension', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.seatbid[0].bid[0].ext.adot = 'bad_adot_ext'; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a server response with a bid without media type', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.seatbid[0].bid[0].ext.adot.media_type = undefined; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a server response with a bid with an invalid media type', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.seatbid[0].bid[0].ext.adot.media_type = {}; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a server response with a bid with an unknown media type', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.seatbid[0].bid[0].ext.adot.media_type = 'unknown_media_type'; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a valid server response and no server request', function () { + const serverRequest = undefined; + + const serverResponse = examples.serverResponse_banner; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a valid server response and an invalid server request', function () { + const serverRequest = 'bad_server_request'; + + const serverResponse = examples.serverResponse_banner; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a valid server response and a server request without bid request', function () { + const serverRequest = utils.deepClone(examples.serverRequest_banner); + serverRequest.data = undefined; + + const serverResponse = examples.serverResponse_banner; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a valid server response and a server request with an invalid bid request', function () { + const serverRequest = utils.deepClone(examples.serverRequest_banner); + serverRequest.data = 'bad_bid_request'; + + const serverResponse = examples.serverResponse_banner; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a valid server response and a server request without impression', function () { + const serverRequest = utils.deepClone(examples.serverRequest_banner); + serverRequest.data.imp = undefined; + + const serverResponse = examples.serverResponse_banner; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a valid server response and a server request with an invalid impression field', function () { + const serverRequest = utils.deepClone(examples.serverRequest_banner); + serverRequest.data.imp = 'invalid_impressions'; + + const serverResponse = examples.serverResponse_banner; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a valid server response and a server request without matching impression', function () { + const serverRequest = utils.deepClone(examples.serverRequest_banner); + serverRequest.data.imp[0].id = 'unknown_imp_id'; + + const serverResponse = examples.serverResponse_banner; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a valid server response and a server request without internal data', function () { + const serverRequest = utils.deepClone(examples.serverRequest_banner); + serverRequest._adot_internal = undefined; + + const serverResponse = examples.serverResponse_banner; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a valid server response and a server request with invalid internal data', function () { + const serverRequest = utils.deepClone(examples.serverRequest_banner); + serverRequest._adot_internal = 'bad_internal_data'; + + const serverResponse = examples.serverResponse_banner; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a valid server response and a server request without internal impression data', function () { + const serverRequest = utils.deepClone(examples.serverRequest_banner); + serverRequest._adot_internal.impressions = undefined; + + const serverResponse = examples.serverResponse_banner; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a valid server response and a server request with invalid internal impression data', function () { + const serverRequest = utils.deepClone(examples.serverRequest_banner); + serverRequest._adot_internal.impressions = 'bad_internal_impression_data'; + + const serverResponse = examples.serverResponse_banner; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a valid server response and a server request without matching internal impression', function () { + const serverRequest = utils.deepClone(examples.serverRequest_banner); + serverRequest._adot_internal.impressions[0].impressionId = 'unknown_imp_id'; + + const serverResponse = examples.serverResponse_banner; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a valid server response and a server request without internal impression ad unit code', function () { + const serverRequest = utils.deepClone(examples.serverRequest_banner); + serverRequest._adot_internal.impressions[0].adUnitCode = undefined; + + const serverResponse = examples.serverResponse_banner; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a valid server response and a server request with an invalid internal impression ad unit code', function () { + const serverRequest = utils.deepClone(examples.serverRequest_banner); + serverRequest._adot_internal.impressions[0].adUnitCode = {}; + + const serverResponse = examples.serverResponse_banner; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + }); + + describe('Banner', function () { + it('should return an ad when given a valid server response with one bid', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = examples.serverResponse_banner; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(1); + expect(ads[0].requestId).to.exist.and.to.be.a('string').and.to.equal(serverRequest._adot_internal.impressions[0].bidId); + expect(ads[0].ad).to.exist.and.to.be.a('string').and.to.have.string(serverResponse.body.seatbid[0].bid[0].adm); + expect(ads[0].adUrl).to.equal(null); + expect(ads[0].vastXml).to.equal(null); + expect(ads[0].vastUrl).to.equal(null); + expect(ads[0].creativeId).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.seatbid[0].bid[0].crid); + expect(ads[0].cpm).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].price); + expect(ads[0].currency).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.cur); + expect(ads[0].netRevenue).to.exist.and.to.be.a('boolean').and.to.equal(true); + expect(ads[0].ttl).to.exist.and.to.be.a('number').and.to.equal(10); + expect(ads[0].height).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].h); + expect(ads[0].width).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].w); + expect(ads[0].mediaType).to.exist.and.to.be.a('string').and.to.equal('banner'); + expect(ads[0].renderer).to.equal(null); + }); + + it('should return an ad when given a valid server response with one bid without a win notice URL', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.seatbid[0].bid[0].nurl = undefined; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(1); + expect(ads[0].requestId).to.exist.and.to.be.a('string').and.to.equal(serverRequest._adot_internal.impressions[0].bidId); + expect(ads[0].ad).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.seatbid[0].bid[0].adm); + expect(ads[0].adUrl).to.equal(null); + expect(ads[0].vastXml).to.equal(null); + expect(ads[0].vastUrl).to.equal(null); + expect(ads[0].creativeId).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.seatbid[0].bid[0].crid); + expect(ads[0].cpm).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].price); + expect(ads[0].currency).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.cur); + expect(ads[0].netRevenue).to.exist.and.to.be.a('boolean').and.to.equal(true); + expect(ads[0].ttl).to.exist.and.to.be.a('number').and.to.equal(10); + expect(ads[0].height).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].h); + expect(ads[0].width).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].w); + expect(ads[0].mediaType).to.exist.and.to.be.a('string').and.to.equal('banner'); + expect(ads[0].renderer).to.equal(null); + }); + + it('should return an ad when given a valid server response with one bid using an ad serving URL', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.seatbid[0].bid[0].adm = undefined; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(1); + expect(ads[0].requestId).to.exist.and.to.be.a('string').and.to.equal(serverRequest._adot_internal.impressions[0].bidId); + expect(ads[0].ad).to.equal(null); + expect(ads[0].adUrl).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.seatbid[0].bid[0].nurl); + expect(ads[0].creativeId).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.seatbid[0].bid[0].crid); + expect(ads[0].cpm).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].price); + expect(ads[0].currency).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.cur); + expect(ads[0].netRevenue).to.exist.and.to.be.a('boolean').and.to.equal(true); + expect(ads[0].ttl).to.exist.and.to.be.a('number').and.to.equal(10); + expect(ads[0].height).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].h); + expect(ads[0].width).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].w); + expect(ads[0].mediaType).to.exist.and.to.be.a('string').and.to.equal('banner'); + expect(ads[0].renderer).to.equal(null); + }); + + it('should return no ad when given a server response with a bid without height', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.seatbid[0].bid[0].h = undefined; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a server response with a bid with an invalid height', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.seatbid[0].bid[0].h = {}; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a server response with a bid without width', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.seatbid[0].bid[0].w = undefined; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a server response with a bid with an invalid width', function () { + const serverRequest = examples.serverRequest_banner; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + serverResponse.body.seatbid[0].bid[0].w = {}; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a valid server response and a server request without banner impression', function () { + const serverRequest = utils.deepClone(examples.serverRequest_banner); + serverRequest.data.imp[0].banner = undefined; + + const serverResponse = utils.deepClone(examples.serverResponse_banner); + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + }); + + describe('Video', function () { + it('should return an ad when given a valid server response with one bid on an instream impression', function () { + const serverRequest = examples.serverRequest_video_instream; + + const serverResponse = examples.serverResponse_video_instream; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(1); + expect(ads[0].requestId).to.exist.and.to.be.a('string').and.to.equal(serverRequest._adot_internal.impressions[0].bidId); + expect(ads[0].ad).to.exist.and.to.be.a('string').and.to.have.string(serverResponse.body.seatbid[0].bid[0].adm); + expect(ads[0].adUrl).to.equal(null); + expect(ads[0].vastXml).to.equal(serverResponse.body.seatbid[0].bid[0].adm); + expect(ads[0].vastUrl).to.equal(null); + expect(ads[0].creativeId).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.seatbid[0].bid[0].crid); + expect(ads[0].cpm).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].price); + expect(ads[0].currency).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.cur); + expect(ads[0].netRevenue).to.exist.and.to.be.a('boolean').and.to.equal(true); + expect(ads[0].ttl).to.exist.and.to.be.a('number').and.to.equal(10); + expect(ads[0].height).to.equal(serverRequest.data.imp[0].video.h); + expect(ads[0].width).to.equal(serverRequest.data.imp[0].video.w); + expect(ads[0].mediaType).to.exist.and.to.be.a('string').and.to.equal('video'); + expect(ads[0].renderer).to.equal(null); + }); + + it('should return an ad when given a valid server response with one bid on an outstream impression', function () { + const serverRequest = examples.serverRequest_video_outstream; + + const serverResponse = examples.serverResponse_video_outstream; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(1); + expect(ads[0].requestId).to.exist.and.to.be.a('string').and.to.equal(serverRequest._adot_internal.impressions[0].bidId); + expect(ads[0].ad).to.exist.and.to.be.a('string').and.to.have.string(serverResponse.body.seatbid[0].bid[0].adm); + expect(ads[0].adUrl).to.equal(null); + expect(ads[0].vastXml).to.equal(serverResponse.body.seatbid[0].bid[0].adm); + expect(ads[0].vastUrl).to.equal(null); + expect(ads[0].creativeId).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.seatbid[0].bid[0].crid); + expect(ads[0].cpm).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].price); + expect(ads[0].currency).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.cur); + expect(ads[0].netRevenue).to.exist.and.to.be.a('boolean').and.to.equal(true); + expect(ads[0].ttl).to.exist.and.to.be.a('number').and.to.equal(10); + expect(ads[0].height).to.equal(serverRequest.data.imp[0].video.h); + expect(ads[0].width).to.equal(serverRequest.data.imp[0].video.w); + expect(ads[0].mediaType).to.exist.and.to.be.a('string').and.to.equal('video'); + expect(ads[0].renderer).to.be.an('object'); + }); + + it('should return two ads when given a valid server response with two bids on both instream and outstream impressions', function () { + const serverRequest = examples.serverRequest_video_instream_outstream; + + const serverResponse = examples.serverResponse_video_instream_outstream; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(2); + expect(ads[0].requestId).to.exist.and.to.be.a('string').and.to.equal(serverRequest._adot_internal.impressions[0].bidId); + expect(ads[0].ad).to.exist.and.to.be.a('string').and.to.have.string(serverResponse.body.seatbid[0].bid[0].adm); + expect(ads[0].adUrl).to.equal(null); + expect(ads[0].vastXml).to.equal(serverResponse.body.seatbid[0].bid[0].adm); + expect(ads[0].vastUrl).to.equal(null); + expect(ads[0].creativeId).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.seatbid[0].bid[0].crid); + expect(ads[0].cpm).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].price); + expect(ads[0].currency).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.cur); + expect(ads[0].netRevenue).to.exist.and.to.be.a('boolean').and.to.equal(true); + expect(ads[0].ttl).to.exist.and.to.be.a('number').and.to.equal(10); + expect(ads[0].height).to.equal(serverRequest.data.imp[0].video.h); + expect(ads[0].width).to.equal(serverRequest.data.imp[0].video.w); + expect(ads[0].mediaType).to.exist.and.to.be.a('string').and.to.equal('video'); + expect(ads[0].renderer).to.equal(null); + expect(ads[1].requestId).to.exist.and.to.be.a('string').and.to.equal(serverRequest._adot_internal.impressions[1].bidId); + expect(ads[1].ad).to.exist.and.to.be.a('string').and.to.have.string(serverResponse.body.seatbid[0].bid[1].adm); + expect(ads[1].adUrl).to.equal(null); + expect(ads[1].vastXml).to.equal(serverResponse.body.seatbid[0].bid[0].adm); + expect(ads[1].vastUrl).to.equal(null); + expect(ads[1].creativeId).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.seatbid[0].bid[1].crid); + expect(ads[1].cpm).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[1].price); + expect(ads[1].currency).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.cur); + expect(ads[1].netRevenue).to.exist.and.to.be.a('boolean').and.to.equal(true); + expect(ads[1].ttl).to.exist.and.to.be.a('number').and.to.equal(10); + expect(ads[0].height).to.equal(serverRequest.data.imp[1].video.h); + expect(ads[0].width).to.equal(serverRequest.data.imp[1].video.w); + expect(ads[1].mediaType).to.exist.and.to.be.a('string').and.to.equal('video'); + expect(ads[1].renderer).to.be.an('object'); + }); + + it('should return an ad when given a valid server response with one bid without a win notice URL', function () { + const serverRequest = examples.serverRequest_video_instream; + + const serverResponse = utils.deepClone(examples.serverResponse_video_instream); + serverResponse.body.seatbid[0].bid[0].nurl = undefined; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(1); + expect(ads[0].requestId).to.exist.and.to.be.a('string').and.to.equal(serverRequest._adot_internal.impressions[0].bidId); + expect(ads[0].ad).to.exist.and.to.be.a('string').and.to.have.string(serverResponse.body.seatbid[0].bid[0].adm); + expect(ads[0].adUrl).to.equal(null); + expect(ads[0].vastXml).to.equal(serverResponse.body.seatbid[0].bid[0].adm); + expect(ads[0].vastUrl).to.equal(null); + expect(ads[0].creativeId).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.seatbid[0].bid[0].crid); + expect(ads[0].cpm).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].price); + expect(ads[0].currency).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.cur); + expect(ads[0].netRevenue).to.exist.and.to.be.a('boolean').and.to.equal(true); + expect(ads[0].ttl).to.exist.and.to.be.a('number').and.to.equal(10); + expect(ads[0].height).to.equal(serverRequest.data.imp[0].video.h); + expect(ads[0].width).to.equal(serverRequest.data.imp[0].video.w); + expect(ads[0].mediaType).to.exist.and.to.be.a('string').and.to.equal('video'); + expect(ads[0].renderer).to.equal(null); + }); + + it('should return an ad when given a valid server response with one bid using an ad serving URL', function () { + const serverRequest = examples.serverRequest_video_instream; + + const serverResponse = utils.deepClone(examples.serverResponse_video_instream); + serverResponse.body.seatbid[0].bid[0].adm = undefined; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(1); + expect(ads[0].requestId).to.exist.and.to.be.a('string').and.to.equal(serverRequest._adot_internal.impressions[0].bidId); + expect(ads[0].ad).to.equal(null); + expect(ads[0].adUrl).to.exist.and.to.be.a('string').and.to.have.string(serverResponse.body.seatbid[0].bid[0].nurl); + expect(ads[0].vastXml).to.equal(null); + expect(ads[0].vastUrl).to.equal(serverResponse.body.seatbid[0].bid[0].nurl); + expect(ads[0].creativeId).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.seatbid[0].bid[0].crid); + expect(ads[0].cpm).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].price); + expect(ads[0].currency).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.cur); + expect(ads[0].netRevenue).to.exist.and.to.be.a('boolean').and.to.equal(true); + expect(ads[0].ttl).to.exist.and.to.be.a('number').and.to.equal(10); + expect(ads[0].height).to.equal(serverRequest.data.imp[0].video.h); + expect(ads[0].width).to.equal(serverRequest.data.imp[0].video.w); + expect(ads[0].mediaType).to.exist.and.to.be.a('string').and.to.equal('video'); + expect(ads[0].renderer).to.equal(null); + }); + + it('should return an ad when given a valid server response with a bid with a video height', function () { + const serverRequest = examples.serverRequest_video_instream; + + const serverResponse = utils.deepClone(examples.serverResponse_video_instream); + serverResponse.body.seatbid[0].bid[0].h = 500; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(1); + expect(ads[0].requestId).to.exist.and.to.be.a('string').and.to.equal(serverRequest._adot_internal.impressions[0].bidId); + expect(ads[0].ad).to.exist.and.to.be.a('string').and.to.have.string(serverResponse.body.seatbid[0].bid[0].adm); + expect(ads[0].adUrl).to.equal(null); + expect(ads[0].vastXml).to.equal(serverResponse.body.seatbid[0].bid[0].adm); + expect(ads[0].vastUrl).to.equal(null); + expect(ads[0].creativeId).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.seatbid[0].bid[0].crid); + expect(ads[0].cpm).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].price); + expect(ads[0].currency).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.cur); + expect(ads[0].netRevenue).to.exist.and.to.be.a('boolean').and.to.equal(true); + expect(ads[0].ttl).to.exist.and.to.be.a('number').and.to.equal(10); + expect(ads[0].height).to.equal(serverRequest.data.imp[0].video.h); + expect(ads[0].width).to.equal(serverRequest.data.imp[0].video.w); + expect(ads[0].mediaType).to.exist.and.to.be.a('string').and.to.equal('video'); + expect(ads[0].renderer).to.equal(null); + }); + + it('should return an ad when given a valid server response with a bid with a video width', function () { + const serverRequest = examples.serverRequest_video_instream; + + const serverResponse = utils.deepClone(examples.serverResponse_video_instream); + serverResponse.body.seatbid[0].bid[0].w = 500; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(1); + expect(ads[0].requestId).to.exist.and.to.be.a('string').and.to.equal(serverRequest._adot_internal.impressions[0].bidId); + expect(ads[0].ad).to.exist.and.to.be.a('string').and.to.have.string(serverResponse.body.seatbid[0].bid[0].adm); + expect(ads[0].adUrl).to.equal(null); + expect(ads[0].vastXml).to.equal(serverResponse.body.seatbid[0].bid[0].adm); + expect(ads[0].vastUrl).to.equal(null); + expect(ads[0].creativeId).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.seatbid[0].bid[0].crid); + expect(ads[0].cpm).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].price); + expect(ads[0].currency).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.cur); + expect(ads[0].netRevenue).to.exist.and.to.be.a('boolean').and.to.equal(true); + expect(ads[0].ttl).to.exist.and.to.be.a('number').and.to.equal(10); + expect(ads[0].height).to.equal(serverRequest.data.imp[0].video.h); + expect(ads[0].width).to.equal(serverRequest.data.imp[0].video.w); + expect(ads[0].mediaType).to.exist.and.to.be.a('string').and.to.equal('video'); + expect(ads[0].renderer).to.equal(null); + }); + + it('should return an ad when given a valid server response with a bid with a video width and height', function () { + const serverRequest = examples.serverRequest_video_instream; + + const serverResponse = utils.deepClone(examples.serverResponse_video_instream); + serverResponse.body.seatbid[0].bid[0].w = 500; + serverResponse.body.seatbid[0].bid[0].h = 400; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(1); + expect(ads[0].requestId).to.exist.and.to.be.a('string').and.to.equal(serverRequest._adot_internal.impressions[0].bidId); + expect(ads[0].ad).to.exist.and.to.be.a('string').and.to.have.string(serverResponse.body.seatbid[0].bid[0].adm); + expect(ads[0].adUrl).to.equal(null); + expect(ads[0].vastXml).to.equal(serverResponse.body.seatbid[0].bid[0].adm); + expect(ads[0].vastUrl).to.equal(null); + expect(ads[0].creativeId).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.seatbid[0].bid[0].crid); + expect(ads[0].cpm).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].price); + expect(ads[0].currency).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.cur); + expect(ads[0].netRevenue).to.exist.and.to.be.a('boolean').and.to.equal(true); + expect(ads[0].ttl).to.exist.and.to.be.a('number').and.to.equal(10); + expect(ads[0].height).to.equal(serverResponse.body.seatbid[0].bid[0].h); + expect(ads[0].width).to.equal(serverResponse.body.seatbid[0].bid[0].w); + expect(ads[0].mediaType).to.exist.and.to.be.a('string').and.to.equal('video'); + expect(ads[0].renderer).to.equal(null); + }); + + it('should return an ad when given a valid server response and server request with a video impression without width', function () { + const serverRequest = utils.deepClone(examples.serverRequest_video_instream); + serverRequest.data.imp[0].video.w = null; + + const serverResponse = utils.deepClone(examples.serverResponse_video_instream); + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(1); + expect(ads[0].requestId).to.exist.and.to.be.a('string').and.to.equal(serverRequest._adot_internal.impressions[0].bidId); + expect(ads[0].ad).to.exist.and.to.be.a('string').and.to.have.string(serverResponse.body.seatbid[0].bid[0].adm); + expect(ads[0].adUrl).to.equal(null); + expect(ads[0].vastXml).to.equal(serverResponse.body.seatbid[0].bid[0].adm); + expect(ads[0].vastUrl).to.equal(null); + expect(ads[0].creativeId).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.seatbid[0].bid[0].crid); + expect(ads[0].cpm).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].price); + expect(ads[0].currency).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.cur); + expect(ads[0].netRevenue).to.exist.and.to.be.a('boolean').and.to.equal(true); + expect(ads[0].ttl).to.exist.and.to.be.a('number').and.to.equal(10); + expect(ads[0].height).to.equal(null); + expect(ads[0].width).to.equal(null); + expect(ads[0].mediaType).to.exist.and.to.be.a('string').and.to.equal('video'); + expect(ads[0].renderer).to.equal(null); + }); + + it('should return an ad when given a valid server response and server request with a video impression without height', function () { + const serverRequest = utils.deepClone(examples.serverRequest_video_instream); + serverRequest.data.imp[0].video.h = null; + + const serverResponse = utils.deepClone(examples.serverResponse_video_instream); + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(1); + expect(ads[0].requestId).to.exist.and.to.be.a('string').and.to.equal(serverRequest._adot_internal.impressions[0].bidId); + expect(ads[0].ad).to.exist.and.to.be.a('string').and.to.have.string(serverResponse.body.seatbid[0].bid[0].adm); + expect(ads[0].adUrl).to.equal(null); + expect(ads[0].vastXml).to.equal(serverResponse.body.seatbid[0].bid[0].adm); + expect(ads[0].vastUrl).to.equal(null); + expect(ads[0].creativeId).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.seatbid[0].bid[0].crid); + expect(ads[0].cpm).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].price); + expect(ads[0].currency).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.cur); + expect(ads[0].netRevenue).to.exist.and.to.be.a('boolean').and.to.equal(true); + expect(ads[0].ttl).to.exist.and.to.be.a('number').and.to.equal(10); + expect(ads[0].height).to.equal(null); + expect(ads[0].width).to.equal(null); + expect(ads[0].mediaType).to.exist.and.to.be.a('string').and.to.equal('video'); + expect(ads[0].renderer).to.equal(null); + }); + + it('should return no ad when given a server response with a bid with an invalid height', function () { + const serverRequest = examples.serverRequest_video_instream; + + const serverResponse = utils.deepClone(examples.serverResponse_video_instream); + serverResponse.body.seatbid[0].bid[0].h = {}; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a server response with a bid with an invalid width', function () { + const serverRequest = examples.serverRequest_video_instream; + + const serverResponse = utils.deepClone(examples.serverResponse_video_instream); + serverResponse.body.seatbid[0].bid[0].w = {}; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + it('should return no ad when given a valid server response and a server request without video impression', function () { + const serverRequest = utils.deepClone(examples.serverRequest_video_instream); + serverRequest.data.imp[0].video = undefined; + + const serverResponse = utils.deepClone(examples.serverResponse_video_instream); + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(0); + }); + + describe('Outstream renderer', function () { + function spyAdRenderingQueue(ad) { + const spy = sinon.spy(ad.renderer, 'push'); + + this.sinonSpies.push(spy); + } + + function executeAdRenderer(ad, onRendererExecution, done) { + executeRenderer(ad.renderer, ad); + + setTimeout(() => { + try { + onRendererExecution(); + } catch (err) { + done(err); + } + + done() + }, 100); + } + + before('Bind helper functions to the Mocha context', function () { + this.spyAdRenderingQueue = spyAdRenderingQueue.bind(this); + + window.VASTPlayer = function VASTPlayer() {}; + window.VASTPlayer.prototype.loadXml = function loadXml() { + return new Promise((resolve, reject) => resolve()) + }; + window.VASTPlayer.prototype.load = function load() { + return new Promise((resolve, reject) => resolve()) + }; + window.VASTPlayer.prototype.on = function on(event, callback) {}; + window.VASTPlayer.prototype.startAd = function startAd() {}; + }); + + beforeEach('Initialize the Sinon spies list', function () { + this.sinonSpies = []; + }); + + afterEach('Clear the registered Sinon spies', function () { + this.sinonSpies.forEach(spy => spy.restore()); + }); + + after('clear data', () => { + window.VASTPlayer = null; + }); + + it('should return an ad with valid renderer', function () { + const serverRequest = examples.serverRequest_video_outstream; + const serverResponse = examples.serverResponse_video_outstream; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(1); + expect(ads[0].renderer).to.be.an('object'); + }); + + it('should append a command to the ad rendering queue when executing the renderer', function (done) { + const serverRequest = examples.serverRequest_video_outstream; + const serverResponse = examples.serverResponse_video_outstream; + + const [ad] = spec.interpretResponse(serverResponse, serverRequest); + + this.spyAdRenderingQueue(ad); + + executeAdRenderer(ad, () => { + expect(ad.renderer.push.calledOnce).to.equal(true); + expect(ad.renderer.push.firstCall.args[0]).to.exist.and.to.be.a('function'); + }, done); + }); + }); + }); + + describe('Native', function () { + it('should return an ad when given a valid server response with one bid', function () { + const serverRequest = examples.serverRequest_native; + const serverResponse = examples.serverResponse_native; + const native = JSON.parse(serverResponse.body.seatbid[0].bid[0].adm).native; + const {link, assets} = native; + const ads = spec.interpretResponse(serverResponse, serverRequest); + + expect(ads).to.be.an('array').and.to.have.length(1); + expect(ads[0].requestId).to.exist.and.to.be.a('string').and.to.equal(serverRequest._adot_internal.impressions[0].bidId); + expect(ads[0].creativeId).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.seatbid[0].bid[0].crid); + expect(ads[0].cpm).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].price); + expect(ads[0].currency).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.cur); + expect(ads[0].netRevenue).to.exist.and.to.be.a('boolean').and.to.equal(true); + expect(ads[0].ttl).to.exist.and.to.be.a('number').and.to.equal(10); + expect(ads[0].mediaType).to.exist.and.to.be.a('string').and.to.equal('native'); + expect(ads[0].native).to.exist.and.to.be.an('object'); + expect(Object.keys(ads[0].native)).to.have.length(10); + expect(ads[0].native.title).to.equal(assets[0].title.text); + expect(ads[0].native.icon.url).to.equal(assets[1].img.url); + expect(ads[0].native.icon.width).to.equal(assets[1].img.w); + expect(ads[0].native.icon.height).to.equal(assets[1].img.h); + expect(ads[0].native.image.url).to.equal(assets[2].img.url); + expect(ads[0].native.image.width).to.equal(assets[2].img.w); + expect(ads[0].native.image.height).to.equal(assets[2].img.h); + expect(ads[0].native.sponsoredBy).to.equal(assets[3].data.value); + expect(ads[0].native.body).to.equal(assets[4].data.value); + expect(ads[0].native.cta).to.equal(assets[5].data.value); + expect(ads[0].native.clickUrl).to.equal(link.url); + }); + }); + }); +}); diff --git a/test/spec/modules/adpod_spec.js b/test/spec/modules/adpod_spec.js index f8c5387b6ce..ff416e05522 100644 --- a/test/spec/modules/adpod_spec.js +++ b/test/spec/modules/adpod_spec.js @@ -1,10 +1,10 @@ -import * as utils from 'src/utils'; -import { config } from 'src/config'; -import * as videoCache from 'src/videoCache'; -import * as auction from 'src/auction'; -import { ADPOD } from 'src/mediaTypes'; +import * as utils from 'src/utils.js'; +import { config } from 'src/config.js'; +import * as videoCache from 'src/videoCache.js'; +import * as auction from 'src/auction.js'; +import { ADPOD } from 'src/mediaTypes.js'; -import { callPrebidCacheHook, checkAdUnitSetupHook, checkVideoBidSetupHook, adpodSetConfig, sortByPricePerSecond } from 'modules/adpod'; +import { callPrebidCacheHook, checkAdUnitSetupHook, checkVideoBidSetupHook, adpodSetConfig, sortByPricePerSecond } from 'modules/adpod.js'; let expect = require('chai').expect; @@ -138,7 +138,7 @@ describe('adpod.js', function () { mediaTypes: { video: { context: ADPOD, - playerSize: [300, 300], + playerSize: [[300, 300]], adPodDurationSec: 300, durationRangeSec: [15, 30, 45], requireExactDuration: false @@ -220,7 +220,7 @@ describe('adpod.js', function () { mediaTypes: { video: { context: ADPOD, - playerSize: [300, 300], + playerSize: [[300, 300]], adPodDurationSec: 120, durationRangeSec: [15, 30], requireExactDuration: false @@ -282,7 +282,7 @@ describe('adpod.js', function () { mediaTypes: { video: { context: ADPOD, - playerSize: [300, 300], + playerSize: [[300, 300]], adPodDurationSec: 120, durationRangeSec: [15, 30], requireExactDuration: true @@ -376,7 +376,7 @@ describe('adpod.js', function () { mediaTypes: { video: { context: ADPOD, - playerSize: [300, 300], + playerSize: [[300, 300]], adPodDurationSec: 45, durationRangeSec: [15, 30], requireExactDuration: false @@ -465,7 +465,7 @@ describe('adpod.js', function () { mediaTypes: { video: { context: ADPOD, - playerSize: [300, 300], + playerSize: [[300, 300]], adPodDurationSec: 45, durationRangeSec: [15, 30], requireExactDuration: false @@ -525,7 +525,7 @@ describe('adpod.js', function () { mediaTypes: { video: { context: ADPOD, - playerSize: [300, 300], + playerSize: [[300, 300]], adPodDurationSec: 45, durationRangeSec: [15, 30], requireExactDuration: false @@ -602,7 +602,7 @@ describe('adpod.js', function () { mediaTypes: { video: { context: ADPOD, - playerSize: [300, 300], + playerSize: [[300, 300]], adPodDurationSec: 120, durationRangeSec: [15, 30, 45], requireExactDuration: false @@ -675,7 +675,7 @@ describe('adpod.js', function () { mediaTypes: { video: { context: ADPOD, - playerSize: [300, 300], + playerSize: [[300, 300]], adPodDurationSec: 120, durationRangeSec: [15, 30, 45], requireExactDuration: false @@ -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 }] @@ -751,7 +748,7 @@ describe('adpod.js', function () { mediaTypes: { video: { context: ADPOD, - playerSize: [300, 300], + playerSize: [[300, 300]], adPodDurationSec: 45, durationRangeSec: [15, 30], requireExactDuration: false @@ -829,7 +826,7 @@ describe('adpod.js', function () { mediaTypes: { video: { context: ADPOD, - playerSize: [300, 300], + playerSize: [[300, 300]], adPodDurationSec: 300, durationRangeSec: [15, 30, 45], requireExactDuration: false @@ -925,7 +922,7 @@ describe('adpod.js', function () { }, video: { context: 'adpod', - playerSize: [300, 250], + playerSize: [[300, 250]], durationRangeSec: [15, 30, 45], adPodDurationSec: 300 } @@ -944,7 +941,7 @@ describe('adpod.js', function () { mediaTypes: { video: { context: ADPOD, - playerSize: [300, 300], + playerSize: [[300, 300]], adPodDurationSec: 360, durationRangeSec: [15, 30, 45], requireExactDuration: true @@ -992,7 +989,7 @@ describe('adpod.js', function () { mediaTypes: { video: { context: ADPOD, - playerSize: [300, 400], + playerSize: [[300, 400]], durationRangeSec: [15, 45], requireExactDuration: false, adPodDurationSec: 300 @@ -1003,7 +1000,7 @@ describe('adpod.js', function () { mediaTypes: { video: { context: ADPOD, - playerSize: [300, 400], + playerSize: [[300, 400]], durationRangeSec: [15, 30, 45, 60], requireExactDuration: true, adPodDurationSec: 300 diff --git a/test/spec/modules/adponeBidAdapter_spec.js b/test/spec/modules/adponeBidAdapter_spec.js index da685a56394..737f1c284e1 100644 --- a/test/spec/modules/adponeBidAdapter_spec.js +++ b/test/spec/modules/adponeBidAdapter_spec.js @@ -1,6 +1,7 @@ import { expect } from 'chai'; -import { spec } from 'modules/adponeBidAdapter'; -import {newBidder} from '../../../src/adapters/bidderFactory'; +import { spec } from 'modules/adponeBidAdapter.js'; +import {newBidder} from 'src/adapters/bidderFactory.js'; +import * as utils from 'src/utils.js'; const EMPTY_ARRAY = []; describe('adponeBidAdapter', function () { @@ -126,11 +127,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 +158,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 +174,7 @@ describe('interpretResponse', function () { currency: 'USD', netRevenue: true, ttl: 300, - ad: '' + ad: '' }); }); @@ -213,11 +214,18 @@ describe('getUserSyncs', function () { }); describe('test onBidWon function', function () { + beforeEach(function() { + sinon.stub(utils, 'triggerPixel'); + }); + afterEach(function() { + utils.triggerPixel.restore(); + }); it('exists and is a function', () => { expect(spec.onBidWon).to.exist.and.to.be.a('function'); }); it('should return nothing', function () { var response = spec.onBidWon({}); expect(response).to.be.an('undefined') + expect(utils.triggerPixel.called).to.equal(true); }); }); diff --git a/test/spec/modules/adspiritBidAdapter_spec.js b/test/spec/modules/adspiritBidAdapter_spec.js deleted file mode 100644 index 7f907612384..00000000000 --- 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 index 28bb057dffe..ad81795d0e9 100644 --- a/test/spec/modules/adtelligentBidAdapter_spec.js +++ b/test/spec/modules/adtelligentBidAdapter_spec.js @@ -1,25 +1,27 @@ import {expect} from 'chai'; -import {spec} from 'modules/adtelligentBidAdapter'; -import {newBidder} from 'src/adapters/bidderFactory'; +import {spec} from 'modules/adtelligentBidAdapter.js'; +import {newBidder} from 'src/adapters/bidderFactory.js'; -const ENDPOINT = '//hb.adtelligent.com/auction/'; +const ENDPOINT = 'https://ghb.adtelligent.com/auction/'; const DISPLAY_REQUEST = { 'bidder': 'adtelligent', 'params': { 'aid': 12345 }, + 'mediaTypes': {'banner': {'sizes': [300, 250]}}, 'bidderRequestId': '7101db09af0db2', 'auctionId': '2e41f65424c87c', 'adUnitCode': 'adunit-code', 'bidId': '84ab500420319d', - 'sizes': [300, 250] }; const VIDEO_REQUEST = { 'bidder': 'adtelligent', 'mediaTypes': { - 'video': {} + 'video': { + 'playerSize': [[480, 360], [640, 480]] + } }, 'params': { 'aid': 12345 @@ -27,8 +29,7 @@ const VIDEO_REQUEST = { 'bidderRequestId': '7101db09af0db2', 'auctionId': '2e41f65424c87c', 'adUnitCode': 'adunit-code', - 'bidId': '84ab500420319d', - 'sizes': [[480, 360], [640, 480]] + 'bidId': '84ab500420319d' }; const SERVER_VIDEO_RESPONSE = { @@ -73,7 +74,7 @@ const SERVER_DISPLAY_RESPONSE_WITH_MIXED_SYNCS = { 'width': 300, 'cpm': 0.9 }], - 'cookieURLs': ['link1', 'link2'], + 'cookieURLs': ['link3', 'link4'], 'cookieURLSTypes': ['image', 'iframe'] }; @@ -122,7 +123,7 @@ const displayEqResponse = [{ cpm: 0.9 }]; -describe('adtelligentBidAdapter', function () { // todo remove only +describe('adtelligentBidAdapter', function () { const adapter = newBidder(spec); describe('user syncs as image', function () { @@ -143,25 +144,37 @@ describe('adtelligentBidAdapter', function () { // todo remove only }) }) - describe('user syncs with both types', function () { - it('should be returned if pixel and iframe enabled', function () { + describe('user sync', function () { + it('should not be returned if passed syncs where already used', 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); + expect(syncs).to.deep.equal([]); }) - }) + }); + + describe('user syncs with both types', function () { + it('should be returned if pixel and iframe enabled', function () { + const mockedServerResponse = Object.assign({}, SERVER_DISPLAY_RESPONSE_WITH_MIXED_SYNCS, {'cookieURLs': ['link5', 'link6']}); + const syncs = spec.getUserSyncs({ + iframeEnabled: true, + pixelEnabled: true + }, [{body: mockedServerResponse}]); + + expect(syncs.map(s => s.url)).to.deep.equal(mockedServerResponse.cookieURLs); + expect(syncs.map(s => s.type)).to.deep.equal(mockedServerResponse.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 () { @@ -171,13 +184,13 @@ describe('adtelligentBidAdapter', function () { // todo remove only describe('isBidRequestValid', function () { it('should return true when required params found', function () { - expect(spec.isBidRequestValid(VIDEO_REQUEST)).to.equal(12345); + expect(spec.isBidRequestValid(VIDEO_REQUEST)).to.equal(true); }); 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); + expect(spec.isBidRequestValid(bid)).to.equal(false); }); }); diff --git a/test/spec/modules/aduptechBidAdapter_spec.js b/test/spec/modules/aduptechBidAdapter_spec.js index da0b603ebfc..1e39e0cfc8b 100644 --- a/test/spec/modules/aduptechBidAdapter_spec.js +++ b/test/spec/modules/aduptechBidAdapter_spec.js @@ -1,261 +1,502 @@ 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'; +import { + BIDDER_CODE, + PUBLISHER_PLACEHOLDER, + ENDPOINT_URL, + ENDPOINT_METHOD, + spec, + extractGdprFromBidderRequest, + extractParamsFromBidRequest, + extractSizesFromBidRequest, + extractTopWindowReferrerFromBidRequest, + extractTopWindowUrlFromBidRequest +} from '../../../modules/aduptechBidAdapter.js'; +import { newBidder } from '../../../src/adapters/bidderFactory.js'; -describe('AduptechBidAdapter', function () { - const adapter = newBidder(spec); +describe('AduptechBidAdapter', () => { + describe('extractGdprFromBidderRequest', () => { + it('should handle empty bidder request', () => { + const bidderRequest = null; + expect(extractGdprFromBidderRequest(bidderRequest)).to.be.null; + }); + + it('should handle missing gdprConsent in bidder request', () => { + const bidderRequest = {}; + expect(extractGdprFromBidderRequest(bidderRequest)).to.be.null; + }); + + it('should handle gdprConsent in bidder request', () => { + const bidderRequest = { + gdprConsent: { + consentString: 'consentString', + gdprApplies: true + } + }; - describe('inherited functions', function () { - it('exists and is a function', function () { - expect(adapter.callBids).to.exist.and.to.be.a('function'); + expect(extractGdprFromBidderRequest(bidderRequest)).to.deep.equal({ + consentString: bidderRequest.gdprConsent.consentString, + consentRequired: true + }); }); }); - describe('isBidRequestValid', function () { - it('should return true when necessary information is given', function () { - expect(spec.isBidRequestValid({ - sizes: [[100, 200]], + describe('extractParamsFromBidRequest', () => { + it('should handle empty bid request', () => { + const bidRequest = null; + expect(extractParamsFromBidRequest(bidRequest)).to.be.null; + }); + + it('should handle missing params in bid request', () => { + const bidRequest = {}; + expect(extractParamsFromBidRequest(bidRequest)).to.be.null; + }); + + it('should handle params in bid request', () => { + const bidRequest = { params: { - publisher: 'test', - placement: '1234' + foo: '123', + bar: 456 } - })).to.be.true; + }; + expect(extractParamsFromBidRequest(bidRequest)).to.deep.equal(bidRequest.params); }); + }); - it('should return false on empty bid', function () { - expect(spec.isBidRequestValid({})).to.be.false; + describe('extractSizesFromBidRequest', () => { + it('should handle empty bid request', () => { + const bidRequest = null; + expect(extractSizesFromBidRequest(bidRequest)).to.deep.equal([]); }); - it('should return false on missing sizes', function () { - expect(spec.isBidRequestValid({ - params: { - publisher: 'test', - placement: '1234' + it('should handle missing sizes in bid request', () => { + const bidRequest = {}; + expect(extractSizesFromBidRequest(bidRequest)).to.deep.equal([]); + }); + + it('should handle sizes in bid request', () => { + const bidRequest = { + mediaTypes: { + banner: { + sizes: [[12, 34], [56, 78]] + } } - })).to.be.false; + }; + expect(extractSizesFromBidRequest(bidRequest)).to.deep.equal(bidRequest.mediaTypes.banner.sizes); }); - it('should return false on empty sizes', function () { - expect(spec.isBidRequestValid({ - sizes: [], - params: { - publisher: 'test', - placement: '1234' + it('should handle sizes in bid request (backward compatibility)', () => { + const bidRequest = { + sizes: [[12, 34], [56, 78]] + }; + expect(extractSizesFromBidRequest(bidRequest)).to.deep.equal(bidRequest.sizes); + }); + + it('should prefer sizes in mediaTypes.banner', () => { + const bidRequest = { + sizes: [[12, 34]], + mediaTypes: { + banner: { + sizes: [[56, 78]] + } } - })).to.be.false; + }; + expect(extractSizesFromBidRequest(bidRequest)).to.deep.equal(bidRequest.mediaTypes.banner.sizes); }); + }); - it('should return false on missing params', function () { - expect(spec.isBidRequestValid({ - sizes: [[100, 200]], - })).to.be.false; + describe('extractTopWindowReferrerFromBidRequest', () => { + it('should use fallback if bid request is empty', () => { + const bidRequest = null; + expect(extractTopWindowReferrerFromBidRequest(bidRequest)).to.equal(window.top.document.referrer); }); - it('should return false on invalid params', function () { - expect(spec.isBidRequestValid({ - sizes: [[100, 200]], - params: 'bar' - })).to.be.false; + it('should use fallback if refererInfo in bid request is missing', () => { + const bidRequest = {}; + expect(extractTopWindowReferrerFromBidRequest(bidRequest)).to.equal(window.top.document.referrer); }); - it('should return false on empty params', function () { - expect(spec.isBidRequestValid({ - sizes: [[100, 200]], - params: {} - })).to.be.false; + it('should use fallback if refererInfo.referer in bid request is missing', () => { + const bidRequest = { + refererInfo: {} + }; + expect(extractTopWindowReferrerFromBidRequest(bidRequest)).to.equal(window.top.document.referrer); }); - it('should return false on missing publisher', function () { - expect(spec.isBidRequestValid({ - sizes: [[100, 200]], - params: { - placement: '1234' + it('should use fallback if refererInfo.referer in bid request is empty', () => { + const bidRequest = { + refererInfo: { + referer: '' + } + }; + expect(extractTopWindowReferrerFromBidRequest(bidRequest)).to.equal(window.top.document.referrer); + }); + + it('should use refererInfo.referer from bid request ', () => { + const bidRequest = { + refererInfo: { + referer: 'foobar' } - })).to.be.false; + }; + expect(extractTopWindowReferrerFromBidRequest(bidRequest)).to.equal(bidRequest.refererInfo.referer); }); + }); - it('should return false on missing placement', function () { - expect(spec.isBidRequestValid({ - sizes: [[100, 200]], - params: { - publisher: 'test' + describe('extractTopWindowUrlFromBidRequest', () => { + it('should use fallback if bid request is empty', () => { + const bidRequest = null; + expect(extractTopWindowUrlFromBidRequest(bidRequest)).to.equal(window.top.location.href); + }); + + it('should use fallback if refererInfo in bid request is missing', () => { + const bidRequest = {}; + expect(extractTopWindowUrlFromBidRequest(bidRequest)).to.equal(window.top.location.href); + }); + + it('should use fallback if refererInfo.canonicalUrl in bid request is missing', () => { + const bidRequest = { + refererInfo: {} + }; + expect(extractTopWindowUrlFromBidRequest(bidRequest)).to.equal(window.top.location.href); + }); + + it('should use fallback if refererInfo.canonicalUrl in bid request is empty', () => { + const bidRequest = { + refererInfo: { + canonicalUrl: '' + } + }; + expect(extractTopWindowUrlFromBidRequest(bidRequest)).to.equal(window.top.location.href); + }); + + it('should use refererInfo.canonicalUrl from bid request ', () => { + const bidRequest = { + refererInfo: { + canonicalUrl: 'foobar' } - })).to.be.false; + }; + expect(extractTopWindowUrlFromBidRequest(bidRequest)).to.equal(bidRequest.refererInfo.canonicalUrl); }); }); - 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]], + describe('spec', () => { + let adapter; + + beforeEach(() => { + adapter = newBidder(spec); + }); + + describe('inherited functions', () => { + it('exists and is a function', () => { + expect(adapter.callBids).to.exist.and.to.be.a('function'); + }); + }); + + describe('isBidRequestValid', () => { + it('should return true when necessary information is given', () => { + expect(spec.isBidRequestValid({ + mediaTypes: { + banner: { + sizes: [[100, 200]] + } + }, params: { - publisher: 'publisher1', - placement: 'placement1' + publisher: 'test', + placement: '1234' } - }, - { - bidder: BIDDER_CODE, - bidId: 'bidId2', - adUnitCode: 'adUnitCode2', - transactionId: 'transactionId2', - auctionId: 'auctionId2', - sizes: [[500, 600]], + })).to.be.true; + }); + + it('should return true when necessary information is given (backward compatibility)', () => { + expect(spec.isBidRequestValid({ + sizes: [[100, 200]], params: { - publisher: 'publisher2', - placement: 'placement2' + publisher: 'test', + placement: '1234' } - } - ]; - - 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 + })).to.be.true; }); - 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 return false on empty bid', () => { + expect(spec.isBidRequestValid({})).to.be.false; }); - }); - 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]], + it('should return false on missing sizes', () => { + expect(spec.isBidRequestValid({ params: { - publisher: 'publisher3', - placement: 'placement3' + publisher: 'test', + placement: '1234' } - } - ]; + })).to.be.false; + }); - 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 return false on empty sizes', () => { + expect(spec.isBidRequestValid({ + mediaTypes: { + banner: { + sizes: [] + } + }, + params: { + publisher: 'test', + placement: '1234' + } + })).to.be.false; + }); - 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]], + it('should return false on empty sizes (backward compatibility)', () => { + expect(spec.isBidRequestValid({ + sizes: [], params: { - publisher: 'crazy publisher key äÖÜ', - placement: 'placement1' + publisher: 'test', + placement: '1234' } - }, - ]; + })).to.be.false; + }); - const result = spec.buildRequests(bidRequests); + it('should return false on missing params', () => { + expect(spec.isBidRequestValid({ + mediaTypes: { + banner: { + sizes: [[100, 200]] + } + }, + })).to.be.false; + }); - expect(result[0].url).to.equal(ENDPOINT_URL.replace(PUBLISHER_PLACEHOLDER, encodeURIComponent(bidRequests[0].params.publisher))); - }); + it('should return false on invalid params', () => { + expect(spec.isBidRequestValid({ + mediaTypes: { + banner: { + sizes: [[100, 200]] + } + }, + params: 'bar' + })).to.be.false; + }); + + it('should return false on empty params', () => { + expect(spec.isBidRequestValid({ + mediaTypes: { + banner: { + sizes: [[100, 200]] + } + }, + params: {} + })).to.be.false; + }); + + it('should return false on missing publisher', () => { + expect(spec.isBidRequestValid({ + mediaTypes: { + banner: { + sizes: [[100, 200]] + } + }, + params: { + placement: '1234' + } + })).to.be.false; + }); - it('should handle empty bidRequests', function () { - expect(spec.buildRequests([])).to.deep.equal([]); + it('should return false on missing placement', () => { + expect(spec.isBidRequestValid({ + mediaTypes: { + banner: { + sizes: [[100, 200]] + } + }, + params: { + publisher: 'test' + } + })).to.be.false; + }); }); - }); - describe('interpretResponse', function () { - it('should correctly interpret the server response', function () { - const serverResponse = { - body: { - bid: { + describe('buildRequests', () => { + it('should send one bid request per ad unit to the endpoint via POST', () => { + const bidRequests = [ + { + bidder: BIDDER_CODE, bidId: 'bidId1', - price: 0.12, - net: true, - currency: 'EUR', - ttl: 123 + adUnitCode: 'adUnitCode1', + transactionId: 'transactionId1', + auctionId: 'auctionId1', + mediaTypes: { + banner: { + sizes: [[100, 200], [300, 400]] + } + }, + params: { + publisher: 'publisher1', + placement: 'placement1' + } }, - creative: { - id: 'creativeId1', - width: 100, - height: 200, - html: '
Hello World
' + { + bidder: BIDDER_CODE, + bidId: 'bidId2', + adUnitCode: 'adUnitCode2', + transactionId: 'transactionId2', + auctionId: 'auctionId2', + mediaTypes: { + banner: { + sizes: [[500, 600]] + } + }, + params: { + publisher: 'publisher2', + placement: 'placement2' + } } - } - }; + ]; - 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 - } - ]); - }); + const result = spec.buildRequests(bidRequests); + expect(result.length).to.equal(2); - it('should handle empty serverResponse', function () { - expect(spec.interpretResponse({})).to.deep.equal([]); - }); + 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({ + bidId: bidRequests[0].bidId, + auctionId: bidRequests[0].auctionId, + transactionId: bidRequests[0].transactionId, + adUnitCode: bidRequests[0].adUnitCode, + pageUrl: extractTopWindowUrlFromBidRequest(bidRequests[0]), + referrer: extractTopWindowReferrerFromBidRequest(bidRequests[0]), + sizes: extractSizesFromBidRequest(bidRequests[0]), + params: extractParamsFromBidRequest(bidRequests[0]), + gdpr: null + }); - it('should handle missing bid', function () { - expect(spec.interpretResponse({ - body: { - creative: {} - } - })).to.deep.equal([]); + 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({ + bidId: bidRequests[1].bidId, + auctionId: bidRequests[1].auctionId, + transactionId: bidRequests[1].transactionId, + adUnitCode: bidRequests[1].adUnitCode, + pageUrl: extractTopWindowUrlFromBidRequest(bidRequests[1]), + referrer: extractTopWindowReferrerFromBidRequest(bidRequests[1]), + sizes: extractSizesFromBidRequest(bidRequests[1]), + params: extractParamsFromBidRequest(bidRequests[1]), + gdpr: null + }); + }); + + it('should pass gdpr informations', () => { + const bidderRequest = { + gdprConsent: { + consentString: 'consentString', + gdprApplies: true + } + }; + + const bidRequests = [ + { + bidder: BIDDER_CODE, + bidId: 'bidId3', + adUnitCode: 'adUnitCode3', + transactionId: 'transactionId3', + auctionId: 'auctionId3', + mediaTypes: { + banner: { + 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.deep.equal(extractGdprFromBidderRequest(bidderRequest)); + }); + + it('should encode publisher param in endpoint url', () => { + const bidRequests = [ + { + bidder: BIDDER_CODE, + bidId: 'bidId1', + adUnitCode: 'adUnitCode1', + transactionId: 'transactionId1', + auctionId: 'auctionId1', + mediaTypes: { + banner: { + 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', () => { + expect(spec.buildRequests([])).to.deep.equal([]); + }); }); - it('should handle missing creative', function () { - expect(spec.interpretResponse({ - body: { - bid: {} - } - })).to.deep.equal([]); + describe('interpretResponse', () => { + it('should correctly interpret the server response', () => { + 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', () => { + expect(spec.interpretResponse({})).to.deep.equal([]); + }); + + it('should handle missing bid', () => { + expect(spec.interpretResponse({ + body: { + creative: {} + } + })).to.deep.equal([]); + }); + + it('should handle missing creative', () => { + expect(spec.interpretResponse({ + body: { + bid: {} + } + })).to.deep.equal([]); + }); }); }); }); diff --git a/test/spec/modules/advangelistsBidAdapter_spec.js b/test/spec/modules/advangelistsBidAdapter_spec.js index fbdfc9f30ee..2b9615fb572 100755 --- a/test/spec/modules/advangelistsBidAdapter_spec.js +++ b/test/spec/modules/advangelistsBidAdapter_spec.js @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import { spec } from 'modules/advangelistsBidAdapter'; -import { BANNER, VIDEO } from 'src/mediaTypes'; +import { spec } from 'modules/advangelistsBidAdapter.js'; +import { BANNER, VIDEO } from 'src/mediaTypes.js'; describe('advangelistsBidAdapter', function () { let bidRequests; diff --git a/test/spec/modules/advenueBidAdapter_spec.js b/test/spec/modules/advenueBidAdapter_spec.js index f6ffb277bf9..2d7739361b4 100644 --- a/test/spec/modules/advenueBidAdapter_spec.js +++ b/test/spec/modules/advenueBidAdapter_spec.js @@ -1,5 +1,5 @@ import {expect} from 'chai'; -import {spec} from '../../../modules/advenueBidAdapter'; +import {spec} from '../../../modules/advenueBidAdapter.js'; describe('AdvenueAdapter', function () { let bid = { @@ -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/advertlyBidAdapter_spec.js b/test/spec/modules/advertlyBidAdapter_spec.js new file mode 100755 index 00000000000..7825f11948a --- /dev/null +++ b/test/spec/modules/advertlyBidAdapter_spec.js @@ -0,0 +1,159 @@ +import { expect } from 'chai'; +import { spec } from 'modules/advertlyBidAdapter.js'; + +const ENDPOINT = 'https://api.advertly.com/www/admin/plugins/Prebid/getAd.php'; + +describe('The Advertly bidding adapter', function () { + describe('isBidRequestValid', function () { + it('should return false when given an invalid bid', function () { + const bid = { + bidder: 'advertly', + }; + const isValid = spec.isBidRequestValid(bid); + expect(isValid).to.equal(false); + }); + + it('should return true when given a publisherId in bid', function () { + const bid = { + bidder: 'advertly', + params: { + publisherId: 2 + }, + }; + const isValid = spec.isBidRequestValid(bid); + expect(isValid).to.equal(true); + }); + }); + + describe('buildRequests', function () { + const bidRequests = [{ + 'bidder': 'advertly', + 'params': { + 'publisherId': 2 + }, + 'adUnitCode': 'adunit-code', + 'sizes': [ + [300, 250], + [300, 600] + ] + }]; + + const request = spec.buildRequests(bidRequests); + + it('sends bid request to our endpoint via POST', function () { + expect(request.method).to.equal('POST'); + }); + + it('check endpoint url', function () { + expect(request.url).to.equal(ENDPOINT) + }); + + it('sets the proper banner object', function () { + expect(bidRequests[0].params.publisherId).to.equal(2); + }) + }); + const response = { + body: [ + { + 'requestId': '2ee937f15015c6', + 'cpm': '0.2000', + 'width': 300, + 'height': 600, + 'creativeId': '4', + 'currency': 'USD', + 'netRevenue': true, + 'ad': 'ads.html', + 'mediaType': 'banner' + }, + { + 'requestId': '3e1af92622bdc', + 'cpm': '0.2000', + 'creativeId': '4', + 'context': 'outstream', + 'currency': 'USD', + 'netRevenue': true, + 'vastUrl': 'tezt.xml', + 'width': 640, + 'height': 480, + 'mediaType': 'video' + }] + }; + + const request = [ + { + 'bidder': 'advertly', + 'params': { + 'publisherId': 2 + }, + 'mediaTypes': { + 'banner': { + 'sizes': [ + [300, 600] + ] + } + }, + 'bidId': '2ee937f15015c6', + 'src': 'client', + }, + { + 'bidder': 'advertly', + 'params': { + 'publisherId': 2 + }, + 'mediaTypes': { + 'video': { + 'context': 'outstream', + 'playerSize': [ + [640, 480] + ] + } + }, + 'bidId': '3e1af92622bdc', + 'src': 'client', + } + ]; + + describe('interpretResponse', function () { + it('return empty array when no ad found', function () { + const response = {}; + const request = { bidRequests: [] }; + const bids = spec.interpretResponse(response, request); + expect(bids).to.have.lengthOf(0); + }); + + it('check response for banner and video', function () { + const bids = spec.interpretResponse(response, request); + expect(bids).to.have.lengthOf(2); + expect(bids[0].requestId).to.equal('2ee937f15015c6'); + expect(bids[0].cpm).to.equal('0.2000'); + expect(bids[1].cpm).to.equal('0.2000'); + expect(bids[0].width).to.equal(300); + expect(bids[0].height).to.equal(600); + expect(bids[1].vastUrl).to.not.equal(''); + expect(bids[0].ad).to.not.equal(''); + expect(bids[1].adResponse).to.not.equal(''); + expect(bids[1].renderer).not.to.be.an('undefined'); + }); + }); + + describe('On winning bid', function () { + const bids = spec.interpretResponse(response, request); + spec.onBidWon(bids); + }); + + describe('On bid Time out', function () { + const bids = spec.interpretResponse(response, request); + spec.onTimeout(bids); + }); + + describe('user sync', function () { + it('to check the user sync iframe', 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'); + }); + }); +}); diff --git a/test/spec/modules/adxcgAnalyticsAdapter_spec.js b/test/spec/modules/adxcgAnalyticsAdapter_spec.js index 605da3bd6bc..a796e7e966d 100644 --- a/test/spec/modules/adxcgAnalyticsAdapter_spec.js +++ b/test/spec/modules/adxcgAnalyticsAdapter_spec.js @@ -1,23 +1,17 @@ -import adxcgAnalyticsAdapter from 'modules/adxcgAnalyticsAdapter'; +import adxcgAnalyticsAdapter from 'modules/adxcgAnalyticsAdapter.js'; import { expect } from 'chai'; import adapterManager from 'src/adapterManager.js'; +import { server } from 'test/mocks/xhr.js'; let events = require('src/events'); let constants = require('src/constants.json'); describe('adxcg 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(); }); @@ -193,9 +187,9 @@ describe('adxcg analytics adapter', function () { // Step 5: Send auction end event events.emit(constants.EVENTS.AUCTION_END, {}); - expect(requests.length).to.equal(1); + expect(server.requests.length).to.equal(1); - let realAfterBid = JSON.parse(requests[0].requestBody); + let realAfterBid = JSON.parse(server.requests[0].requestBody); expect(realAfterBid).to.deep.equal(expectedAfterBid); @@ -204,8 +198,8 @@ describe('adxcg analytics adapter', function () { // Step 6: Send auction bid won event events.emit(constants.EVENTS.BID_WON, wonRequest); - expect(requests.length).to.equal(2); - let winEventData = JSON.parse(requests[1].requestBody); + expect(server.requests.length).to.equal(2); + let winEventData = JSON.parse(server.requests[1].requestBody); expect(winEventData).to.deep.equal(wonExpect); }); diff --git a/test/spec/modules/adxcgBidAdapter_spec.js b/test/spec/modules/adxcgBidAdapter_spec.js index 3e73479259c..306914960c3 100644 --- a/test/spec/modules/adxcgBidAdapter_spec.js +++ b/test/spec/modules/adxcgBidAdapter_spec.js @@ -1,7 +1,6 @@ import {expect} from 'chai'; -import * as url from 'src/url'; -import {spec} from 'modules/adxcgBidAdapter'; -import {deepClone} from '../../../src/utils'; +import {spec} from 'modules/adxcgBidAdapter.js'; +import {deepClone, parseUrl} from 'src/utils.js'; describe('AdxcgAdapter', function () { let bidBanner = { @@ -119,7 +118,7 @@ describe('AdxcgAdapter', function () { let request = spec.buildRequests([bidBanner]); expect(request).to.exist; expect(request.method).to.equal('GET'); - let parsedRequestUrl = url.parse(request.url); + let parsedRequestUrl = parseUrl(request.url); expect(parsedRequestUrl.hostname).to.equal('hbps.adxcg.net'); expect(parsedRequestUrl.pathname).to.equal('/get/adi'); @@ -152,7 +151,7 @@ describe('AdxcgAdapter', function () { let request = spec.buildRequests([bidVideo]); expect(request).to.exist; expect(request.method).to.equal('GET'); - let parsedRequestUrl = url.parse(request.url); + let parsedRequestUrl = parseUrl(request.url); expect(parsedRequestUrl.hostname).to.equal('hbps.adxcg.net'); expect(parsedRequestUrl.pathname).to.equal('/get/adi'); @@ -191,7 +190,7 @@ describe('AdxcgAdapter', function () { let request = spec.buildRequests([bidNative]); expect(request).to.exist; expect(request.method).to.equal('GET'); - let parsedRequestUrl = url.parse(request.url); + let parsedRequestUrl = parseUrl(request.url); expect(parsedRequestUrl.hostname).to.equal('hbps.adxcg.net'); expect(parsedRequestUrl.pathname).to.equal('/get/adi'); @@ -229,7 +228,7 @@ describe('AdxcgAdapter', function () { consentString: 'consentDataString' } }); - let parsedRequestUrl = url.parse(request.url); + let parsedRequestUrl = parseUrl(request.url); let query = parsedRequestUrl.search; expect(query.gdpr).to.equal('1'); @@ -243,7 +242,7 @@ describe('AdxcgAdapter', function () { consentString: 'consentDataString' } }); - let parsedRequestUrl = url.parse(request.url); + let parsedRequestUrl = parseUrl(request.url); let query = parsedRequestUrl.search; expect(query.gdpr).to.be.undefined; @@ -258,7 +257,7 @@ describe('AdxcgAdapter', function () { it('should send pubcid if available', function () { let request = spec.buildRequests(bid, bidderRequests); - let parsedRequestUrl = url.parse(request.url); + let parsedRequestUrl = parseUrl(request.url); let query = parsedRequestUrl.search; expect(query.pubcid).to.equal('pubcidabcd'); }); @@ -272,7 +271,7 @@ describe('AdxcgAdapter', function () { it('should send pubcid if available', function () { let request = spec.buildRequests(bid, bidderRequests); - let parsedRequestUrl = url.parse(request.url); + let parsedRequestUrl = parseUrl(request.url); let query = parsedRequestUrl.search; expect(query.tdid).to.equal('tdidabcd'); }); @@ -286,7 +285,7 @@ describe('AdxcgAdapter', function () { it('should send pubcid if available', function () { let request = spec.buildRequests(bid, bidderRequests); - let parsedRequestUrl = url.parse(request.url); + let parsedRequestUrl = parseUrl(request.url); let query = parsedRequestUrl.search; expect(query.id5id).to.equal('id5idsample'); }); @@ -300,7 +299,7 @@ describe('AdxcgAdapter', function () { it('should send pubcid if available', function () { let request = spec.buildRequests(bid, bidderRequests); - let parsedRequestUrl = url.parse(request.url); + let parsedRequestUrl = parseUrl(request.url); let query = parsedRequestUrl.search; expect(query.idl_env).to.equal('idl_envsample'); }); diff --git a/test/spec/modules/adyoulikeBidAdapter_spec.js b/test/spec/modules/adyoulikeBidAdapter_spec.js index 7edb9416b03..3573681dd17 100644 --- a/test/spec/modules/adyoulikeBidAdapter_spec.js +++ b/test/spec/modules/adyoulikeBidAdapter_spec.js @@ -1,19 +1,35 @@ import { expect } from 'chai'; -import { parse } from '../../../src/url'; -import { spec } from 'modules/adyoulikeBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; +import { spec } from 'modules/adyoulikeBidAdapter.js'; +import { newBidder } from 'src/adapters/bidderFactory.js'; describe('Adyoulike Adapter', function () { - const canonicalUrl = 'http://canonical.url/?t=%26'; + const canonicalUrl = 'https://canonical.url/?t=%26'; + const referrerUrl = 'http://referrer.url/?param=value'; const defaultDC = 'hb-api'; + const consentString = 'BOJ8RZsOJ8RZsABAB8AAAAAZ+A=='; + const bidderRequest = { + 'auctionId': '1d1a030790a475', + 'bidderRequestId': '22edbae2733bf6', + 'timeout': 3000, + 'gdprConsent': { + consentString: consentString, + gdprApplies: true + }, + refererInfo: {referer: referrerUrl} + }; const bidRequestWithEmptyPlacement = [ { 'bidId': 'bid_id_0', 'bidder': 'adyoulike', 'placementCode': 'adunit/hb-0', 'params': {}, - 'sizes': '300x250' + 'sizes': '300x250', + 'mediaTypes': + { 'banner': + {'sizes': ['300x250', '300x600'] + } + } } ]; const bidRequestWithEmptySizes = { @@ -39,6 +55,11 @@ describe('Adyoulike Adapter', function () { 'placement': 'placement_0' }, 'sizes': '300x250', + 'mediaTypes': + { 'banner': + {'sizes': ['300x250'] + } + }, 'transactionId': 'bid_id_0_transaction_id' } ]; @@ -53,6 +74,11 @@ describe('Adyoulike Adapter', function () { 'DC': 'fra01' }, 'sizes': '300x250', + 'mediaTypes': + { 'banner': + {'sizes': ['300x250'] + } + }, 'transactionId': 'bid_id_0_transaction_id' } ]; @@ -66,6 +92,11 @@ describe('Adyoulike Adapter', function () { 'placement': 'placement_0' }, 'sizes': '300x250', + 'mediaTypes': + { 'banner': + {'sizes': ['300x250'] + } + }, 'transactionId': 'bid_id_0_transaction_id' }, { @@ -76,6 +107,11 @@ describe('Adyoulike Adapter', function () { 'placement': 'placement_1' }, 'sizes': [[300, 600]], + 'mediaTypes': + { 'banner': + {'sizes': ['300x600'] + } + }, 'transactionId': 'bid_id_1_transaction_id' }, { @@ -97,6 +133,33 @@ describe('Adyoulike Adapter', function () { } ]; + const requestDataOnePlacement = { + 'bid_id_0': + { 'PlacementID': 'e622af275681965d3095808561a1e510', + 'TransactionID': '1bca18cc-c0fe-439b-88c2-8247d3448f22', + 'Width': 300, + 'Height': 600, + 'AvailableSizes': '300x600' + } + } + + const requestDataMultiPlacement = { + 'bid_id_0': + { 'PlacementID': 'e622af275681965d3095808561a1e510', + 'TransactionID': '1bca18cc-c0fe-439b-88c2-8247d3448f22', + 'Width': 300, + 'Height': 600, + 'AvailableSizes': '300x600' + }, + 'bid_id_1': + { 'PlacementID': 'e622af275681965d3095808561a1e510', + 'TransactionID': 'e63b2d86-ca60-4167-9cf1-497607079634', + 'Width': 400, + 'Height': 250, + 'AvailableSizes': '300x250' + } + } + const responseWithEmptyPlacement = [ { 'Placement': 'placement_0' @@ -108,8 +171,7 @@ describe('Adyoulike Adapter', function () { 'Placement': 'placement_0', 'Ad': 'placement_0', 'Price': 0.5, - 'Height': 300, - 'Width': 300, + 'Height': 600, } ]; const responseWithMultiplePlacements = [ @@ -118,16 +180,16 @@ describe('Adyoulike Adapter', function () { 'Placement': 'placement_0', 'Ad': 'placement_0', 'Price': 0.5, - 'Height': 300, - 'Width': 300, + 'Height': 0, // test with wrong value + 'Width': 300 }, { 'BidID': 'bid_id_1', 'Placement': 'placement_1', 'Ad': 'placement_1', 'Price': 0.6, - 'Height': 300, - 'Width': 300, + 'Height': 250 + // 'Width' test with missing value } ]; const adapter = newBidder(spec); @@ -188,8 +250,9 @@ describe('Adyoulike Adapter', function () { canonicalQuery.restore(); }); - it('should add gdpr consent information to the request', function () { + it('should add gdpr/usp consent information to the request', function () { let consentString = 'BOJ8RZsOJ8RZsABAB8AAAAAZ+A=='; + let uspConsentData = '1YCC'; let bidderRequest = { 'auctionId': '1d1a030790a475', 'bidderRequestId': '22edbae2733bf6', @@ -197,8 +260,10 @@ describe('Adyoulike Adapter', function () { 'gdprConsent': { consentString: consentString, gdprApplies: true - } + }, + 'uspConsent': uspConsentData }; + bidderRequest.bids = bidRequestWithSinglePlacement; const request = spec.buildRequests(bidRequestWithSinglePlacement, bidderRequest); @@ -207,15 +272,17 @@ describe('Adyoulike Adapter', function () { expect(payload.gdprConsent).to.exist; expect(payload.gdprConsent.consentString).to.exist.and.to.equal(consentString); expect(payload.gdprConsent.consentRequired).to.exist.and.to.be.true; + expect(payload.uspConsent).to.exist.and.to.equal(uspConsentData); }); it('sends bid request to endpoint with single placement', function () { - const request = spec.buildRequests(bidRequestWithSinglePlacement); + const request = spec.buildRequests(bidRequestWithSinglePlacement, bidderRequest); const payload = JSON.parse(request.data); expect(request.url).to.contain(getEndpoint()); expect(request.method).to.equal('POST'); expect(request.url).to.contains('CanonicalUrl=' + encodeURIComponent(canonicalUrl)); + expect(request.url).to.contains('RefererUrl=' + encodeURIComponent(referrerUrl)); expect(payload.Version).to.equal('1.0'); expect(payload.Bids['bid_id_0'].PlacementID).to.be.equal('placement_0'); @@ -225,7 +292,7 @@ describe('Adyoulike Adapter', function () { it('sends bid request to endpoint with single placement without canonical', function () { canonicalQuery.restore(); - const request = spec.buildRequests(bidRequestWithSinglePlacement); + const request = spec.buildRequests(bidRequestWithSinglePlacement, bidderRequest); const payload = JSON.parse(request.data); expect(request.url).to.contain(getEndpoint()); @@ -239,12 +306,13 @@ describe('Adyoulike Adapter', function () { }); it('sends bid request to endpoint with multiple placements', function () { - const request = spec.buildRequests(bidRequestMultiPlacements); + const request = spec.buildRequests(bidRequestMultiPlacements, bidderRequest); const payload = JSON.parse(request.data); expect(request.url).to.contain(getEndpoint()); expect(request.method).to.equal('POST'); expect(request.url).to.contains('CanonicalUrl=' + encodeURIComponent(canonicalUrl)); + expect(request.url).to.contains('RefererUrl=' + encodeURIComponent(referrerUrl)); expect(payload.Version).to.equal('1.0'); @@ -259,7 +327,7 @@ describe('Adyoulike Adapter', function () { }); it('sends bid request to endpoint setted by parameters', function () { - const request = spec.buildRequests(bidRequestWithDCPlacement); + const request = spec.buildRequests(bidRequestWithDCPlacement, bidderRequest); const payload = JSON.parse(request.data); expect(request.url).to.contain(getEndpoint(`${defaultDC}-fra01`)); @@ -288,30 +356,30 @@ describe('Adyoulike Adapter', function () { it('receive reponse with single placement', function () { serverResponse.body = responseWithSinglePlacement; - let result = spec.interpretResponse(serverResponse, bidRequestWithSinglePlacement); + let result = spec.interpretResponse(serverResponse, {data: '{"Bids":' + JSON.stringify(requestDataOnePlacement) + '}'}); expect(result.length).to.equal(1); expect(result[0].cpm).to.equal(0.5); expect(result[0].ad).to.equal('placement_0'); expect(result[0].width).to.equal(300); - expect(result[0].height).to.equal(300); + expect(result[0].height).to.equal(600); }); it('receive reponse with multiple placement', function () { serverResponse.body = responseWithMultiplePlacements; - let result = spec.interpretResponse(serverResponse, bidRequestMultiPlacements); + let result = spec.interpretResponse(serverResponse, {data: '{"Bids":' + JSON.stringify(requestDataMultiPlacement) + '}'}); expect(result.length).to.equal(2); expect(result[0].cpm).to.equal(0.5); expect(result[0].ad).to.equal('placement_0'); expect(result[0].width).to.equal(300); - expect(result[0].height).to.equal(300); + expect(result[0].height).to.equal(600); expect(result[1].cpm).to.equal(0.6); expect(result[1].ad).to.equal('placement_1'); - expect(result[1].width).to.equal(300); - expect(result[1].height).to.equal(300); + expect(result[1].width).to.equal(400); + expect(result[1].height).to.equal(250); }); }); }); diff --git a/test/spec/modules/ajaBidAdapter_spec.js b/test/spec/modules/ajaBidAdapter_spec.js index 642ac2f0df4..80ecab764e8 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'; +import { spec } from 'modules/ajaBidAdapter.js'; +import { newBidder } from 'src/adapters/bidderFactory.js'; -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 f9b0758749b..00000000000 --- 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 index ce8a34509c4..0161652505c 100644 --- a/test/spec/modules/aniviewBidAdapter_spec.js +++ b/test/spec/modules/aniviewBidAdapter_spec.js @@ -1,5 +1,5 @@ -import { spec } from 'modules/aniviewBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; +import { spec } from 'modules/aniviewBidAdapter.js'; +import { newBidder } from 'src/adapters/bidderFactory.js'; const { expect } = require('chai'); describe('ANIVIEW Bid Adapter Test', function () { @@ -180,4 +180,22 @@ describe('ANIVIEW Bid Adapter Test', function () { expect(result.length).to.equal(0); }); }); + + describe('getUserSyncs', function () { + it('Check get sync pixels from response', function () { + let pixelUrl = 'https://sync.pixel.url/sync'; + let pixelEvent = 'inventory'; + let pixelType = '3'; + let pixelStr = '{"url":"' + pixelUrl + '", "e":"' + pixelEvent + '", "t":' + pixelType + '}'; + let bidResponse = 'FORDFORD00:00:15'; + let serverResponse = [ + {body: bidResponse} + ]; + let syncPixels = spec.getUserSyncs({iframeEnabled: true, pixelEnabled: true}, serverResponse); + expect(syncPixels.length).to.equal(1); + let pixel = syncPixels[0]; + expect(pixel.url).to.equal(pixelUrl); + expect(pixel.type).to.equal('iframe'); + }); + }); }); diff --git a/test/spec/modules/aolBidAdapter_spec.js b/test/spec/modules/aolBidAdapter_spec.js index 0f99901bce4..dd10a57bbfe 100644 --- a/test/spec/modules/aolBidAdapter_spec.js +++ b/test/spec/modules/aolBidAdapter_spec.js @@ -1,7 +1,7 @@ import {expect} from 'chai'; -import * as utils from 'src/utils'; -import {spec} from 'modules/aolBidAdapter'; -import {config} from 'src/config'; +import * as utils from 'src/utils.js'; +import {spec} from 'modules/aolBidAdapter.js'; +import {config} from 'src/config.js'; const DEFAULT_AD_CONTENT = ''; @@ -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/appierAnalyticsAdapter_spec.js b/test/spec/modules/appierAnalyticsAdapter_spec.js index f8c434967f7..56c33604a2e 100644 --- a/test/spec/modules/appierAnalyticsAdapter_spec.js +++ b/test/spec/modules/appierAnalyticsAdapter_spec.js @@ -1,7 +1,7 @@ import { appierAnalyticsAdapter, getCpmInUsd, parseBidderCode, parseAdUnitCode, ANALYTICS_VERSION, BIDDER_STATUS -} from 'modules/appierAnalyticsAdapter'; +} from 'modules/appierAnalyticsAdapter.js'; import {expect} from 'chai'; const events = require('src/events'); const constants = require('src/constants.json'); @@ -15,8 +15,6 @@ const auctionId = 'b0b39610-b941-4659-a87c-de9f62d3e13e'; describe('Appier Prebid AnalyticsAdapter Testing', function () { describe('event tracking and message cache manager', function () { - let xhr; - beforeEach(function () { const configOptions = { affiliateId: affiliateId, @@ -32,12 +30,10 @@ describe('Appier Prebid AnalyticsAdapter Testing', function () { provider: 'appierAnalytics', options: configOptions }); - xhr = sinon.useFakeXMLHttpRequest(); }); afterEach(function () { appierAnalyticsAdapter.disableAnalytics(); - xhr.restore(); }); describe('#getCpmInUsd()', function() { diff --git a/test/spec/modules/appierBidAdapter_spec.js b/test/spec/modules/appierBidAdapter_spec.js index c7fc5744d1c..5b6ccf14162 100644 --- a/test/spec/modules/appierBidAdapter_spec.js +++ b/test/spec/modules/appierBidAdapter_spec.js @@ -1,7 +1,7 @@ import { expect } from 'chai'; -import { spec, API_SERVERS_MAP, ADAPTER_VERSION } from 'modules/appierBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; -import { config } from 'src/config'; +import { spec, API_SERVERS_MAP, ADAPTER_VERSION } from 'modules/appierBidAdapter.js'; +import { newBidder } from 'src/adapters/bidderFactory.js'; +import { config } from 'src/config.js'; describe('AppierAdapter', function () { const adapter = newBidder(spec); diff --git a/test/spec/modules/appnexusBidAdapter_spec.js b/test/spec/modules/appnexusBidAdapter_spec.js index c1d307521a5..8934d1cdaef 100644 --- a/test/spec/modules/appnexusBidAdapter_spec.js +++ b/test/spec/modules/appnexusBidAdapter_spec.js @@ -1,12 +1,12 @@ import { expect } from 'chai'; -import { spec } from 'modules/appnexusBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; -import * as bidderFactory from 'src/adapters/bidderFactory'; -import { auctionManager } from 'src/auctionManager'; -import { deepClone } from 'src/utils'; -import { config } from 'src/config'; +import { spec } from 'modules/appnexusBidAdapter.js'; +import { newBidder } from 'src/adapters/bidderFactory.js'; +import * as bidderFactory from 'src/adapters/bidderFactory.js'; +import { auctionManager } from 'src/auctionManager.js'; +import { deepClone } from 'src/utils.js'; +import { config } from 'src/config.js'; -const ENDPOINT = '//ib.adnxs.com/ut/v3/prebid'; +const ENDPOINT = 'https://ib.adnxs.com/ut/v3/prebid'; describe('AppNexusAdapter', function () { const adapter = newBidder(spec); @@ -164,6 +164,7 @@ describe('AppNexusAdapter', function () { const payload = JSON.parse(request.data); expect(payload.tags[0].ad_types).to.deep.equal(['video']); + expect(payload.tags[0].hb_source).to.deep.equal(1); }); it('sends bid request to ENDPOINT via POST', function () { @@ -193,6 +194,7 @@ describe('AppNexusAdapter', function () { id: 123, minduration: 100 }); + expect(payload.tags[0].hb_source).to.deep.equal(1); }); it('should add video property when adUnit includes a renderer', function () { @@ -215,7 +217,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 () {} } }); @@ -256,7 +258,7 @@ describe('AppNexusAdapter', function () { expect(payload.user).to.exist; expect(payload.user).to.deep.equal({ - externalUid: '123', + external_uid: '123', }); }); @@ -417,6 +419,44 @@ describe('AppNexusAdapter', function () { expect(payload3.tags.length).to.equal(15); }); + it('should contain hb_source value for adpod', function() { + let bidRequest = Object.assign({}, + bidRequests[0], + { + params: { placementId: '14542875' } + }, + { + mediaTypes: { + video: { + context: 'adpod', + playerSize: [640, 480], + adPodDurationSec: 300, + durationRangeSec: [15, 30], + } + } + } + ); + const request = spec.buildRequests([bidRequest])[0]; + const payload = JSON.parse(request.data); + expect(payload.tags[0].hb_source).to.deep.equal(7); + }); + + it('should contain hb_source value for other media', function() { + let bidRequest = Object.assign({}, + bidRequests[0], + { + mediaType: 'banner', + params: { + sizes: [[300, 250], [300, 600]], + placementId: 13144370 + } + } + ); + const request = spec.buildRequests([bidRequest]); + const payload = JSON.parse(request.data); + expect(payload.tags[0].hb_source).to.deep.equal(1); + }); + it('adds brand_category_exclusion to request when set', function() { let bidRequest = Object.assign({}, bidRequests[0]); sinon @@ -480,6 +520,7 @@ describe('AppNexusAdapter', function () { saleprice: {required: true}, privacy_supported: true }); + expect(payload.tags[0].hb_source).to.equal(1); }); it('should always populated tags[].sizes with 1,1 for native if otherwise not defined', function () { @@ -583,6 +624,7 @@ describe('AppNexusAdapter', function () { bidderRequest.bids = bidRequests; const request = spec.buildRequests(bidRequests, bidderRequest); + expect(request.options).to.be.empty; const payload = JSON.parse(request.data); expect(payload.gdpr_consent).to.exist; @@ -656,13 +698,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 +713,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(',') @@ -681,11 +723,7 @@ describe('AppNexusAdapter', function () { it('should populate tpids array when userId is available', function () { const bidRequest = Object.assign({}, bidRequests[0], { userId: { - criteortus: { - appnexus: { - userid: 'sample-userid' - } - } + criteoId: 'sample-userid' } }); @@ -737,6 +775,32 @@ describe('AppNexusAdapter', function () { config.getConfig.restore(); }); + + it('should set withCredentials to false if purpose 1 consent is not given', function () { + let consentString = 'BOJ8RZsOJ8RZsABAB8AAAAAZ+A=='; + let bidderRequest = { + 'bidderCode': 'appnexus', + 'auctionId': '1d1a030790a475', + 'bidderRequestId': '22edbae2733bf6', + 'timeout': 3000, + 'gdprConsent': { + consentString: consentString, + gdprApplies: true, + apiVersion: 2, + vendorData: { + purpose: { + consents: { + 1: false + } + } + } + } + }; + bidderRequest.bids = bidRequests; + + const request = spec.buildRequests(bidRequests, bidderRequest); + expect(request.options).to.deep.equal({withCredentials: false}); + }); }) describe('interpretResponse', function () { @@ -757,7 +821,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 +837,7 @@ describe('AppNexusAdapter', function () { 'publisher_currency_code': '$', 'client_initiated_ad_counting': true, 'viewability': { - 'config': '' + 'config': '' }, 'rtb': { 'banner': { @@ -784,7 +848,7 @@ describe('AppNexusAdapter', function () { 'trackers': [ { 'impression_urls': [ - 'http://lax1-ib.adnxs.com/impression' + 'https://lax1-ib.adnxs.com/impression' ], 'video_events': {} } @@ -855,7 +919,7 @@ describe('AppNexusAdapter', function () { 'content': '' } }, - 'javascriptTrackers': '' + 'javascriptTrackers': '' }] }] }; @@ -887,10 +951,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 +987,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 +1029,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 +1064,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 () { @@ -1032,17 +1096,29 @@ describe('AppNexusAdapter', function () { it('should add deal_priority and deal_code', function() { let responseWithDeal = deepClone(response); - responseWithDeal.tags[0].ads[0].deal_priority = 'high'; + responseWithDeal.tags[0].ads[0].ad_type = 'video'; + responseWithDeal.tags[0].ads[0].deal_priority = 5; responseWithDeal.tags[0].ads[0].deal_code = '123'; + responseWithDeal.tags[0].ads[0].rtb.video = { + duration_ms: 1500, + player_width: 640, + player_height: 340, + }; let bidderRequest = { bids: [{ bidId: '3db3773286ee59', - adUnitCode: 'code' + adUnitCode: 'code', + mediaTypes: { + video: { + context: 'adpod' + } + } }] } let result = spec.interpretResponse({ body: responseWithDeal }, {bidderRequest}); expect(Object.keys(result[0].appnexus)).to.include.members(['buyerMemberId', 'dealPriority', 'dealCode']); + expect(result[0].video.dealTier).to.equal(5); }); it('should add advertiser id', function() { diff --git a/test/spec/modules/arteebeeBidAdapter_spec.js b/test/spec/modules/arteebeeBidAdapter_spec.js deleted file mode 100644 index 013e1bd6c0c..00000000000 --- 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/astraoneBidAdapter_spec.js b/test/spec/modules/astraoneBidAdapter_spec.js index cd80e742b7d..e422f64b570 100644 --- a/test/spec/modules/astraoneBidAdapter_spec.js +++ b/test/spec/modules/astraoneBidAdapter_spec.js @@ -1,5 +1,5 @@ import { expect } from 'chai' -import { spec } from 'modules/astraoneBidAdapter' +import { spec } from 'modules/astraoneBidAdapter.js' function getSlotConfigs(mediaTypes, params) { return { diff --git a/test/spec/modules/atomxBidAdapter_spec.js b/test/spec/modules/atomxBidAdapter_spec.js index fdcdb55ec7f..d798bd6308c 100644 --- a/test/spec/modules/atomxBidAdapter_spec.js +++ b/test/spec/modules/atomxBidAdapter_spec.js @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import { spec } from 'modules/atomxBidAdapter'; +import { spec } from 'modules/atomxBidAdapter.js'; describe('atomxAdapterTest', function () { describe('bidRequestValidity', function () { @@ -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/atsAnalyticsAdapter_spec.js b/test/spec/modules/atsAnalyticsAdapter_spec.js new file mode 100644 index 00000000000..3dd6f261c11 --- /dev/null +++ b/test/spec/modules/atsAnalyticsAdapter_spec.js @@ -0,0 +1,150 @@ +import atsAnalyticsAdapter from '../../../modules/atsAnalyticsAdapter.js'; +import { expect } from 'chai'; +import adapterManager from 'src/adapterManager.js'; +import {server} from '../../mocks/xhr.js'; +import {browserIsChrome, browserIsEdge, browserIsFirefox, browserIsSafari} from '../../../modules/atsAnalyticsAdapter.js'; +let events = require('src/events'); +let constants = require('src/constants.json'); + +describe('ats analytics adapter', function () { + beforeEach(function () { + sinon.stub(events, 'getEvents').returns([]); + }); + + afterEach(function () { + events.getEvents.restore(); + atsAnalyticsAdapter.disableAnalytics(); + }); + + describe('track', function () { + it('builds and sends request and response data', function () { + sinon.spy(atsAnalyticsAdapter, 'track'); + + let initOptions = { + pid: '10433394', + host: 'https://example.com/dev', + }; + let auctionTimestamp = 1496510254326; + + // prepare general auction - request + let bidRequest = { + 'bidderCode': 'appnexus', + 'auctionStart': 1580739265161, + 'bids': [{ + 'bidder': 'appnexus', + 'params': { + 'placementId': '10433394' + }, + 'userId': { + 'idl_env': 'AmThEbO1ssIWjrNdU4noT4ZFBILSVBBYHbipOYt_JP40e5nZdXns2g' + }, + 'adUnitCode': 'div-gpt-ad-1438287399331-0', + 'transactionId': '2f481ff1-8d20-4c28-8e36-e384e9e3eec6', + 'sizes': '300x250,300x600', + 'bidId': '30c77d079cdf17' + }], + 'refererInfo': { + 'referer': 'https://example.com/dev' + }, + 'auctionId': 'a5b849e5-87d7-4205-8300-d063084fcfb7', + }; + // prepare general auction - response + let bidResponse = { + 'height': 250, + 'statusMessage': 'Bid available', + 'adId': '2eddfdc0c791dc', + 'mediaType': 'banner', + 'source': 'client', + 'requestId': '30c77d079cdf17', + 'cpm': 0.5, + 'creativeId': 29681110, + 'currency': 'USD', + 'netRevenue': true, + 'ttl': 300, + 'auctionId': 'a5b849e5-87d7-4205-8300-d063084fcfb7', + 'responseTimestamp': 1580739791978, + 'requestTimestamp': 1580739265164, + 'bidder': 'appnexus', + 'adUnitCode': 'div-gpt-ad-1438287399331-0', + 'timeToRespond': 2510, + 'size': '300x250' + }; + + // what we expect after general auction + let expectedAfterBid = { + 'Data': [{ + 'has_envelope': true, + 'bidder': 'appnexus', + 'bid_id': '30c77d079cdf17', + 'auction_id': 'a5b849e5-87d7-4205-8300-d063084fcfb7', + 'user_browser': (browserIsFirefox() || browserIsEdge() || browserIsChrome() || browserIsSafari()), + 'user_platform': navigator.platform, + 'auction_start': '2020-02-03T14:14:25.161Z', + 'domain': window.location.hostname, + 'pid': '10433394', + 'response_time_stamp': '2020-02-03T14:23:11.978Z', + 'currency': 'USD', + 'cpm': 0.5, + 'net_revenue': true + }] + }; + + // lets simulate that some bidders timeout + 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' + } + ]; + + adapterManager.registerAnalyticsAdapter({ + code: 'atsAnalytics', + adapter: atsAnalyticsAdapter + }); + + adapterManager.enableAnalytics({ + provider: 'atsAnalytics', + options: initOptions + }); + + // 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, {}); + + let requests = server.requests.filter(req => { + return req.url.indexOf(initOptions.host) > -1; + }); + + expect(requests.length).to.equal(1); + + let realAfterBid = JSON.parse(requests[0].requestBody); + + // Step 6: assert real data after bid and expected data + expect(realAfterBid['Data']).to.deep.equal(expectedAfterBid['Data']); + + // check that the host and publisher ID is configured via options + expect(atsAnalyticsAdapter.context.host).to.equal(initOptions.host); + expect(atsAnalyticsAdapter.context.pid).to.equal(initOptions.pid); + }) + }) +}) diff --git a/test/spec/modules/audienceNetworkBidAdapter_spec.js b/test/spec/modules/audienceNetworkBidAdapter_spec.js index b8f6b26ffaf..5d3a8527953 100644 --- a/test/spec/modules/audienceNetworkBidAdapter_spec.js +++ b/test/spec/modules/audienceNetworkBidAdapter_spec.js @@ -3,8 +3,8 @@ */ import { expect } from 'chai'; -import { spec } from 'modules/audienceNetworkBidAdapter'; -import * as utils from 'src/utils'; +import { spec } from 'modules/audienceNetworkBidAdapter.js'; +import * as utils from 'src/utils.js'; const { code, @@ -20,7 +20,22 @@ const playerwidth = 320; const playerheight = 180; const requestId = 'test-request-id'; const debug = 'adapterver=1.3.0&platform=2078522619030089&platver=$prebid.version$&cb=test-uuid'; -const pageUrl = encodeURIComponent(utils.getTopWindowUrl()); +const expectedPageUrl = encodeURIComponent('http://www.prebid-test.com/audienceNetworkTest.html?pbjs_debug=true'); +const mockBidderRequest = { + bidderCode: 'audienceNetwork', + auctionId: '720146a0-8f32-4db0-bb30-21f1d057efb4', + bidderRequestId: '1312d48561657e', + auctionStart: 1579711852920, + timeout: 3000, + refererInfo: { + referer: 'http://www.prebid-test.com/audienceNetworkTest.html?pbjs_debug=true', + reachedTop: true, + numIframes: 0, + stack: ['http://www.prebid-test.com/audienceNetworkTest.html?pbjs_debug=true'], + canonicalUrl: undefined + }, + start: 1579711852925 +}; describe('AudienceNetwork adapter', function () { describe('Public API', function () { @@ -129,19 +144,40 @@ describe('AudienceNetwork adapter', function () { utils.generateUUID.restore(); }); + it('takes the canonicalUrl as priority over referer for pageurl', function () { + let expectedCanonicalUrl = encodeURIComponent('http://www.this-is-canonical-url.com/hello-world.html?pbjs_debug=true'); + mockBidderRequest.refererInfo.canonicalUrl = 'http://www.this-is-canonical-url.com/hello-world.html?pbjs_debug=true'; + expect(buildRequests([{ + bidder, + bidId: requestId, + sizes: [[300, 50], [300, 250], [320, 50]], + params: { placementId } + }], mockBidderRequest)).to.deep.equal([{ + adformats: ['300x250'], + method: 'GET', + pageurl: expectedCanonicalUrl, + requestIds: [requestId], + sizes: ['300x250'], + url: 'https://an.facebook.com/v2/placementbid.json', + data: `placementids[]=test-placement-id&adformats[]=300x250&testmode=false&pageurl=${expectedCanonicalUrl}&sdk[]=6.0.web&${debug}` + }]); + mockBidderRequest.refererInfo.canonicalUrl = undefined; + }); + 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([{ + }], mockBidderRequest)).to.deep.equal([{ adformats: ['300x250'], method: 'GET', + pageurl: expectedPageUrl, 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}` + data: `placementids[]=test-placement-id&adformats[]=300x250&testmode=false&pageurl=${expectedPageUrl}&sdk[]=6.0.web&${debug}` }]); }); @@ -154,13 +190,14 @@ describe('AudienceNetwork adapter', function () { placementId, format: 'video' } - }])).to.deep.equal([{ + }], mockBidderRequest)).to.deep.equal([{ adformats: ['video'], method: 'GET', + pageurl: expectedPageUrl, 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` + data: `placementids[]=test-placement-id&adformats[]=video&testmode=false&pageurl=${expectedPageUrl}&sdk[]=&${debug}&playerwidth=640&playerheight=480` }]); }); @@ -173,13 +210,14 @@ describe('AudienceNetwork adapter', function () { placementId, format: 'native' } - }])).to.deep.equal([{ + }], mockBidderRequest)).to.deep.equal([{ adformats: ['native'], method: 'GET', + pageurl: expectedPageUrl, 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}` + data: `placementids[]=test-placement-id&adformats[]=native&testmode=false&pageurl=${expectedPageUrl}&sdk[]=6.0.web&${debug}` }]); }); @@ -196,13 +234,14 @@ describe('AudienceNetwork adapter', function () { platform, format: 'fullwidth' } - }])).to.deep.equal([{ + }], mockBidderRequest)).to.deep.equal([{ adformats: ['300x250'], method: 'GET', + pageurl: expectedPageUrl, 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}` + data: `placementids[]=test-placement-id&adformats[]=300x250&testmode=false&pageurl=${expectedPageUrl}&sdk[]=6.0.web&${debugPlatform}` }]); }); }); @@ -233,7 +272,8 @@ describe('AudienceNetwork adapter', function () { }, { adformats: ['native'], requestIds: [requestId], - sizes: [[300, 250]] + sizes: [[300, 250]], + pageurl: expectedPageUrl }); expect(bidResponse.cpm).to.equal(1.23); @@ -274,7 +314,8 @@ describe('AudienceNetwork adapter', function () { }, { adformats: ['300x250'], requestIds: [requestId], - sizes: [[300, 250]] + sizes: [[300, 250]], + pageurl: expectedPageUrl }); expect(bidResponse.cpm).to.equal(1.23); @@ -314,7 +355,8 @@ describe('AudienceNetwork adapter', function () { }, { adformats: ['300x250'], requestIds: [requestId], - sizes: [[300, 250]] + sizes: [[300, 250]], + pageurl: expectedPageUrl }); expect(bidResponse.cpm).to.equal(1.23); @@ -358,7 +400,8 @@ describe('AudienceNetwork adapter', function () { }, { adformats: ['native', '300x250'], requestIds: [requestId, requestId], - sizes: ['300x250', [300, 250]] + sizes: ['300x250', [300, 250]], + pageurl: expectedPageUrl }); expect(bidResponseNative.cpm).to.equal(1.23); @@ -415,14 +458,15 @@ describe('AudienceNetwork adapter', function () { }, { adformats: ['video'], requestIds: [requestId], - sizes: [[playerwidth, playerheight]] + sizes: [[playerwidth, playerheight]], + pageurl: expectedPageUrl }); 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.vastUrl).to.equal(`https://an.facebook.com/v1/instream/vast.xml?placementid=${placementId}&pageurl=${expectedPageUrl}&playerwidth=${playerwidth}&playerheight=${playerheight}&bidid=${bidId}`); expect(bidResponse.width).to.equal(playerwidth); expect(bidResponse.height).to.equal(playerheight); }); @@ -456,14 +500,15 @@ describe('AudienceNetwork adapter', function () { }, { adformats: ['video', 'native'], requestIds: [requestId, requestId], - sizes: [[playerwidth, playerheight], [300, 250]] + sizes: [[playerwidth, playerheight], [300, 250]], + pageurl: expectedPageUrl }); 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.vastUrl).to.equal(`https://an.facebook.com/v1/instream/vast.xml?placementid=${videoPlacementId}&pageurl=${expectedPageUrl}&playerwidth=${playerwidth}&playerheight=${playerheight}&bidid=${videoBidId}`); expect(bidResponseVideo.width).to.equal(playerwidth); expect(bidResponseVideo.height).to.equal(playerheight); @@ -495,7 +540,8 @@ describe('AudienceNetwork adapter', function () { }, { adformats: ['native'], requestIds: [requestId], - sizes: [[300, 250]] + sizes: [[300, 250]], + pageurl: expectedPageUrl }); expect(bidResponse.cpm).to.equal(1.23); diff --git a/test/spec/modules/audiencerunBidAdapter_spec.js b/test/spec/modules/audiencerunBidAdapter_spec.js new file mode 100644 index 00000000000..826944abaf5 --- /dev/null +++ b/test/spec/modules/audiencerunBidAdapter_spec.js @@ -0,0 +1,204 @@ +import { expect } from 'chai'; +import { spec } from 'modules/audiencerunBidAdapter.js'; +import { newBidder } from 'src/adapters/bidderFactory.js'; + +const ENDPOINT = 'https://d.audiencerun.com/prebid'; + +const BID_SERVER_RESPONSE = { + body: { + bid: [ + { + 'bidId': '51ef8751f9aead', + 'zoneId': '12345abcde', + 'adId': '1234', + 'crid': '5678', + 'cpm': 8.021951999999999999, + 'currency': 'USD', + 'w': 728, + 'h': 90, + 'isNet': false, + 'buying_type': 'rtb', + 'syncUrl': 'https://ac.audiencerun.com/f/sync.html', + 'adm': '' + } + ] + } +}; + +describe('AudienceRun bid adapter tests', 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': 'audiencerun', + 'params': { + 'zoneId': '12345abcde' + }, + 'adUnitCode': 'adunit-code', + 'mediaTypes': { + 'banner': { + '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 true when zoneId is valid', function() { + let bid = Object.assign({}, bid); + delete bid.params; + bid.params = { + 'zoneId': '12345abcde' + }; + + 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 = {}; + + expect(spec.isBidRequestValid(bid)).to.equal(false); + }); + }); + + describe('buildRequests', function() { + let bidRequests = [ + { + 'bidder': 'audiencerun', + 'bidId': '51ef8751f9aead', + 'params': { + 'zoneId': '12345abcde' + }, + 'adUnitCode': 'div-gpt-ad-1460505748561-0', + 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', + 'mediaTypes': { + 'banner': { + '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 + }, + refererInfo: { + canonicalUrl: 'https://example.com/canonical', + referer: 'https://example.com' + } + }); + + 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).to.have.property('bidId'); + expect(bid).to.have.property('zoneId'); + expect(bid).to.have.property('sizes'); + expect(bid.sizes[0].w).to.be.a('number'); + expect(bid.sizes[0].h).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 () { + const expectedResponse = [{ + 'requestId': '51ef8751f9aead', + 'adId': '12345abcde', + 'cpm': 8.021951999999999999, + 'width': '728', + 'height': '90', + 'creativeId': '5678', + 'currency': 'USD', + 'netRevenue': false, + 'ttl': 300, + 'ad': '', + 'mediaType': 'banner' + }]; + + it('should get the correct bid response by display ad', function () { + let result = spec.interpretResponse(BID_SERVER_RESPONSE); + expect(Object.keys(result[0])).to.have.members(Object.keys(expectedResponse[0])); + }); + + it('handles empty bid response', function () { + const response = { + body: {} + }; + let result = spec.interpretResponse(response); + expect(result.length).to.equal(0); + }); + }); + + describe('getUserSyncs', function () { + const serverResponses = [ BID_SERVER_RESPONSE ]; + const syncOptions = { iframeEnabled: true }; + + it('should return empty if no server responses', function() { + const syncs = spec.getUserSyncs(syncOptions, []); + expect(syncs).to.deep.equal([]) + }); + + it('should return user syncs', function () { + const syncs = spec.getUserSyncs(syncOptions, serverResponses); + expect(syncs).to.deep.equal([{type: 'iframe', url: 'https://ac.audiencerun.com/f/sync.html'}]) + }); + }); +}); diff --git a/test/spec/modules/automatadBidAdapter_spec.js b/test/spec/modules/automatadBidAdapter_spec.js new file mode 100644 index 00000000000..788fd3aefc4 --- /dev/null +++ b/test/spec/modules/automatadBidAdapter_spec.js @@ -0,0 +1,144 @@ +import { expect } from 'chai' +import { spec } from 'modules/automatadBidAdapter.js' +import { newBidder } from 'src/adapters/bidderFactory.js' + +describe('automatadBidAdapter', function () { + const adapter = newBidder(spec) + + let bidRequest = { + bidder: 'automatad', + params: {siteId: '123ad', placementId: '123abc345'}, + mediaTypes: { + banner: { + sizes: [[300, 600]], + } + }, + adUnitCode: 'some-ad-unit-code', + transactionId: '1465569e-52cc-4c36-88a1-7174cfef4b44', + sizes: [[300, 600]], + bidId: '123abc', + bidderRequestId: '3213887463c059', + auctionId: 'abc-123', + src: 'client', + bidRequestsCount: 1 + } + + let expectedResponse = [{ + 'body': { + 'id': 'abc-123', + 'seatbid': [ + { + 'bid': [ + { + 'adm': '', + 'adomain': [ + 'someAdDomain' + ], + 'crid': 123, + 'h': 600, + 'id': 'bid1', + 'impid': '1', + 'nurl': 'https://example/win', + 'price': 0.5, + 'w': 300 + } + ] + } + ] + } + }] + + describe('codes', function () { + it('should return a bidder code of automatad', function () { + expect(spec.code).to.equal('automatad') + }) + it('should alias atd', function () { + expect(spec.aliases.length > 0 && spec.aliases[0] === 'atd').to.be.true + }) + }) + + describe('isBidRequestValid', function () { + let inValidBid = Object.assign({}, bidRequest) + delete inValidBid.params + it('should return true if all params present', function () { + expect(spec.isBidRequestValid(bidRequest)).to.equal(true) + }) + + it('should return false if any parameter missing', function () { + expect(spec.isBidRequestValid(inValidBid)).to.be.false + }) + }) + + describe('buildRequests', function () { + let req = spec.buildRequests([ bidRequest ], { refererInfo: { } }) + let rdata + + it('should return request object', function () { + expect(req).to.not.be.null + }) + + it('should build request data', function () { + expect(req.data).to.not.be.null + }) + + it('should include one request', function () { + rdata = JSON.parse(req.data) + expect(rdata.imp.length).to.equal(1) + }) + + it('should include media types', function () { + let r = rdata.imp[0] + expect(r.media_types !== null).to.be.true + }) + + it('should include all publisher params', function () { + let r = rdata.imp[0] + expect(r.siteID !== null && r.placementID !== null).to.be.true + }) + }) + + describe('interpretResponse', function () { + it('should get the correct bid response', function () { + let result = spec.interpretResponse(expectedResponse[0]) + expect(result).to.be.an('array').that.is.not.empty + }) + + it('handles empty bid response', function () { + let response = { + body: '' + } + let result = spec.interpretResponse(response) + expect(result.length).to.equal(0) + }) + }) + + describe('getUserSyncs', function () { + it('should return iframe sync', function () { + let sync = spec.getUserSyncs() + expect(sync.length).to.equal(1) + expect(sync[0].type === 'iframe') + expect(typeof sync[0].url === 'string') + }) + }) + + describe('onBidWon', function () { + let serverResponses = spec.interpretResponse(expectedResponse[0]) + let wonbid = serverResponses[0] + let ajaxStub + + beforeEach(() => { + ajaxStub = sinon.stub(spec, 'ajaxCall') + }) + + afterEach(() => { + ajaxStub.restore() + }) + + it('Returns true is nurl is good/not blank', function () { + expect(wonbid.nurl).to.not.equal('') + expect(spec.onBidWon(wonbid)).to.be.true + expect(ajaxStub.calledOnce).to.equal(true) + expect(ajaxStub.firstCall.args[0].indexOf('https://')).to.equal(0) + }) + }) +}) diff --git a/test/spec/modules/beachfrontBidAdapter_spec.js b/test/spec/modules/beachfrontBidAdapter_spec.js index 155da4fb309..f7dcc1305e5 100644 --- a/test/spec/modules/beachfrontBidAdapter_spec.js +++ b/test/spec/modules/beachfrontBidAdapter_spec.js @@ -1,7 +1,7 @@ import { expect } from 'chai'; import sinon from 'sinon'; -import { spec, VIDEO_ENDPOINT, BANNER_ENDPOINT, OUTSTREAM_SRC, DEFAULT_MIMES } from 'modules/beachfrontBidAdapter'; -import { parse as parseUrl } from 'src/url'; +import { spec, VIDEO_ENDPOINT, BANNER_ENDPOINT, OUTSTREAM_SRC, DEFAULT_MIMES } from 'modules/beachfrontBidAdapter.js'; +import { parseUrl } from 'src/utils.js'; describe('BeachfrontAdapter', function () { let bidRequests; @@ -234,6 +234,16 @@ describe('BeachfrontAdapter', function () { expect(data.imp[0].video).to.deep.contain({ mimes, playbackmethod, maxduration, placement }); }); + it('must add US privacy data to the request', function () { + const bidRequest = bidRequests[0]; + bidRequest.mediaTypes = { video: {} }; + const uspConsent = '2112YYZ'; + const bidderRequest = { uspConsent }; + const requests = spec.buildRequests([ bidRequest ], bidderRequest); + const data = requests[0].data; + expect(data.regs.ext.us_privacy).to.equal(uspConsent); + }); + it('must add GDPR consent data to the request', function () { const bidRequest = bidRequests[0]; bidRequest.mediaTypes = { video: {} }; @@ -372,6 +382,16 @@ describe('BeachfrontAdapter', function () { expect(data.slots[0].sizes).to.deep.contain({ w: width, h: height }); }); + it('must add US privacy data to the request', function () { + const bidRequest = bidRequests[0]; + bidRequest.mediaTypes = { banner: {} }; + const uspConsent = '2112YYZ'; + const bidderRequest = { uspConsent }; + const requests = spec.buildRequests([ bidRequest ], bidderRequest); + const data = requests[0].data; + expect(data.usPrivacy).to.equal(uspConsent); + }); + it('must add GDPR consent data to the request', function () { const bidRequest = bidRequests[0]; bidRequest.mediaTypes = { banner: {} }; diff --git a/test/spec/modules/betweenBidAdapter_spec.js b/test/spec/modules/betweenBidAdapter_spec.js index f2d770805c5..94db41ba014 100644 --- a/test/spec/modules/betweenBidAdapter_spec.js +++ b/test/spec/modules/betweenBidAdapter_spec.js @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import { spec } from 'modules/betweenBidAdapter'; +import { spec } from 'modules/betweenBidAdapter.js'; describe('betweenBidAdapterTests', function () { it('validate_pub_params', function () { @@ -23,6 +23,122 @@ describe('betweenBidAdapterTests', function () { let req_data = request[0].data; expect(req_data.bidid).to.equal('bid1234'); }); + it('validate itu param', function() { + let bidRequestData = [{ + bidId: 'bid1234', + bidder: 'between', + params: { + w: 240, + h: 400, + s: 1112, + itu: 'https://something.url' + }, + sizes: [[240, 400]] + }]; + + let request = spec.buildRequests(bidRequestData); + let req_data = request[0].data; + + expect(req_data.itu).to.equal('https://something.url'); + }); + it('validate cur param', function() { + let bidRequestData = [{ + bidId: 'bid1234', + bidder: 'between', + params: { + w: 240, + h: 400, + s: 1112, + cur: 'THX' + }, + sizes: [[240, 400]] + }]; + + let request = spec.buildRequests(bidRequestData); + let req_data = request[0].data; + + expect(req_data.cur).to.equal('THX'); + }); + it('validate subid param', function() { + let bidRequestData = [{ + bidId: 'bid1234', + bidder: 'between', + params: { + w: 240, + h: 400, + s: 1112, + subid: 1138, + }, + sizes: [[240, 400]] + }]; + + let request = spec.buildRequests(bidRequestData); + let req_data = request[0].data; + + expect(req_data.subid).to.equal(1138); + }); + it('validate click3rd param', function() { + let bidRequestData = [{ + bidId: 'bid1234', + bidder: 'between', + params: { + w: 240, + h: 400, + s: 1112, + click3rd: 'https://something.url', + }, + sizes: [[240, 400]] + }]; + + let request = spec.buildRequests(bidRequestData); + let req_data = request[0].data; + + expect(req_data.click3rd).to.equal('https://something.url'); + }); + it('validate pubdata param', function() { + let bidRequestData = [{ + bidId: 'bid1234', + bidder: 'between', + params: { + w: 240, + h: 400, + s: 1112, + pubdata: { + param: '&test=tset' + }, + }, + sizes: [[240, 400]] + }]; + + let request = spec.buildRequests(bidRequestData); + let req_data = request[0].data; + + expect(req_data['pubside_macro[param]']).to.equal('%26test%3Dtset'); + }); + it('validate gdprConsent', function() { + let bidRequestData = [{ + bidId: 'bid1234', + bidder: 'between', + params: { + w: 240, + h: 400, + s: 1112, + }, + sizes: [[240, 400]] + }]; + let bidderRequest = { + gdprConsent: { + consentString: 'BOtGbjbOtGbjbBQABBENC3-AAAAtR7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4u_1vf99yfm1-7etr3tp_87ues2_Xur__79__3z3_9pxP78k89r7337Ew_v-_v-b7JCON_IA', + gdprApplies: true + } + } + + let request = spec.buildRequests(bidRequestData, bidderRequest); + let req_data = request[0].data; + + expect(req_data.gdprApplies).to.equal(bidderRequest.gdprConsent.gdprApplies); + expect(req_data.consentString).to.equal(bidderRequest.gdprConsent.consentString); + }); it('validate_response_params', function () { let serverResponse = { body: [{ @@ -66,4 +182,43 @@ describe('betweenBidAdapterTests', function () { expect(bid.requestId).to.equal('bid1234'); expect(bid.ad).to.equal('Ad html'); }); + it('validate response params without currency', function () { + let serverResponse = { + body: [{ + bidid: 'bid1234', + w: 240, + h: 400, + ad: 'Ad html' + }] + }; + let bids = spec.interpretResponse(serverResponse); + expect(bids).to.have.lengthOf(1); + let bid = bids[0]; + expect(bid.currency).to.equal('RUB'); + }); + it('check getUserSyncs', function() { + const syncs = spec.getUserSyncs({}, {}); + expect(syncs).to.be.an('array').that.to.have.lengthOf(1); + expect(syncs[0]).to.deep.equal({type: 'iframe', url: 'https://ads.betweendigital.com/sspmatch-iframe'}); + }); + + it('check sizes', function() { + let bidRequestData = [{ + bidId: 'bid1234', + bidder: 'between', + mediaTypes: { + banner: { + sizes: [[970, 250], [240, 400], [728, 90]] + } + }, + params: { + s: 1112, + }, + }]; + + let request = spec.buildRequests(bidRequestData); + let req_data = request[0].data; + + expect(req_data.sizes).to.deep.equal('970x250%2C240x400%2C728x90'); + }); }); diff --git a/test/spec/modules/bidfluenceBidAdapter_spec.js b/test/spec/modules/bidfluenceBidAdapter_spec.js index 9ce6e808c6b..6b3a0c2b044 100644 --- a/test/spec/modules/bidfluenceBidAdapter_spec.js +++ b/test/spec/modules/bidfluenceBidAdapter_spec.js @@ -1,114 +1,114 @@ -import { expect } from 'chai'; -import { spec } from 'modules/bidfluenceBidAdapter'; - -const BIDDER_CODE = 'bidfluence'; -const PLACEMENT_ID = '1000'; -const PUB_ID = '1000'; -const CONSENT_STRING = 'DUXDSDFSFWRRR8345F=='; - -const validBidRequests = [{ - 'bidder': BIDDER_CODE, - 'params': { - 'placementId': PLACEMENT_ID, - 'publisherId': PUB_ID, - 'reservePrice': 0 - }, - 'adUnitCode': 'adunit-code', - 'sizes': [[300, 250]], - 'bidId': '2b1f23307fb8ef', - 'bidderRequestId': '10edf38ec1a719', - 'auctionId': '1025ba77-5463-4877-b0eb-14b205cb9304' -}]; - -const bidderRequest = { - 'bidderCode': 'bidfluence', - 'auctionId': '1025ba77-5463-4877-b0eb-14b205cb9304', - 'bidderRequestId': '10edf38ec1a719', - 'refererInfo': { - 'numIframes': 0, - 'reachedTop': true, - 'referer': 'test', - 'stack': ['test'] - }, - 'timeout': 1000, - 'gdprConsent': { - 'gdprApplies': true, - 'consentString': CONSENT_STRING, - 'vendorData': '' - } -}; - -bidderRequest.bids = validBidRequests; - -describe('Bidfluence Adapter test', () => { - describe('isBidRequestValid', function () { - it('should return true when required params found', function () { - expect(spec.isBidRequestValid(validBidRequests[0])).to.equal(true); - }); - it('should return the right bidder code', function () { - expect(spec.code).to.eql(BIDDER_CODE); - }); - }); - - describe('buildRequests', function () { - const request = spec.buildRequests(validBidRequests, bidderRequest); - - it('sends bid request to our endpoint via POST', function () { - expect(request.method).to.equal('POST'); - }); - - const payload = JSON.parse(request.data); - - expect(payload.bids[0].bid).to.equal(validBidRequests[0].bidId); - expect(payload.azr).to.equal(true); - expect(payload.ck).to.not.be.undefined; - expect(payload.bids[0].tid).to.equal(PLACEMENT_ID); - expect(payload.bids[0].pid).to.equal(PUB_ID); - expect(payload.bids[0].rp).to.be.a('number'); - expect(payload.re).to.not.be.undefined; - expect(payload.st).to.not.be.undefined; - expect(payload.tz).to.not.be.undefined; - expect(payload.sr).to.not.be.undefined; - expect(payload.vp).to.not.be.undefined; - expect(payload.sdt).to.not.be.undefined; - expect(payload.bids[0].w).to.equal('300'); - expect(payload.bids[0].h).to.equal('250'); - - it('sends gdpr info if exists', function () { - expect(payload.gdpr).to.equal(true); - expect(payload.gdprc).to.equal(CONSENT_STRING); - }); - }); - - describe('interpretResponse', function () { - const response = { - body: { - Bids: - [{ - 'CreativeId': '1000', - 'Cpm': 0.50, - 'Ad': '
', - 'Height': 250, - 'Width': 300 - }] - } - }; - - it('should get correct bid response', function () { - const expectedResponse = [{ - requestId: response.body.Bids[0].BidId, - cpm: response.body.Bids[0].Cpm, - width: response.body.Bids[0].Width, - height: response.body.Bids[0].Height, - creativeId: response.body.Bids[0].CreativeId, - ad: response.body.Bids[0].Ad, - currency: 'USD', - netRevenue: true, - ttl: 360 - }]; - - let result = spec.interpretResponse(response, { 'bidderRequest': validBidRequests[0] }); - expect(result).to.deep.equal(expectedResponse); - }); - }); -}); +import { expect } from 'chai'; +import { spec } from 'modules/bidfluenceBidAdapter.js'; + +const BIDDER_CODE = 'bidfluence'; +const PLACEMENT_ID = '1000'; +const PUB_ID = '1000'; +const CONSENT_STRING = 'DUXDSDFSFWRRR8345F=='; + +const validBidRequests = [{ + 'bidder': BIDDER_CODE, + 'params': { + 'placementId': PLACEMENT_ID, + 'publisherId': PUB_ID, + 'reservePrice': 0 + }, + 'adUnitCode': 'adunit-code', + 'sizes': [[300, 250]], + 'bidId': '2b1f23307fb8ef', + 'bidderRequestId': '10edf38ec1a719', + 'auctionId': '1025ba77-5463-4877-b0eb-14b205cb9304' +}]; + +const bidderRequest = { + 'bidderCode': 'bidfluence', + 'auctionId': '1025ba77-5463-4877-b0eb-14b205cb9304', + 'bidderRequestId': '10edf38ec1a719', + 'refererInfo': { + 'numIframes': 0, + 'reachedTop': true, + 'referer': 'test', + 'stack': ['test'] + }, + 'timeout': 1000, + 'gdprConsent': { + 'gdprApplies': true, + 'consentString': CONSENT_STRING, + 'vendorData': '' + } +}; + +bidderRequest.bids = validBidRequests; + +describe('Bidfluence Adapter test', () => { + describe('isBidRequestValid', function () { + it('should return true when required params found', function () { + expect(spec.isBidRequestValid(validBidRequests[0])).to.equal(true); + }); + it('should return the right bidder code', function () { + expect(spec.code).to.eql(BIDDER_CODE); + }); + }); + + describe('buildRequests', function () { + it('sends bid request to our endpoint via POST', function () { + const request = spec.buildRequests(validBidRequests, bidderRequest); + expect(request.method).to.equal('POST'); + const payload = JSON.parse(request.data); + + expect(payload.bids[0].bid).to.equal(validBidRequests[0].bidId); + expect(payload.azr).to.equal(true); + expect(payload.ck).to.not.be.undefined; + expect(payload.bids[0].tid).to.equal(PLACEMENT_ID); + expect(payload.bids[0].pid).to.equal(PUB_ID); + expect(payload.bids[0].rp).to.be.a('number'); + expect(payload.re).to.not.be.undefined; + expect(payload.st).to.not.be.undefined; + expect(payload.tz).to.not.be.undefined; + expect(payload.sr).to.not.be.undefined; + expect(payload.vp).to.not.be.undefined; + expect(payload.sdt).to.not.be.undefined; + expect(payload.bids[0].w).to.equal('300'); + expect(payload.bids[0].h).to.equal('250'); + }); + + it('sends gdpr info if exists', function () { + const request = spec.buildRequests(validBidRequests, bidderRequest); + const payload = JSON.parse(request.data); + expect(payload.gdpr).to.equal(true); + expect(payload.gdprc).to.equal(CONSENT_STRING); + }); + }); + + describe('interpretResponse', function () { + const response = { + body: { + Bids: + [{ + 'CreativeId': '1000', + 'Cpm': 0.50, + 'Ad': '
', + 'Height': 250, + 'Width': 300 + }] + } + }; + + it('should get correct bid response', function () { + const expectedResponse = [{ + requestId: response.body.Bids[0].BidId, + cpm: response.body.Bids[0].Cpm, + width: response.body.Bids[0].Width, + height: response.body.Bids[0].Height, + creativeId: response.body.Bids[0].CreativeId, + ad: response.body.Bids[0].Ad, + currency: 'USD', + netRevenue: true, + ttl: 360 + }]; + + let result = spec.interpretResponse(response, { 'bidderRequest': validBidRequests[0] }); + expect(result).to.deep.equal(expectedResponse); + }); + }); +}); diff --git a/test/spec/modules/bidglassAdapter_spec.js b/test/spec/modules/bidglassAdapter_spec.js index 00a47fc997a..d153430103d 100644 --- a/test/spec/modules/bidglassAdapter_spec.js +++ b/test/spec/modules/bidglassAdapter_spec.js @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import { spec } from 'modules/bidglassBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; +import { spec } from 'modules/bidglassBidAdapter.js'; +import { newBidder } from 'src/adapters/bidderFactory.js'; describe('Bid Glass Adapter', function () { const adapter = newBidder(spec); diff --git a/test/spec/modules/bidlabBidAdapter_spec.js b/test/spec/modules/bidlabBidAdapter_spec.js new file mode 100644 index 00000000000..cffd43ae6ca --- /dev/null +++ b/test/spec/modules/bidlabBidAdapter_spec.js @@ -0,0 +1,235 @@ +import {expect} from 'chai'; +import {spec} from '../../../modules/bidlabBidAdapter.js'; + +describe('BidlabBidAdapter', function () { + let bid = { + bidId: '23fhj33i987f', + bidder: 'bidlab', + 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('https://service.bidlab.ai/?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', 'sizes'); + 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', 'mediaType'); + 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', 'mediaType'); + 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', + 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', 'ttl', 'creativeId', 'netRevenue', 'currency', 'mediaType', 'native'); + expect(dataItem.native).to.have.keys('clickUrl', 'impressionTrackers', 'title', 'image') + expect(dataItem.requestId).to.equal('23fhj33i987f'); + expect(dataItem.cpm).to.equal(0.4); + expect(dataItem.native.clickUrl).to.equal('test.com'); + expect(dataItem.native.title).to.equal('Test'); + expect(dataItem.native.image).to.equal('test.com'); + expect(dataItem.native.impressionTrackers).to.be.an('array').that.is.not.empty; + expect(dataItem.native.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 () { + if (spec.noSync) { + expect(userSync).to.be.equal(false); + } else { + 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('https://service.bidlab.ai/?c=o&m=sync'); + } + }); + }); +}); diff --git a/test/spec/modules/bidphysicsBidAdapter_spec.js b/test/spec/modules/bidphysicsBidAdapter_spec.js index ba93642ad81..fc15c39cf81 100644 --- a/test/spec/modules/bidphysicsBidAdapter_spec.js +++ b/test/spec/modules/bidphysicsBidAdapter_spec.js @@ -1,5 +1,5 @@ import {expect} from 'chai'; -import {spec} from 'modules/bidphysicsBidAdapter'; +import {spec} from 'modules/bidphysicsBidAdapter.js'; const REQUEST = { 'bidderCode': 'bidphysics', @@ -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 6f518f32ccf..00000000000 --- 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 a3ce90d927a..00000000000 --- 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 index 6ca9675a1bb..644f468abe8 100644 --- a/test/spec/modules/bridgewellBidAdapter_spec.js +++ b/test/spec/modules/bridgewellBidAdapter_spec.js @@ -1,172 +1,8 @@ import { expect } from 'chai'; -import { spec } from 'modules/bridgewellBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; -import * as utils from 'src/utils'; +import { spec } from 'modules/bridgewellBidAdapter.js'; +import { newBidder } from 'src/adapters/bidderFactory.js'; 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 () { @@ -176,113 +12,108 @@ describe('bridgewellBidAdapter', 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); + const validTag = { + 'bidder': 'bridgewell', + 'params': { + 'ChannelID': 'CLJgEAYYvxUiBXBlbm55KgkIrAIQ-gEaATk' + }, + }; + expect(spec.isBidRequestValid(validTag)).to.equal(true); }); 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 + const invalidTag = { + 'bidder': 'bridgewell', + 'params': {}, }; + expect(spec.isBidRequestValid(invalidTag)).to.equal(false); + }); - bidWithZeroCpmWeight.params = { - 'ChannelID': 0 + it('should return false when required params are empty', function () { + const invalidTag = { + 'bidder': 'bridgewell', + 'params': { + 'ChannelID': '', + }, }; - - 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); + expect(spec.isBidRequestValid(invalidTag)).to.equal(false); }); }); describe('buildRequests', function () { + const bidRequests = [ + { + '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', + } + ]; + it('should attach valid params to the tag', function () { - const request = spec.buildRequests(bidRequests); + const bidderRequest = { + refererInfo: { + referer: 'https://www.bridgewell.com/' + } + } + const request = spec.buildRequests(bidRequests, bidderRequest); 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'); + expect(payload.adUnits).to.be.an('array'); + expect(payload.url).to.exist.and.to.equal('https://www.bridgewell.com/'); + for (let i = 0, max_i = payload.adUnits.length; i < max_i; i++) { + expect(payload.adUnits[i]).to.have.property('ChannelID').that.is.a('string'); + expect(payload.adUnits[i]).to.have.property('adUnitCode').and.to.equal('adunit-code-2'); } }); @@ -294,96 +125,54 @@ describe('bridgewellBidAdapter', function () { }); 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' - }, + const nativeBidRequests = { + validBidRequests: [ + { + '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', + }, + ] + }; + const nativeServerResponses = [ { 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', 'bidder_code': 'bridgewell', - 'cpm': 5.0, + 'cpm': 7.0, 'width': 1, 'height': 1, 'mediaType': 'native', @@ -405,317 +194,373 @@ describe('bridgewellBidAdapter', function () { 'clickTrackers': ['https://img.scupio.com/test-clickTracker'], 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker'] }, - 'ttl': 360, + 'ttl': 400, 'netRevenue': true, 'currency': 'NTD' }, + ]; + const bannerBidRequests = { + validBidRequests: [ + { + 'mediaTypes': { + 'banner': { + 'sizes': [300, 250] + } + }, + 'bidId': '3150ccb55da321', + }, + ] + }; + const bannerServerResponses = [ { - 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', + 'id': 'e5b10774-32bf-4931-85ee-05095e8cff21', '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'] - }, + 'width': 300, + 'height': 250, + 'mediaType': 'banner', + 'ad': '
test 300x250
', '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'); - } - }); + const result = spec.interpretResponse({ 'body': nativeServerResponses }, nativeBidRequests); + + expect(result[0].requestId).to.equal('3150ccb55da321'); + expect(result[0].cpm).to.equal(7.0); + expect(result[0].width).to.equal(1); + expect(result[0].height).to.equal(1); + expect(result[0].ttl).to.equal(400); + expect(result[0].creativeId).to.equal('0e4048d3-5c74-4380-a21a-00ba35629f7d'); + expect(result[0].netRevenue).to.equal(true); + expect(result[0].currency).to.equal('NTD'); + expect(result[0].mediaType).to.equal('native'); + expect(result[0].native.image.url).to.equal('https://img.scupio.com/test/test-image.jpg'); + }); + + it('should return all required parameters banner', function () { + const result = spec.interpretResponse({ 'body': bannerServerResponses }, bannerBidRequests); + + expect(result[0].requestId).to.equal('3150ccb55da321'); + expect(result[0].cpm).to.equal(5.0); + expect(result[0].width).to.equal(300); + expect(result[0].height).to.equal(250); + expect(result[0].ttl).to.equal(360); + expect(result[0].creativeId).to.equal('e5b10774-32bf-4931-85ee-05095e8cff21'); + expect(result[0].netRevenue).to.equal(true); + expect(result[0].currency).to.equal('NTD'); + expect(result[0].mediaType).to.equal('banner'); + expect(result[0].ad).to.equal('
test 300x250
'); }); it('should give up bid if server response is undefiend', function () { - const result = spec.interpretResponse({'body': undefined}, request); + let result = spec.interpretResponse({ 'body': undefined }, bannerBidRequests); + 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', - }])); + const request = { + validBidRequests: [ + { + 'mediaTypes': { + 'banner': {} + }, + 'bidId': '3150ccb55da321', + }, + ] + }; + const result = spec.interpretResponse({ 'body': bannerServerResponses }, request); 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 request = { + validBidRequests: [ + { + 'mediaTypes': { + 'banner': { + 'sizes': [728, 90] + } + }, + 'bidId': '3150ccb55da321', + }, + ] }; - - const result = spec.interpretResponse({'body': [target]}, request); + const result = spec.interpretResponse({ 'body': bannerServerResponses }, 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 response = [ + { + 'id': 'e5b10774-32bf-4931-85ee-05095e8cff21', + 'bidder_code': 'bridgewell', + 'width': 300, + 'height': 250, + 'mediaType': 'banner', + 'ad': '
test 300x250
', + 'ttl': 360, + 'netRevenue': true, + 'currency': 'NTD' + }, + ]; - const result = spec.interpretResponse({'body': [target]}, request); + const result = spec.interpretResponse({ 'body': response }, bannerBidRequests); 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([]); + const response = [ + { + 'id': 'e5b10774-32bf-4931-85ee-05095e8cff21', + 'bidder_code': 'bridgewell', + 'cpm': 5.0, + 'mediaType': 'banner', + 'ad': '
test 300x250
', + 'ttl': 360, + 'netRevenue': true, + 'currency': 'NTD' + }, + ]; + + const result = spec.interpretResponse({ 'body': response }, bannerBidRequests); + 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 response = [ + { + '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); + const result = spec.interpretResponse({ 'body': response }, bannerBidRequests); 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 response = [ + { + 'id': 'e5b10774-32bf-4931-85ee-05095e8cff21', + 'bidder_code': 'bridgewell', + 'cpm': 5.0, + 'width': 300, + 'height': 250, + 'mediaType': 'banner', + 'ad': '
test 300x250
', + 'ttl': 360, + 'currency': 'NTD' + }, + ]; - const result = spec.interpretResponse({'body': [target]}, request); + const result = spec.interpretResponse({ 'body': response }, bannerBidRequests); 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 response = [ + { + '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, + }, + ]; - const result = spec.interpretResponse({'body': [target]}, request); + const result = spec.interpretResponse({ 'body': response }, bannerBidRequests); 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 response = [ + { + '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': response }, bannerBidRequests); + expect(result).to.deep.equal([]); + }); + + it('should give up bid if mediaType is not support', function () { + const responses = [ + { + 'id': 'e5b10774-32bf-4931-85ee-05095e8cff21', + 'bidder_code': 'bridgewell', + 'cpm': 5.0, + 'width': 300, + 'height': 250, + 'mediaType': 'superNiceAd', + 'ad': '
test 300x250
', + 'ttl': 360, + 'netRevenue': true, + 'currency': 'NTD' + }, + ]; - const result = spec.interpretResponse({'body': [target]}, request); + const result = spec.interpretResponse({ 'body': responses }, bannerBidRequests); 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 response = [ + { + 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', + 'bidder_code': 'bridgewell', + 'cpm': 7.0, + 'width': 1, + 'height': 1, + 'mediaType': 'native', + 'ttl': 400, + 'netRevenue': true, + 'currency': 'NTD' + }, + ]; - const result = spec.interpretResponse({'body': [target]}, request); + const result = spec.interpretResponse({ 'body': response }, nativeBidRequests); 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 + const response = [ + { + 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', + 'bidder_code': 'bridgewell', + 'cpm': 7.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'] }, - 'clickUrl': 'https://img.scupio.com/test-clickUrl', - 'clickTrackers': ['https://img.scupio.com/test-clickTracker'], - 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker'] + 'ttl': 400, + 'netRevenue': true, + 'currency': 'NTD' }, - 'ttl': 360, - 'netRevenue': true, - 'currency': 'NTD' - }; + ]; - const result = spec.interpretResponse({'body': [target]}, request); + const result = spec.interpretResponse({ 'body': response }, nativeBidRequests); 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 + const response = [ + { + 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', + 'bidder_code': 'bridgewell', + 'cpm': 7.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'] }, - 'clickUrl': 'https://img.scupio.com/test-clickUrl', - 'clickTrackers': ['https://img.scupio.com/test-clickTracker'], - 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker'] + 'ttl': 400, + 'netRevenue': true, + 'currency': 'NTD' }, - 'ttl': 360, - 'netRevenue': true, - 'currency': 'NTD' - }; + ]; - const result = spec.interpretResponse({'body': [target]}, request); + const result = spec.interpretResponse({ 'body': response }, nativeBidRequests); 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 + const response = [ + { + 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', + 'bidder_code': 'bridgewell', + 'cpm': 7.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'] }, - 'clickUrl': 'https://img.scupio.com/test-clickUrl', - 'clickTrackers': ['https://img.scupio.com/test-clickTracker'], - 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker'] + 'ttl': 400, + 'netRevenue': true, + 'currency': 'NTD' }, - 'ttl': 360, - 'netRevenue': true, - 'currency': 'NTD' - }; + ]; - const result = spec.interpretResponse({'body': [target]}, request); + const result = spec.interpretResponse({ 'body': response }, nativeBidRequests); expect(result).to.deep.equal([]); + }); - it('should give up bid if native image url is missing', function () { - let target = { + it('should give up bid if native image url is missing', function () { + const response = [ + { 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', 'bidder_code': 'bridgewell', - 'cpm': 5.0, + 'cpm': 7.0, 'width': 1, 'height': 1, 'mediaType': 'native', @@ -736,429 +581,639 @@ describe('bridgewellBidAdapter', function () { 'clickTrackers': ['https://img.scupio.com/test-clickTracker'], 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker'] }, - 'ttl': 360, + 'ttl': 400, 'netRevenue': true, 'currency': 'NTD' - }; + }, + ]; - const result = spec.interpretResponse({'body': [target]}, request); - expect(result).to.deep.equal([]); - }); + const result = spec.interpretResponse({ 'body': response }, nativeBidRequests); + 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 + const response = [ + { + 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', + 'bidder_code': 'bridgewell', + 'cpm': 7.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'] }, - 'clickUrl': 'https://img.scupio.com/test-clickUrl', - 'clickTrackers': ['https://img.scupio.com/test-clickTracker'], - 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker'] + 'ttl': 400, + 'netRevenue': true, + 'currency': 'NTD' }, - 'ttl': 360, - 'netRevenue': true, - 'currency': 'NTD' - }; + ]; - const result = spec.interpretResponse({'body': [target]}, request); + const result = spec.interpretResponse({ 'body': response }, nativeBidRequests); 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 + it('should give up bid if native image is empty', function () { + const response = [ + { + 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', + 'bidder_code': 'bridgewell', + 'cpm': 7.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'] }, - 'clickUrl': 'https://img.scupio.com/test-clickUrl', - 'clickTrackers': ['https://img.scupio.com/test-clickTracker'], - 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker'] + 'ttl': 400, + 'netRevenue': true, + 'currency': 'NTD' }, - 'ttl': 360, - 'netRevenue': true, - 'currency': 'NTD' - }; + ]; - const result = spec.interpretResponse({'body': [target]}, request); + const result = spec.interpretResponse({ 'body': response }, nativeBidRequests); 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 + it('should give up bid if native image sizes is missing', function () { + const response = [ + { + 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', + 'bidder_code': 'bridgewell', + 'cpm': 7.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'] }, - 'clickUrl': 'https://img.scupio.com/test-clickUrl', - 'clickTrackers': ['https://img.scupio.com/test-clickTracker'], - 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker'] + 'ttl': 400, + 'netRevenue': true, + 'currency': 'NTD' }, - 'ttl': 360, - 'netRevenue': true, - 'currency': 'NTD' - }; + ]; - const result = spec.interpretResponse({'body': [target]}, request); + const result = spec.interpretResponse({ 'body': response }, nativeBidRequests); 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 + const response = [ + { + 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', + 'bidder_code': 'bridgewell', + 'cpm': 7.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'] }, - 'clickUrl': 'https://img.scupio.com/test-clickUrl', - 'clickTrackers': ['https://img.scupio.com/test-clickTracker'], - 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker'] + 'ttl': 400, + 'netRevenue': true, + 'currency': 'NTD' }, - 'ttl': 360, - 'netRevenue': true, - 'currency': 'NTD' - }; + ]; - const result = spec.interpretResponse({'body': [target]}, request); + const result = spec.interpretResponse({ 'body': response }, nativeBidRequests); 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 + const response = [ + { + 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', + 'bidder_code': 'bridgewell', + 'cpm': 7.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'] }, - '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': 400, + 'netRevenue': true, + 'currency': 'NTD' }, - 'ttl': 360, - 'netRevenue': true, - 'currency': 'NTD' - }; + ]; - const result = spec.interpretResponse({'body': [target]}, request); + const result = spec.interpretResponse({ 'body': response }, nativeBidRequests); 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 + const response = [ + { + 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', + 'bidder_code': 'bridgewell', + 'cpm': 7.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'] }, - 'title': 'test-title', - 'sponsoredBy': 'test-sponsoredBy', - 'body': 'test-body', - 'icon': { - 'width': 50, - 'height': 50 + 'ttl': 400, + 'netRevenue': true, + 'currency': 'NTD' + }, + ]; + + const result = spec.interpretResponse({ 'body': response }, nativeBidRequests); + expect(result).to.deep.equal([]); + }); + + it('should give up bid if native icon sizes is missing', function () { + const response = [ + { + 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', + 'bidder_code': 'bridgewell', + 'cpm': 7.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'] }, - 'clickUrl': 'https://img.scupio.com/test-clickUrl', - 'clickTrackers': ['https://img.scupio.com/test-clickTracker'], - 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker'] + 'ttl': 400, + 'netRevenue': true, + 'currency': 'NTD' }, - 'ttl': 360, - 'netRevenue': true, - 'currency': 'NTD' - }; + ]; - const result = spec.interpretResponse({'body': [target]}, request); + const result = spec.interpretResponse({ 'body': response }, nativeBidRequests); 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 + it('should give up bid if native clickUrl is missing', function () { + const response = [ + { + 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', + 'bidder_code': 'bridgewell', + 'cpm': 7.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'] }, - 'title': 'test-title', - 'sponsoredBy': 'test-sponsoredBy', - 'body': 'test-body', - 'icon': { - 'url': 'https://img.scupio.com/test/test-icon.jpg' + 'ttl': 400, + 'netRevenue': true, + 'currency': 'NTD' + }, + ]; + + const result = spec.interpretResponse({ 'body': response }, nativeBidRequests); + expect(result).to.deep.equal([]); + }); + + it('should give up bid if native clickTrackers is missing', function () { + const response = [ + { + 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', + 'bidder_code': 'bridgewell', + 'cpm': 7.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': 400, + 'netRevenue': true, + 'currency': 'NTD' + }, + ]; + + const result = spec.interpretResponse({ 'body': response }, nativeBidRequests); + expect(result).to.deep.equal([]); + }); + + it('should give up bid if native clickTrackers is empty', function () { + const response = [ + { + 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', + 'bidder_code': 'bridgewell', + 'cpm': 7.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'] }, - 'clickUrl': 'https://img.scupio.com/test-clickUrl', - 'clickTrackers': ['https://img.scupio.com/test-clickTracker'], - 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker'] + 'ttl': 400, + 'netRevenue': true, + 'currency': 'NTD' }, - 'ttl': 360, - 'netRevenue': true, - 'currency': 'NTD' - }; + ]; - const result = spec.interpretResponse({'body': [target]}, request); + const result = spec.interpretResponse({ 'body': response }, nativeBidRequests); 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 + it('should give up bid if native impressionTrackers is missing', function () { + const response = [ + { + 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', + 'bidder_code': 'bridgewell', + 'cpm': 7.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'], }, - 'clickTrackers': ['https://img.scupio.com/test-clickTracker'], - 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker'] + 'ttl': 400, + 'netRevenue': true, + 'currency': 'NTD' }, - 'ttl': 360, - 'netRevenue': true, - 'currency': 'NTD' - }; + ]; - const result = spec.interpretResponse({'body': [target]}, request); + const result = spec.interpretResponse({ 'body': response }, nativeBidRequests); 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 + it('should give up bid if native impressionTrackers is empty', function () { + const response = [ + { + 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', + 'bidder_code': 'bridgewell', + 'cpm': 7.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': [] }, - 'clickUrl': 'https://img.scupio.com/test-clickUrl', - 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker'] + 'ttl': 400, + 'netRevenue': true, + 'currency': 'NTD' }, - 'ttl': 360, - 'netRevenue': true, - 'currency': 'NTD' - }; + ]; - const result = spec.interpretResponse({'body': [target]}, request); + const result = spec.interpretResponse({ 'body': response }, nativeBidRequests); 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 + it('should contain every request bid id in responses', function () { + const request = { + validBidRequests: [ + { + 'mediaTypes': { + 'banner': { + 'sizes': [300, 250] + } + }, + 'bidId': '3150ccb55da321', }, - 'clickUrl': 'https://img.scupio.com/test-clickUrl', - 'clickTrackers': [], - 'impressionTrackers': ['https://img.scupio.com/test-impressionTracker'] - }, - 'ttl': 360, + { + 'mediaTypes': { + 'banner': { + 'sizes': [300, 250] + } + }, + 'bidId': '3150ccb55da322', + } + ], + }; + const response = [{ + 'id': '0cd250f4-f40e-4a78-90f5-5168eb0a97e9', + 'bidder_code': 'bridgewell', + 'cpm': 7.0, + 'width': 300, + 'height': 250, + 'mediaType': 'banner', + 'ad': '
test 300x250
', + 'ttl': 400, 'netRevenue': true, 'currency': 'NTD' - }; + }, { + 'id': '8a740063-6820-45e4-b01f-34ce9b38e858', + 'bidder_code': 'bridgewell', + 'cpm': 7.0, + 'width': 300, + 'height': 250, + 'mediaType': 'banner', + 'ad': '
test 300x250
', + 'ttl': 400, + 'netRevenue': true, + 'currency': 'NTD' + }]; + const result = spec.interpretResponse({ 'body': response }, request); + let actualBidId = result.map(obj => obj.requestId); + let expectedBidId = ['3150ccb55da321', '3150ccb55da322']; - const result = spec.interpretResponse({'body': [target]}, request); - expect(result).to.deep.equal([]); + expect(actualBidId).to.include(expectedBidId[0]).and.to.include(expectedBidId[1]); }); - 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 + it('should have 2 consumed responses when two requests with same sizes are given', function () { + const request = { + validBidRequests: [ + { + 'mediaTypes': { + 'banner': { + 'sizes': [300, 250] + } + }, + 'bidId': '3150ccb55da321', }, - 'clickUrl': 'https://img.scupio.com/test-clickUrl', - 'clickTrackers': ['https://img.scupio.com/test-clickTracker'] - }, - 'ttl': 360, + { + 'mediaTypes': { + 'banner': { + 'sizes': [300, 250] + } + }, + 'bidId': '3150ccb55da322', + } + ], + }; + const response = [{ + 'id': '0cd250f4-f40e-4a78-90f5-5168eb0a97e9', + 'bidder_code': 'bridgewell', + 'cpm': 7.0, + 'width': 300, + 'height': 250, + 'mediaType': 'banner', + 'ad': '
test 300x250
', + 'ttl': 400, 'netRevenue': true, 'currency': 'NTD' + }, { + 'id': '8a740063-6820-45e4-b01f-34ce9b38e858', + 'bidder_code': 'bridgewell', + 'cpm': 7.0, + 'width': 300, + 'height': 250, + 'mediaType': 'banner', + 'ad': '
test 300x250
', + 'ttl': 400, + 'netRevenue': true, + 'currency': 'NTD' + }]; + const reducer = function(accumulator, currentValue) { + if (currentValue.consumed) accumulator++; + return accumulator; }; - const result = spec.interpretResponse({'body': [target]}, request); - expect(result).to.deep.equal([]); + spec.interpretResponse({ 'body': response }, request); + expect(response.reduce(reducer, 0)).to.equal(2); }); - 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 + it('should use adUnitCode to build bidResponses', function () { + const request = { + validBidRequests: [ + { + 'adUnitCode': 'div-gpt-ad-1564632520056-0', + 'bidId': '3150ccb55da321', }, - 'clickUrl': 'https://img.scupio.com/test-clickUrl', - 'clickTrackers': ['https://img.scupio.com/test-clickTracker'], - 'impressionTrackers': [] - }, - 'ttl': 360, + { + 'adUnitCode': 'div-gpt-ad-1564632520056-1', + 'bidId': '3150ccb55da322', + } + ], + }; + const response = [{ + 'id': '0cd250f4-f40e-4a78-90f5-5168eb0a97e9', + 'bidder_code': 'bridgewell', + 'adUnitCode': 'div-gpt-ad-1564632520056-0', + 'cpm': 7.0, + 'width': 300, + 'height': 250, + 'mediaType': 'banner', + 'ad': '
test 300x250
', + 'ttl': 400, 'netRevenue': true, 'currency': 'NTD' - }; + }, { + 'id': '8a740063-6820-45e4-b01f-34ce9b38e858', + 'bidder_code': 'bridgewell', + 'adUnitCode': 'div-gpt-ad-1564632520056-1', + 'cpm': 7.0, + 'width': 300, + 'height': 250, + 'mediaType': 'banner', + 'ad': '
test 300x250
', + 'ttl': 400, + 'netRevenue': true, + 'currency': 'NTD' + }]; + const result = spec.interpretResponse({ 'body': response }, request); + let actualBidId = result.map(obj => obj.requestId); + let expectedBidId = ['3150ccb55da321', '3150ccb55da322']; - const result = spec.interpretResponse({'body': [target]}, request); - expect(result).to.deep.equal([]); + expect(actualBidId).to.include(expectedBidId[0]).and.to.include(expectedBidId[1]); }); - it('should give up bid if mediaType is not support', function () { - let target = { - 'id': '0e4048d3-5c74-4380-a21a-00ba35629f7d', + it('should use size to match when adUnitCode is empty string in server response', function () { + const request = { + validBidRequests: [ + { + 'mediaTypes': { + 'banner': { + 'sizes': [300, 250] + } + }, + 'adUnitCode': 'div-gpt-ad-1564632520056-0', + 'bidId': '3150ccb55da321', + }, + { + 'mediaTypes': { + 'banner': { + 'sizes': [300, 250] + } + }, + 'adUnitCode': 'div-gpt-ad-1564632520056-1', + 'bidId': '3150ccb55da322', + } + ], + }; + const response = [{ + 'id': '0cd250f4-f40e-4a78-90f5-5168eb0a97e9', 'bidder_code': 'bridgewell', - 'cpm': 5.0, - 'width': 1, - 'height': 1, - 'mediaType': 'superNiceAd', - 'ttl': 360, + 'adUnitCode': '', + 'cpm': 7.0, + 'width': 300, + 'height': 250, + 'mediaType': 'banner', + 'ad': '
test 300x250
', + 'ttl': 400, 'netRevenue': true, 'currency': 'NTD' - }; + }, { + 'id': '8a740063-6820-45e4-b01f-34ce9b38e858', + 'bidder_code': 'bridgewell', + 'adUnitCode': '', + 'cpm': 7.0, + 'width': 300, + 'height': 250, + 'mediaType': 'banner', + 'ad': '
test 300x250
', + 'ttl': 400, + 'netRevenue': true, + 'currency': 'NTD' + }]; + const result = spec.interpretResponse({ 'body': response }, request); + let actualBidId = result.map(obj => obj.requestId); + let expectedBidId = ['3150ccb55da321', '3150ccb55da322']; - const result = spec.interpretResponse({'body': [target]}, request); - expect(result).to.deep.equal([]); + expect(actualBidId).to.include(expectedBidId[0]).and.to.include(expectedBidId[1]); }); }); }); diff --git a/test/spec/modules/brightcomBidAdapter_spec.js b/test/spec/modules/brightcomBidAdapter_spec.js index 14ed4d3024d..6477e94d9d6 100644 --- a/test/spec/modules/brightcomBidAdapter_spec.js +++ b/test/spec/modules/brightcomBidAdapter_spec.js @@ -1,7 +1,7 @@ import { expect } from 'chai'; -import * as utils from 'src/utils'; -import { spec } from 'modules/brightcomBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; +import * as utils from 'src/utils.js'; +import { spec } from 'modules/brightcomBidAdapter.js'; +import { newBidder } from 'src/adapters/bidderFactory.js'; const URL = 'https://brightcombid.marphezis.com/hb'; diff --git a/test/spec/modules/britepoolIdSystem_spec.js b/test/spec/modules/britepoolIdSystem_spec.js index d7250eeb941..2c6dd234a90 100644 --- a/test/spec/modules/britepoolIdSystem_spec.js +++ b/test/spec/modules/britepoolIdSystem_spec.js @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import {britepoolIdSubmodule} from 'modules/britepoolIdSystem'; +import {britepoolIdSubmodule} from 'modules/britepoolIdSystem.js'; describe('BritePool Submodule', () => { const api_key = '1111'; diff --git a/test/spec/modules/bucksenseBidAdapter_spec.js b/test/spec/modules/bucksenseBidAdapter_spec.js index 17b5c3ceff5..f49a63d2003 100644 --- a/test/spec/modules/bucksenseBidAdapter_spec.js +++ b/test/spec/modules/bucksenseBidAdapter_spec.js @@ -1,5 +1,5 @@ import {expect} from 'chai'; -import {spec} from 'modules/bucksenseBidAdapter'; +import {spec} from 'modules/bucksenseBidAdapter.js'; describe('Bucksense Adapter', function() { const BIDDER_CODE = 'bucksense'; @@ -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 @@ -104,12 +104,12 @@ describe('Bucksense Adapter', function() { beforeEach(function() { serverRequest = { 'method': 'POST', - 'url': 'https://prebid.bksn.se:445/prebidjs/', + 'url': 'https://prebid.bksn.se/prebidjs/', 'data': { '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/buzzoolaBidAdapter_spec.js b/test/spec/modules/buzzoolaBidAdapter_spec.js index e6f22d1da20..8a04999219d 100644 --- a/test/spec/modules/buzzoolaBidAdapter_spec.js +++ b/test/spec/modules/buzzoolaBidAdapter_spec.js @@ -1,8 +1,8 @@ import {expect} from 'chai'; -import {spec} from 'modules/buzzoolaBidAdapter'; -import {newBidder} from 'src/adapters/bidderFactory'; -import {executeRenderer, Renderer} from '../../../src/Renderer'; -import {deepClone} from '../../../src/utils'; +import {spec} from 'modules/buzzoolaBidAdapter.js'; +import {newBidder} from 'src/adapters/bidderFactory.js'; +import {executeRenderer, Renderer} from '../../../src/Renderer.js'; +import {deepClone} from '../../../src/utils.js'; const ENDPOINT = 'https://exchange.buzzoola.com/ssp/prebidjs'; const RENDERER_SRC = 'https://tube.buzzoola.com/new/build/buzzlibrary.js'; diff --git a/test/spec/modules/byplayBidAdapter_spec.js b/test/spec/modules/byplayBidAdapter_spec.js new file mode 100644 index 00000000000..57aad403c4e --- /dev/null +++ b/test/spec/modules/byplayBidAdapter_spec.js @@ -0,0 +1,93 @@ +import { expect } from 'chai'; +import { spec } from 'modules/byplayBidAdapter.js'; +import { newBidder } from 'src/adapters/bidderFactory.js'; +import * as bidderFactory from 'src/adapters/bidderFactory.js'; + +describe('byplayBidAdapter', () => { + describe('isBidRequestValid', () => { + describe('exist sectionId', () => { + const bid = { + 'bidder': 'byplay', + 'params': { + 'sectionId': '11111' + }, + }; + + it('should equal true', () => { + expect(spec.isBidRequestValid(bid)).to.equal(true); + }); + }); + + describe('not exist sectionId', () => { + const bid = { + 'bidder': 'byplay', + 'params': { + }, + }; + + it('should equal false', () => { + expect(spec.isBidRequestValid(bid)).to.equal(false); + }); + }); + }); + + describe('buildRequests', () => { + const bids = [ + { + 'bidder': 'byplay', + 'bidId': '1234', + 'params': { + 'sectionId': '1111' + }, + } + ]; + + const request = spec.buildRequests(bids); + + it('should return POST', () => { + expect(request[0].method).to.equal('POST'); + }); + + it('should return data', () => { + expect(request[0].data).to.equal('{"requestId":"1234","sectionId":"1111"}'); + }); + }); + + describe('interpretResponse', () => { + const serverResponse = { + body: { + 'cpm': 1500, + 'width': 320, + 'height': 180, + 'netRevenue': true, + 'creativeId': '1', + 'requestId': '209c1fb5ad88f5', + 'vastXml': '' + } + }; + + const bidderRequest = { + 'method': 'GET', + 'url': 'https://tasp0g98f2.execute-api.ap-northeast-1.amazonaws.com/v1/bidder', + 'data': '{"requestId":"209c1fb5ad88f5","sectionId":7986}' + }; + + const result = spec.interpretResponse(serverResponse, bidderRequest); + + it('should return Array', () => { + expect(Array.isArray(result)).to.equal(true); + }); + + it('should get the correct bid response', () => { + expect(result[0].cpm).to.equal(1500); + expect(result[0].creativeId).to.equal('1'); + expect(result[0].width).to.equal(320); + expect(result[0].height).to.equal(180); + expect(result[0].mediaType).to.equal('video'); + expect(result[0].netRevenue).to.equal(true); + expect(result[0].requestId).to.equal('209c1fb5ad88f5'); + expect(result[0].ttl).to.equal(3000); + expect(result[0].vastXml).to.equal(''); + }); + }); +}); diff --git a/test/spec/modules/c1xBidAdapter_spec.js b/test/spec/modules/c1xBidAdapter_spec.js index 268ad46d0ce..00741abda7a 100644 --- a/test/spec/modules/c1xBidAdapter_spec.js +++ b/test/spec/modules/c1xBidAdapter_spec.js @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import { c1xAdapter } from 'modules/c1xBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; +import { c1xAdapter } from 'modules/c1xBidAdapter.js'; +import { newBidder } from 'src/adapters/bidderFactory.js'; const ENDPOINT = 'https://ht.c1exchange.com/ht'; const BIDDER_CODE = 'c1x'; @@ -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/categoryTranslation_spec.js b/test/spec/modules/categoryTranslation_spec.js index 17cc07269b0..555fe3d6357 100644 --- a/test/spec/modules/categoryTranslation_spec.js +++ b/test/spec/modules/categoryTranslation_spec.js @@ -1,6 +1,6 @@ -import { getAdserverCategoryHook, initTranslation } from 'modules/categoryTranslation'; -import { config } from 'src/config'; -import * as utils from 'src/utils'; +import { getAdserverCategoryHook, initTranslation, storage } from 'modules/categoryTranslation.js'; +import { config } from 'src/config.js'; +import * as utils from 'src/utils.js'; import { expect } from 'chai'; describe('category translation', function () { @@ -9,7 +9,7 @@ describe('category translation', function () { beforeEach(function () { fakeTranslationServer = sinon.fakeServer.create(); - getLocalStorageStub = sinon.stub(utils, 'getDataFromLocalStorage'); + getLocalStorageStub = sinon.stub(storage, 'getDataFromLocalStorage'); }); afterEach(function() { diff --git a/test/spec/modules/ccxBidAdapter_spec.js b/test/spec/modules/ccxBidAdapter_spec.js index a89a0402a97..f14612629b1 100644 --- a/test/spec/modules/ccxBidAdapter_spec.js +++ b/test/spec/modules/ccxBidAdapter_spec.js @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import { spec } from 'modules/ccxBidAdapter'; -import * as utils from 'src/utils'; +import { spec } from 'modules/ccxBidAdapter.js'; +import * as utils from 'src/utils.js'; describe('ccxAdapter', function () { let bids = [ @@ -248,6 +248,31 @@ describe('ccxAdapter', function () { }); }); + describe('GDPR conformity', function () { + it('should transmit correct data', function () { + let bidsClone = utils.deepClone(bids); + let gdprConsent = { + consentString: 'awefasdfwefasdfasd', + gdprApplies: true + }; + let response = spec.buildRequests(bidsClone, {'bids': bidsClone, 'gdprConsent': gdprConsent}); + let data = JSON.parse(response.data); + + expect(data.regs.ext.gdpr).to.equal(1); + expect(data.user.ext.consent).to.equal('awefasdfwefasdfasd'); + }); + }); + + describe('GDPR absence conformity', function () { + it('should transmit correct data', function () { + let response = spec.buildRequests(bids, {bids}); + let data = JSON.parse(response.data); + + expect(data.regs).to.be.undefined; + expect(data.user).to.be.undefined; + }); + }); + let response = { id: '0b9de793-8eda-481e-a548-c187d58b28d9', seatbid: [ diff --git a/test/spec/modules/cedatoBidAdapter_spec.js b/test/spec/modules/cedatoBidAdapter_spec.js index 0cf6d14147a..a7f4875afff 100644 --- a/test/spec/modules/cedatoBidAdapter_spec.js +++ b/test/spec/modules/cedatoBidAdapter_spec.js @@ -1,5 +1,5 @@ import {expect} from 'chai'; -import {spec} from 'modules/cedatoBidAdapter'; +import {spec} from 'modules/cedatoBidAdapter.js'; describe('the cedato adapter', function () { function getValidBidObject() { @@ -50,12 +50,12 @@ describe('the cedato adapter', function () { }); it('should build a very basic request', function() { - var request = spec.buildRequests([bid], bidRequestObj); + var [request] = spec.buildRequests([bid], bidRequestObj); expect(request.method).to.equal('POST'); }); it('should pass gdpr and usp strings to server', function() { - var request = spec.buildRequests([bid], bidRequestObj); + var [request] = spec.buildRequests([bid], bidRequestObj); var payload = JSON.parse(request.data); expect(payload.gdpr_consent).to.not.be.undefined; expect(payload.gdpr_consent.consent_string).to.equal(bidRequestObj.gdprConsent.consentString); diff --git a/test/spec/modules/cleanmedianetBidAdapter_spec.js b/test/spec/modules/cleanmedianetBidAdapter_spec.js index 09f76806fd7..5438f6c8701 100644 --- a/test/spec/modules/cleanmedianetBidAdapter_spec.js +++ b/test/spec/modules/cleanmedianetBidAdapter_spec.js @@ -1,15 +1,13 @@ -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'; +import {expect} from 'chai'; +import {spec, helper} from 'modules/cleanmedianetBidAdapter.js'; +import * as utils from 'src/utils.js'; +import {newBidder} from '../../../src/adapters/bidderFactory.js'; 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() { +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 ); @@ -103,7 +101,7 @@ describe('CleanmedianetAdapter', function() { }, sizes: [[300, 250], [300, 600]], transactionId: 'a123456789', - refererInfo: { referer: 'http://examplereferer.com' }, + refererInfo: { referer: 'https://examplereferer.com' }, gdprConsent: { consentString: 'some string', gdprApplies: true @@ -131,15 +129,12 @@ describe('CleanmedianetAdapter', function() { }); 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 bidRequest2 = utils.deepClone(bidRequest); + bidRequest2.refererInfo.referer = 'https://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.site.page).to.equal('https://www.test.com/page.html'); + expect(response.data.site.ref).to.equal('https://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); @@ -173,7 +168,6 @@ describe('CleanmedianetAdapter', function() { expect(response.data.imp[0].bidfloor).to.equal( bidRequestWithBidfloorEquals1.params.bidfloor ); - stub.restore(); }); it('builds request banner object correctly', function() { @@ -290,7 +284,7 @@ describe('CleanmedianetAdapter', function() { sizes: [[300, 250], [300, 600]], transactionId: 'a123456789', bidId: '111', - refererInfo: { referer: 'http://examplereferer.com' } + refererInfo: { referer: 'https://examplereferer.com' } }; const videoBidRequest = { @@ -305,7 +299,7 @@ describe('CleanmedianetAdapter', function() { sizes: [[300, 250], [300, 600]], transactionId: 'a123456789', bidId: '111', - refererInfo: { referer: 'http://examplereferer.com' } + refererInfo: { referer: 'https://examplereferer.com' } }; const rtbResponse = { @@ -329,7 +323,7 @@ describe('CleanmedianetAdapter', function() { 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}', + 'https://bidder.cleanmediaads.com/pix/monitoring/win_notice/imp_5b05b9fde4b09084267a556f/im.gif?r=imp_5b05b9fde4b09084267a556f&i=1&a=579ef31bfa788b9d2000d562&b=0', adm: '', adomain: ['aaa.com'], @@ -339,7 +333,7 @@ describe('CleanmedianetAdapter', function() { h: 600, w: 120, ext: { - vast_url: 'http://my.vast.com', + vast_url: 'https://my.vast.com', utrk: [{ type: 'iframe', url: '//p.partner1.io/user/sync/1' }] } } @@ -355,7 +349,7 @@ describe('CleanmedianetAdapter', function() { 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}', + 'https://bidder.cleanmediaads.com/pix/monitoring/win_notice/imp_5b05b9fde4b09084267a556f/im.gif?r=imp_5b05b9fde4b09084267a556f&i=1&a=579ef31bfa788b9d2000d562&b=0', adm: ' ', adomain: ['bbb.com'], @@ -400,7 +394,7 @@ describe('CleanmedianetAdapter', function() { 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.ttl).to.equal(360); expect(ad0.creativeId).to.equal(rtbResponse.seatbid[1].bid[0].crid); expect(ad0.netRevenue).to.equal(true); expect(ad0.currency).to.equal( @@ -424,7 +418,7 @@ describe('CleanmedianetAdapter', function() { 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.ttl).to.equal(360); expect(ad0.creativeId).to.equal(rtbResponse.seatbid[0].bid[0].crid); expect(ad0.netRevenue).to.equal(true); expect(ad0.currency).to.equal( @@ -477,7 +471,7 @@ describe('CleanmedianetAdapter', function() { 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}', + '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', 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', @@ -508,7 +502,7 @@ describe('CleanmedianetAdapter', function() { ] } }; - const videoRequest = deepClone(videoBidRequest); + const videoRequest = utils.deepClone(videoBidRequest); videoRequest.mediaTypes.video.context = 'outstream'; const result = spec.interpretResponse( { body: videoResponse }, @@ -533,7 +527,7 @@ describe('CleanmedianetAdapter', function() { 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}', + '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', 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', diff --git a/test/spec/modules/clickforceBidAdapter_spec.js b/test/spec/modules/clickforceBidAdapter_spec.js index 3d4fc70c057..dad00f94641 100644 --- a/test/spec/modules/clickforceBidAdapter_spec.js +++ b/test/spec/modules/clickforceBidAdapter_spec.js @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import { spec } from 'modules/clickforceBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; +import { spec } from 'modules/clickforceBidAdapter.js'; +import { newBidder } from 'src/adapters/bidderFactory.js'; describe('ClickforceAdapter', function () { const adapter = newBidder(spec); @@ -175,7 +175,7 @@ describe('ClickforceAdapter', function () { } let userSync = spec.getUserSyncs(syncOptions); expect(userSync[0].type).to.equal('iframe'); - expect(userSync[0].url).to.equal('https://cdn.doublemax.net/js/capmapping.htm'); + expect(userSync[0].url).to.equal('https://cdn.holmesmind.com/js/capmapping.htm'); }); it('should register type is image', function () { @@ -184,7 +184,7 @@ describe('ClickforceAdapter', function () { } let userSync = spec.getUserSyncs(syncOptions); expect(userSync[0].type).to.equal('image'); - expect(userSync[0].url).to.equal('https://c.doublemax.net/cm'); + expect(userSync[0].url).to.equal('https://c.holmesmind.com/cm'); }); }); }); diff --git a/test/spec/modules/clicktripzBidAdapter_spec.js b/test/spec/modules/clicktripzBidAdapter_spec.js new file mode 100644 index 00000000000..fed94811c4e --- /dev/null +++ b/test/spec/modules/clicktripzBidAdapter_spec.js @@ -0,0 +1,152 @@ +import {expect} from 'chai'; +import {spec} from 'modules/clicktripzBidAdapter.js'; + +const ENDPOINT_URL = 'https://www.clicktripz.com/x/prebid/v1'; + +describe('clicktripzBidAdapter', function () { + describe('isBidRequestValid', function () { + let bid = { + 'bidder': 'clicktripz', + 'params': { + placementId: 'testPlacementId', + siteId: 'testSiteId' + }, + 'adUnitCode': 'adunit-code', + 'sizes': [ + [300, 250] + ], + 'bidId': '1234asdf1234', + 'bidderRequestId': '1234asdf1234asdf', + 'auctionId': '61466567-d482-4a16-96f0-fe5f25ffbdf120' + }; + + let bid2 = { + 'bidder': 'clicktripz', + 'params': { + placementId: 'testPlacementId' + }, + 'adUnitCode': 'adunit-code', + 'sizes': [ + [300, 250] + ], + 'bidId': '1234asdf1234', + 'bidderRequestId': '1234asdf1234asdf', + 'auctionId': '61466567-d482-4a16-96f0-fe5f25ffbdf120' + }; + + let bid3 = { + 'bidder': 'clicktripz', + 'params': { + siteId: 'testSiteId' + }, + 'adUnitCode': 'adunit-code', + 'sizes': [ + [300, 250] + ], + 'bidId': '1234asdf1234', + 'bidderRequestId': '1234asdf1234asdf', + 'auctionId': '61466567-d482-4a16-96f0-fe5f25ffbdf120' + }; + + 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 found', function () { + expect(spec.isBidRequestValid(bid2)).to.equal(false); + expect(spec.isBidRequestValid(bid3)).to.equal(false); + }); + }); + + describe('buildRequests', function () { + let validBidRequests = [{ + 'bidder': 'clicktripz', + 'params': { + placementId: 'testPlacementId', + siteId: 'testSiteId' + }, + 'sizes': [ + [300, 250], + [300, 300] + ], + 'bidId': '23beaa6af6cdde', + 'bidderRequestId': '19c0c1efdf37e7', + 'auctionId': '61466567-d482-4a16-96f0-fe5f25ffbdf1', + }, { + 'bidder': 'clicktripz', + 'params': { + placementId: 'testPlacementId2', + siteId: 'testSiteId2' + }, + 'sizes': [ + [300, 250] + ], + 'bidId': '25beaa6af6cdde', + 'bidderRequestId': '19c0c1efdf37e7', + 'auctionId': '61466567-d482-4a16-96f0-fe5f25ffbdf1', + }]; + + const request = spec.buildRequests(validBidRequests); + it('sends bid request to our endpoint via POST', function () { + expect(request.method).to.equal('POST'); + }); + it('sends bid request to our endpoint via POST', function () { + expect(request.method).to.equal('POST'); + }); + + it('sends bid request to our endpoint at the correct URL', function () { + expect(request.url).to.equal(ENDPOINT_URL); + }); + it('sends bid request to our endpoint at the correct URL', function () { + expect(request.url).to.equal(ENDPOINT_URL); + }); + + it('transforms sizes into an array of strings. Pairs of concatenated sizes joined with an x', function () { + expect(request.data[0].sizes.toString()).to.equal('300x250,300x300'); + }); + it('transforms sizes into an array of strings. Pairs of concatenated sizes joined with an x', function () { + expect(request.data[1].sizes.toString()).to.equal('300x250'); + }); + + it('includes bidId, siteId, and placementId in payload', function () { + expect(request.data[0].bidId).to.equal('23beaa6af6cdde'); + expect(request.data[0].siteId).to.equal('testSiteId'); + expect(request.data[0].placementId).to.equal('testPlacementId'); + }); + it('includes bidId, siteId, and placementId in payload', function () { + expect(request.data[1].bidId).to.equal('25beaa6af6cdde'); + expect(request.data[1].siteId).to.equal('testSiteId2'); + expect(request.data[1].placementId).to.equal('testPlacementId2'); + }); + }); + + describe('interpretResponse', function () { + let serverResponse = { + body: [{ + 'bidId': 'bid-request-id', + 'ttl': 120, + 'netRevenue': true, + 'size': '300x200', + 'currency': 'USD', + 'adUrl': 'https://www.clicktripz.com/n3/crane/v0/render?t=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJwYXlsb2FkIjoiaHR0cHM6XC9cL3d3dy5jbGlja3RyaXB6LmNvbVwvY2xpY2sucGhwP2NhbXBhaWduSUQ9MTkxNTYmcHJlQ2hlY2tlZD0xJnB1Ymxpc2hlcklEPTM2MCZzZWFyY2hLZXk9N2M5MzQ0NzhlM2M1NTc3Y2EyN2ZmN2Y1NTg5N2NkMzkmc2VhcmNoRGlzcGxheVR5cGU9MSZkaXNwbGF5VHlwZT00JmNyZWF0aXZlVHlwZT1zaW5nbGUmaXNQb3BVbmRlcj0wJnBvc2l0aW9uPTEmdHlwZT0xJmNpdHk9TWFkcmlkJTJDK1NwYWluJmNoZWNrSW5EYXRlPTAzJTJGMDElMkYyMDIwJmNoZWNrT3V0RGF0ZT0wMyUyRjA1JTJGMjAyMCZndWVzdHM9MiZyb29tcz0xIn0.WBDGYr1qfkSvOuK02VpMW3iAua1E02jjDGDViFc2kaE', + 'creativeId': '25ef9876abc5681f153', + 'cpm': 50 + }] + }; + it('should get the correct bid response', function () { + let expectedResponse = [{ + 'requestId': 'bid-request-id', + 'cpm': 50, + 'netRevenue': true, + 'width': '300', + 'height': '200', + 'creativeId': '25ef9876abc5681f153', + 'currency': 'USD', + 'adUrl': 'https://www.clicktripz.com/n3/crane/v0/render?t=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJwYXlsb2FkIjoiaHR0cHM6XC9cL3d3dy5jbGlja3RyaXB6LmNvbVwvY2xpY2sucGhwP2NhbXBhaWduSUQ9MTkxNTYmcHJlQ2hlY2tlZD0xJnB1Ymxpc2hlcklEPTM2MCZzZWFyY2hLZXk9N2M5MzQ0NzhlM2M1NTc3Y2EyN2ZmN2Y1NTg5N2NkMzkmc2VhcmNoRGlzcGxheVR5cGU9MSZkaXNwbGF5VHlwZT00JmNyZWF0aXZlVHlwZT1zaW5nbGUmaXNQb3BVbmRlcj0wJnBvc2l0aW9uPTEmdHlwZT0xJmNpdHk9TWFkcmlkJTJDK1NwYWluJmNoZWNrSW5EYXRlPTAzJTJGMDElMkYyMDIwJmNoZWNrT3V0RGF0ZT0wMyUyRjA1JTJGMjAyMCZndWVzdHM9MiZyb29tcz0xIn0.WBDGYr1qfkSvOuK02VpMW3iAua1E02jjDGDViFc2kaE', + 'ttl': 120 + }]; + let result = spec.interpretResponse(serverResponse); + expect(result).to.deep.equal(expectedResponse); + }); + }); +}); diff --git a/test/spec/modules/coinzillaBidAdapter_spec.js b/test/spec/modules/coinzillaBidAdapter_spec.js index 7a0c745d57d..a3438b80126 100644 --- a/test/spec/modules/coinzillaBidAdapter_spec.js +++ b/test/spec/modules/coinzillaBidAdapter_spec.js @@ -1,6 +1,6 @@ import {assert, expect} from 'chai'; -import {spec} from 'modules/coinzillaBidAdapter'; -import {newBidder} from 'src/adapters/bidderFactory'; +import {spec} from 'modules/coinzillaBidAdapter.js'; +import {newBidder} from 'src/adapters/bidderFactory.js'; const ENDPOINT_URL = 'https://request.czilladx.com/serve/request.php'; @@ -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 04c819992cd..0ab83a8024b 100644 --- a/test/spec/modules/collectcentBidAdapter_spec.js +++ b/test/spec/modules/collectcentBidAdapter_spec.js @@ -1,5 +1,5 @@ import {expect} from 'chai'; -import {spec} from '../../../modules/collectcentBidAdapter'; +import {spec} from '../../../modules/collectcentBidAdapter.js'; describe('Collectcent', function () { let bid = { @@ -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 index 5a8678e866c..4e80c6b1d9d 100644 --- a/test/spec/modules/colombiaBidAdapter_spec.js +++ b/test/spec/modules/colombiaBidAdapter_spec.js @@ -86,7 +86,7 @@ describe('colombiaBidAdapter', function() { let bidRequest = [ { 'method': 'POST', - 'url': ENDPOINT, + 'url': 'https://ade.clmbtech.com/cde/prebid.htm', 'data': { 'v': 'hb1', 'p': '307466', @@ -96,23 +96,23 @@ describe('colombiaBidAdapter', function() { 'r': 'http%3A%2F%2Flocalhost%3A9876%2F%3Fid%3D74552836', 'uid': '23beaa6af6cdde', 't': 'i', - 'd': HOST_NAME } } ]; let serverResponse = { body: { - 'ad': '
This is test case
', + 'ad': '
This is test case for colombia adapter
', 'cpm': 3.14, 'creativeId': '6b958110-612c-4b03-b6a9-7436c9f746dc-1sk24', 'currency': 'USD', - 'statusMessage': 'Bid available', 'uid': '23beaa6af6cdde', - 'width': 300, - 'height': 250, + 'width': 728, + 'height': 90, 'netRevenue': true, - 'ttl': 600 + 'ttl': 600, + 'dealid': '', + 'referrer': 'http%3A%2F%2Flocalhost%3A9876%2F%3Fid%3D74552836' } }; @@ -120,26 +120,26 @@ describe('colombiaBidAdapter', function() { let expectedResponse = [{ 'requestId': '23beaa6af6cdde', 'cpm': 3.14, - 'width': 300, - 'height': 250, + 'width': 728, + 'height': 90, 'creativeId': '6b958110-612c-4b03-b6a9-7436c9f746dc-1sk24', 'dealId': '', 'currency': 'USD', 'netRevenue': true, - 'ttl': 3000, - 'referrer': '', - 'ad': '
This is test case
' + 'ttl': 300, + 'referrer': 'http%3A%2F%2Flocalhost%3A9876%2F%3Fid%3D74552836', + 'ad': '
This is test case for colombia adapter
' }]; let result = spec.interpretResponse(serverResponse, bidRequest[0]); - expect(Object.keys(result)).to.deep.equal(Object.keys(expectedResponse)); + expect(Object.keys(result[0])).to.deep.equal(Object.keys(expectedResponse[0])); }); it('handles empty bid response', function () { let response = { body: { - 'uid': '2c0b634db95a01', + 'uid': '23beaa6af6cdde', 'height': 0, - 'crid': '', + 'creativeId': '', 'statusMessage': 'Bid returned empty or error response', 'width': 0, 'cpm': 0 diff --git a/test/spec/modules/colossussspBidAdapter_spec.js b/test/spec/modules/colossussspBidAdapter_spec.js index 9ed2dbe6e6b..df9bdcbd47b 100644 --- a/test/spec/modules/colossussspBidAdapter_spec.js +++ b/test/spec/modules/colossussspBidAdapter_spec.js @@ -1,5 +1,5 @@ import {expect} from 'chai'; -import {spec} from '../../../modules/colossussspBidAdapter'; +import {spec} from '../../../modules/colossussspBidAdapter.js'; describe('ColossussspAdapter', function () { let bid = { @@ -88,7 +88,7 @@ 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', 'schain'); + expect(placement).to.have.all.keys('placementId', 'eids', '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'); @@ -102,6 +102,36 @@ describe('ColossussspAdapter', function () { expect(data.placements).to.be.an('array').that.is.empty; }); }); + + describe('buildRequests with user ids', function () { + bid.userId = {} + bid.userId.britepoolid = 'britepoolid123'; + bid.userId.idl_env = 'idl_env123'; + bid.userId.tdid = 'tdid123'; + bid.userId.id5id = 'id5id123' + let serverRequest = spec.buildRequests([bid], bidderRequest); + it('Returns valid data if array of bids is valid', function () { + let data = serverRequest.data; + let placements = data['placements']; + expect(data).to.be.an('object'); + for (let i = 0; i < placements.length; i++) { + let placement = placements[i]; + expect(placement).to.have.property('eids') + expect(placement.eids).to.be.an('array') + expect(placement.eids.length).to.be.equal(4) + for (let index in placement.eids) { + let v = placement.eids[index]; + expect(v).to.have.all.keys('source', 'uids') + expect(v.source).to.be.oneOf(['britepool.com', 'identityLink', 'adserver.org', 'id5-sync.com']) + expect(v.uids).to.be.an('array'); + expect(v.uids.length).to.be.equal(1) + expect(v.uids[0]).to.have.property('id') + expect(v.uids[0].id).to.be.oneOf(['britepoolid123', 'idl_env123', 'tdid123', 'id5id123']) + } + } + }); + }); + describe('interpretResponse', function () { let resObject = { body: [ { diff --git a/test/spec/modules/connectadBidAdapter_spec.js b/test/spec/modules/connectadBidAdapter_spec.js new file mode 100644 index 00000000000..626018241c4 --- /dev/null +++ b/test/spec/modules/connectadBidAdapter_spec.js @@ -0,0 +1,453 @@ +import {expect} from 'chai'; +import {spec} from 'modules/connectadBidAdapter.js'; +import { config } from 'src/config.js'; +import {newBidder} from 'src/adapters/bidderFactory.js'; + +describe('ConnectAd Adapter', function () { + let bidRequests; + let bidderRequest; + let bidRequestsUserIds; + + beforeEach(function () { + bidRequests = [ + { + bidder: 'conntectad', + params: { + siteId: 123456, + networkId: 123456 + }, + adUnitCode: '/19968336/header-bid-tag-1', + mediaTypes: { + banner: { + sizes: [[300, 250], [300, 600]], + } + }, + bidId: '2f95c00074b931', + auctionId: 'e76cbb58-f3e1-4ad9-9f4c-718c1919d0df', + bidderRequestId: '1c56ad30b9b8ca8', + transactionId: 'e76cbb58-f3e1-4ad9-9f4c-718c1919d0df' + } + ]; + + bidRequestsUserIds = [{ + bidder: 'conntectad', + params: { + siteId: 123456, + networkId: 123456 + }, + adUnitCode: '/19968336/header-bid-tag-1', + mediaTypes: { + banner: { + sizes: [[300, 250], [300, 600]], + } + }, + bidId: '2f95c00074b931', + auctionId: 'e76cbb58-f3e1-4ad9-9f4c-718c1919d0df', + bidderRequestId: '1c56ad30b9b8ca8', + transactionId: 'e76cbb58-f3e1-4ad9-9f4c-718c1919d0df', + userId: { + tdid: '123456', + digitrustid: {data: {id: 'DTID', keyv: 4, privacy: {optout: false}, producer: 'ABC', version: 2}} + } + }]; + + bidderRequest = { + timeout: 3000, + gdprConsent: { + gdprApplies: true, + consentString: 'consentDataString', + vendorData: {} + } + } + }); + + describe('inherited functions', function () { + it('should exists and is a function', function () { + const adapter = newBidder(spec); + expect(adapter.callBids).to.exist.and.to.be.a('function'); + }); + }); + + describe('implementation', function () { + describe('for requests', function () { + it('should accept bid', function () { + let validBid = { + bidder: 'connectad', + params: { + siteId: 123456, + networkId: 123456 + }, + mediaTypes: { + banner: { + sizes: [[300, 250], [300, 600]] + } + } + }; + const isValid = spec.isBidRequestValid(validBid); + + expect(isValid).to.equal(true); + }); + + it('should reject if missing sizes', function () { + let invalidBid = { + bidder: 'connectad', + params: { + siteId: 123456, + } + }; + const isValid = spec.isBidRequestValid(invalidBid); + expect(isValid).to.equal(false); + }); + + it('should return true when optional bidFloor params found for an ad', function () { + let validBid = { + bidder: 'connectad', + params: { + siteId: 123456, + networkId: 123456, + bidfloor: 0.20 + }, + mediaTypes: { + banner: { + sizes: [[300, 250], [300, 600]] + } + } + }; + const isValid = spec.isBidRequestValid(validBid); + expect(isValid).to.equal(true) + }); + + it('should reject if missing siteId/networkId', function () { + let invalidBid = { + bidder: 'connectad', + params: {}, + mediaTypes: { + banner: { + sizes: [[300, 250], [300, 600]], + } + } + }; + const isValid = spec.isBidRequestValid(invalidBid); + expect(isValid).to.equal(false); + }); + + it('should reject if missing networkId', function () { + let invalidBid = { + bidder: 'connectad', + params: { + siteId: 123456 + }, + mediaTypes: { + banner: { + sizes: [[300, 250], [300, 600]], + } + } + }; + const isValid = spec.isBidRequestValid(invalidBid); + expect(isValid).to.equal(false); + }); + + it('should contain SiteId and NetworkId', function () { + const request = spec.buildRequests(bidRequests, bidderRequest); + const requestparse = JSON.parse(request.data); + expect(requestparse.placements[0].siteId).to.equal(123456); + expect(requestparse.placements[0].networkId).to.equal(123456); + }); + + it('should contain gdpr info', function () { + const request = spec.buildRequests(bidRequests, bidderRequest); + const requestparse = JSON.parse(request.data); + + expect(requestparse.user.ext.gdpr).to.equal(1); + expect(requestparse.user.ext.consent).to.equal('consentDataString'); + }); + + it('should build a request if Consent but no gdprApplies', function () { + let bidderRequest = { + timeout: 3000, + gdprConsent: { + gdprApplies: false, + consentString: 'consentDataString', + }, + } + const request = spec.buildRequests(bidRequests, bidderRequest); + const requestparse = JSON.parse(request.data); + + expect(requestparse.placements[0].adTypes).to.be.an('array'); + expect(requestparse.placements[0].siteId).to.equal(123456); + expect(requestparse.user.ext.consent).to.equal('consentDataString'); + }); + + it('should build a request if gdprConsent empty', function () { + let bidderRequest = { + timeout: 3000, + gdprConsent: {} + } + const request = spec.buildRequests(bidRequests, bidderRequest); + const requestparse = JSON.parse(request.data); + + expect(requestparse.placements[0].adTypes).to.be.an('array'); + expect(requestparse.placements[0].siteId).to.equal(123456); + }); + + it('should have CCPA Consent if defined', function () { + const uspConsent = '1YYN' + bidderRequest.uspConsent = uspConsent + const request = spec.buildRequests(bidRequests, bidderRequest); + const requestparse = JSON.parse(request.data); + + expect(requestparse.user.ext.us_privacy).to.equal(uspConsent); + }); + + it('should not have CCPA Consent if not defined', function () { + bidderRequest.uspConsent = undefined + const request = spec.buildRequests(bidRequests, bidderRequest); + const requestparse = JSON.parse(request.data); + expect(requestparse.user.ext.us_privacy).to.be.undefined; + }); + + it('should not include schain when not provided', function () { + const request = spec.buildRequests(bidRequests, bidderRequest); + const requestparse = JSON.parse(request.data); + expect(requestparse.source).to.not.exist; + }); + + it('should submit coppa if set in config', function () { + sinon.stub(config, 'getConfig') + .withArgs('coppa') + .returns(true); + const request = spec.buildRequests(bidRequests, bidderRequest); + const requestparse = JSON.parse(request.data); + expect(requestparse.user.coppa).to.equal(1); + config.getConfig.restore(); + }); + + it('should send all UserData data', function () { + const request = spec.buildRequests(bidRequestsUserIds, bidderRequest); + const requestparse = JSON.parse(request.data); + expect(requestparse.user.ext.eids).to.be.an('array'); + expect(requestparse.user.ext.eids[0].uids[0].id).to.equal('123456'); + expect(requestparse.user.ext.digitrust.id).to.equal('DTID'); + }); + + it('should add referer info', function () { + const bidRequest = Object.assign({}, bidRequests[0]) + const bidderRequ = { + refererInfo: { + referer: 'https://connectad.io/page.html', + reachedTop: true, + numIframes: 2, + stack: [ + 'https://connectad.io/page.html', + 'https://connectad.io/iframe1.html', + 'https://connectad.io/iframe2.html' + ] + } + } + const request = spec.buildRequests([bidRequest], bidderRequ); + const requestparse = JSON.parse(request.data); + + expect(requestparse.referrer_info).to.exist; + }); + + it('should populate schain', function () { + const bidRequest = Object.assign({}, bidRequests[0], { + schain: { + ver: '1.0', + complete: 1, + nodes: [ + { + 'asi': 'reseller1.com', + 'sid': 'absc1', + 'hp': 1 + } + ] + } + }); + + const request = spec.buildRequests([bidRequest], bidderRequest); + const requestparse = JSON.parse(request.data); + expect(requestparse.source.ext.schain).to.deep.equal({ + ver: '1.0', + complete: 1, + nodes: [ + { + 'asi': 'reseller1.com', + 'sid': 'absc1', + 'hp': 1 + } + ] + }); + }); + }); + + describe('bid responses', function () { + it('should return complete bid response', function () { + let serverResponse = { + body: { + decisions: { + '2f95c00074b931': { + adId: '0', + contents: [ + { + body: '<<<---- Creative --->>>' + } + ], + height: '250', + width: '300', + pricing: { + clearPrice: 11.899999999999999 + } + } + } + } + }; + const request = spec.buildRequests(bidRequests, bidderRequest); + const bids = spec.interpretResponse(serverResponse, request); + + expect(bids).to.be.lengthOf(1); + expect(bids[0].cpm).to.equal(11.899999999999999); + expect(bids[0].width).to.equal('300'); + expect(bids[0].height).to.equal('250'); + expect(bids[0].ad).to.have.length.above(1); + }); + + it('should return empty bid response', function () { + let serverResponse = { + body: { + decisions: [] + } + }; + const request = spec.buildRequests(bidRequests, bidderRequest); + const bids = spec.interpretResponse(serverResponse, request); + expect(bids).to.be.lengthOf(0); + }); + + it('should return empty bid response on incorrect size', function () { + let serverResponse = { + body: { + decisions: { + '2f95c00074b931': { + adId: '0', + contents: [ + { + body: '<<<---- Creative --->>>' + } + ], + height: '160', + width: '600', + pricing: { + clearPrice: 0 + } + } + } + } + }; + const request = spec.buildRequests(bidRequests, bidderRequest); + const bids = spec.interpretResponse(serverResponse, request); + expect(bids).to.be.lengthOf(0); + }); + + it('should return empty bid response on 0 cpm', function () { + let serverResponse = { + body: { + decisions: { + '2f95c00074b931': { + adId: '0', + contents: [ + { + body: '<<<---- Creative --->>>' + } + ], + height: '300', + width: '250', + pricing: { + clearPrice: 0 + } + } + } + } + }; + const request = spec.buildRequests(bidRequests, bidderRequest); + const bids = spec.interpretResponse(serverResponse, request); + expect(bids).to.be.lengthOf(0); + }); + + it('should process a deal id', function () { + let serverResponse = { + body: { + decisions: { + '2f95c00074b931': { + adId: '0', + dealid: 'ABC90210', + contents: [ + { + body: '<<<---- Creative --->>>' + } + ], + height: '300', + width: '250', + pricing: { + clearPrice: 11.899999999999999 + } + } + } + } + }; + const request = spec.buildRequests(bidRequests, bidderRequest); + const bids = spec.interpretResponse(serverResponse, request); + expect(bids).to.be.lengthOf(1); + expect(bids[0].dealid).to.equal('ABC90210'); + }); + }); + }); + + describe('getUserSyncs', () => { + let testParams = [ + { + name: 'iframe/no gdpr or ccpa', + arguments: [{ iframeEnabled: true, pixelEnabled: true }, {}, null], + expect: { + type: 'iframe', + pixels: ['https://cdn.connectad.io/connectmyusers.php?'] + } + }, + { + name: 'iframe/gdpr', + arguments: [{ iframeEnabled: true, pixelEnabled: true }, {}, {gdprApplies: true, consentString: '234234'}], + expect: { + type: 'iframe', + pixels: ['https://cdn.connectad.io/connectmyusers.php?gdpr=1&gdpr_consent=234234&'] + } + }, + { + name: 'iframe/ccpa', + arguments: [{ iframeEnabled: true, pixelEnabled: true }, {}, null, 'YN12'], + expect: { + type: 'iframe', + pixels: ['https://cdn.connectad.io/connectmyusers.php?us_privacy=YN12&'] + } + }, + { + name: 'iframe/ccpa & gdpr', + arguments: [{ iframeEnabled: true, pixelEnabled: true }, {}, {gdprApplies: true, consentString: '234234'}, 'YN12'], + expect: { + type: 'iframe', + pixels: ['https://cdn.connectad.io/connectmyusers.php?gdpr=1&gdpr_consent=234234&us_privacy=YN12&'] + } + } + ]; + + for (let i = 0; i < testParams.length; i++) { + let currParams = testParams[i]; + it(currParams.name, function () { + const result = spec.getUserSyncs.apply(this, currParams.arguments); + expect(result).to.have.lengthOf(currParams.expect.pixels.length); + for (let ix = 0; ix < currParams.expect.pixels.length; ix++) { + expect(result[ix].url).to.equal(currParams.expect.pixels[ix]); + expect(result[ix].type).to.equal(currParams.expect.type); + } + }); + } + }); +}); diff --git a/test/spec/modules/consentManagementUsp_spec.js b/test/spec/modules/consentManagementUsp_spec.js index d757ea0b86f..2e8d7db92b5 100644 --- a/test/spec/modules/consentManagementUsp_spec.js +++ b/test/spec/modules/consentManagementUsp_spec.js @@ -3,11 +3,12 @@ import { requestBidsHook, resetConsentData, consentAPI, - consentTimeout -} from 'modules/consentManagementUsp'; -import * as utils from 'src/utils'; -import { config } from 'src/config'; -import { uspDataHandler } from 'src/adapterManager'; + consentTimeout, + staticConsentData +} from 'modules/consentManagementUsp.js'; +import * as utils from 'src/utils.js'; +import { config } from 'src/config.js'; +import { uspDataHandler } from 'src/adapterManager.js'; let assert = require('chai').assert; let expect = require('chai').expect; @@ -84,6 +85,31 @@ describe('consentManagement', function () { expect(consentTimeout).to.be.equal(7500); }); }); + + describe('static consent string setConsentConfig value', () => { + afterEach(() => { + config.resetConfig(); + $$PREBID_GLOBAL$$.requestBids.removeAll(); + }); + it('results in user settings overriding system defaults', () => { + let staticConfig = { + usp: { + cmpApi: 'static', + timeout: 7500, + consentData: { + getUSPData: { + uspString: '1YYY' + } + } + } + }; + + setConsentConfig(staticConfig); + expect(consentAPI).to.be.equal('static'); + expect(consentTimeout).to.be.equal(0); // should always return without a timeout when config is used + expect(staticConsentData.usPrivacy).to.be.equal(staticConfig.usp.consentData.getUSPData.uspString); + }); + }); }); describe('requestBidsHook tests:', function () { diff --git a/test/spec/modules/consentManagement_spec.js b/test/spec/modules/consentManagement_spec.js index 9731164c655..fb33094e151 100644 --- a/test/spec/modules/consentManagement_spec.js +++ b/test/spec/modules/consentManagement_spec.js @@ -1,9 +1,8 @@ -import {setConsentConfig, requestBidsHook, resetConsentData, userCMP, consentTimeout, allowAuction, staticConsentData} from 'modules/consentManagement'; -import {gdprDataHandler} from 'src/adapterManager'; -import * as utils from 'src/utils'; -import { config } from 'src/config'; +import { setConsentConfig, requestBidsHook, resetConsentData, userCMP, consentTimeout, allowAuction, staticConsentData, gdprScope } from 'modules/consentManagement.js'; +import { gdprDataHandler } from 'src/adapterManager.js'; +import * as utils from 'src/utils.js'; +import { config } from 'src/config.js'; -let assert = require('chai').assert; let expect = require('chai').expect; describe('consentManagement', function () { @@ -26,16 +25,17 @@ describe('consentManagement', function () { expect(userCMP).to.be.equal('iab'); expect(consentTimeout).to.be.equal(10000); expect(allowAuction).to.be.true; + expect(gdprScope).to.be.equal(false); sinon.assert.callCount(utils.logInfo, 4); }); - it('should exit consent manager if config is not an object', function() { + it('should exit consent manager if config is not an object', function () { setConsentConfig(''); expect(userCMP).to.be.undefined; sinon.assert.calledOnce(utils.logWarn); }); - it('should exit consent manager if gdpr not set with new config structure', function() { + it('should exit consent manager if gdpr not set with new config structure', function () { setConsentConfig({ usp: { cmpApi: 'iab', timeout: 50 } }); expect(userCMP).to.be.undefined; sinon.assert.calledOnce(utils.logWarn); @@ -45,23 +45,24 @@ describe('consentManagement', function () { describe('valid setConsentConfig value', function () { afterEach(function () { config.resetConfig(); - $$PREBID_GLOBAL$$.requestBids.removeAll(); }); it('results in all user settings overriding system defaults', function () { let allConfig = { cmpApi: 'iab', timeout: 7500, - allowAuctionWithoutConsent: false + allowAuctionWithoutConsent: false, + defaultGdprScope: true }; setConsentConfig(allConfig); expect(userCMP).to.be.equal('iab'); expect(consentTimeout).to.be.equal(7500); expect(allowAuction).to.be.false; + expect(gdprScope).to.be.true; }); - it('should use new consent manager config structure for gdpr', function() { + it('should use new consent manager config structure for gdpr', function () { setConsentConfig({ gdpr: { cmpApi: 'daa', timeout: 8700 } }); @@ -70,7 +71,7 @@ describe('consentManagement', function () { expect(consentTimeout).to.be.equal(8700); }); - it('should ignore config.usp and use config.gdpr, with default cmpApi', function() { + it('should ignore config.usp and use config.gdpr, with default cmpApi', function () { setConsentConfig({ gdpr: { timeout: 5000 }, usp: { cmpApi: 'daa', timeout: 50 } @@ -80,7 +81,7 @@ describe('consentManagement', function () { expect(consentTimeout).to.be.equal(5000); }); - it('should ignore config.usp and use config.gdpr, with default cmpAip and timeout', function() { + it('should ignore config.usp and use config.gdpr, with default cmpAip and timeout', function () { setConsentConfig({ gdpr: {}, usp: { cmpApi: 'daa', timeout: 50 } @@ -90,7 +91,7 @@ describe('consentManagement', function () { expect(consentTimeout).to.be.equal(10000); }); - it('should recognize config.gdpr, with default cmpAip and timeout', function() { + it('should recognize config.gdpr, with default cmpAip and timeout', function () { setConsentConfig({ gdpr: {} }); @@ -99,7 +100,7 @@ describe('consentManagement', function () { expect(consentTimeout).to.be.equal(10000); }); - it('should fallback to old consent manager config object if no config.gdpr', function() { + it('should fallback to old consent manager config object if no config.gdpr', function () { setConsentConfig({ cmpApi: 'iab', timeout: 3333, @@ -110,15 +111,15 @@ describe('consentManagement', function () { expect(userCMP).to.be.equal('iab'); expect(consentTimeout).to.be.equal(3333); expect(allowAuction).to.be.equal(false); + expect(gdprScope).to.be.equal(false); }); }); describe('static consent string setConsentConfig value', () => { afterEach(() => { config.resetConfig(); - $$PREBID_GLOBAL$$.requestBids.removeAll(); }); - it('results in user settings overriding system defaults', () => { + it('results in user settings overriding system defaults for v1 spec', () => { let staticConfig = { cmpApi: 'static', timeout: 7500, @@ -154,361 +155,87 @@ describe('consentManagement', function () { '2': true, '3': true, '4': true, - '5': false, - '6': true, - '7': true, - '8': true, - '9': true, - '10': true, - '11': true, - '12': true, - '13': true, - '14': true, - '15': true, - '16': true, - '17': true, - '18': true, - '19': true, - '20': true, - '21': true, - '22': true, - '23': true, - '24': true, - '25': true, - '26': true, - '27': true, - '28': true, - '29': true, - '30': true, - '31': true, - '32': true, - '33': true, - '34': true, - '35': true, - '36': true, - '37': true, - '38': true, - '39': true, - '40': true, - '41': true, - '42': true, - '43': true, - '44': true, - '45': true, - '46': true, - '47': true, - '48': true, - '49': true, - '50': true, - '51': true, - '52': true, - '53': true, - '54': false, - '55': true, - '56': true, - '57': true, - '58': true, - '59': true, - '60': true, - '61': true, - '62': true, - '63': true, - '64': true, - '65': true, - '66': true, - '67': true, - '68': true, - '69': true, - '70': true, - '71': true, - '72': true, - '73': true, - '74': true, - '75': true, - '76': true, - '77': true, - '78': true, - '79': true, - '80': true, - '81': true, - '82': true, - '83': false, - '84': true, - '85': true, - '86': true, - '87': true, - '88': true, - '89': true, - '90': true, - '91': true, - '92': true, - '93': true, - '94': true, - '95': true, - '96': false, - '97': true, - '98': true, - '99': false, - '100': true, - '101': true, - '102': true, - '103': false, - '104': true, - '105': true, - '106': false, - '107': false, - '108': true, - '109': true, - '110': true, - '111': true, - '112': true, - '113': true, - '114': true, - '115': true, - '116': false, - '117': false, - '118': false, - '119': true, - '120': true, - '121': false, - '122': true, - '123': false, - '124': true, - '125': true, - '126': true, - '127': true, - '128': true, - '129': true, - '130': true, - '131': true, - '132': true, - '133': true, - '134': true, - '135': false, - '136': true, - '137': false, - '138': true, - '139': true, - '140': true, - '141': true, - '142': true, - '143': true, - '144': true, - '145': true, - '146': false, - '147': true, - '148': true, - '149': true, - '150': true, - '151': true, - '152': false, - '153': true, - '154': true, - '155': true, - '156': true, - '157': true, - '158': true, - '159': true, - '160': true, - '161': true, - '162': true, - '163': true, - '164': true, - '165': true, - '166': false, - '167': true, - '168': true, - '169': true, - '170': true, - '171': false, - '172': false, - '173': true, - '174': true, - '175': true, - '176': false, - '177': true, - '178': false, - '179': true, - '180': true, - '181': false, - '182': true, - '183': true, - '184': false, - '185': true, - '186': false, - '187': false, - '188': true, - '189': true, - '190': true, - '191': false, - '192': true, - '193': true, - '194': true, - '195': true, - '196': false, - '197': true, - '198': true, - '199': true, - '200': true, - '201': true, - '202': true, - '203': true, - '204': false, - '205': true, - '206': false, - '207': false, - '208': true, - '209': true, - '210': true, - '211': true, - '212': true, - '213': true, - '214': false, - '215': true, - '216': false, - '217': true, - '218': false, - '219': false, - '220': false, - '221': false, - '222': false, - '223': false, - '224': true, - '225': true, - '226': true, - '227': true, - '228': true, - '229': true, - '230': true, - '231': false, - '232': true, - '233': false, - '234': true, - '235': true, - '236': true, - '237': true, - '238': true, - '239': true, - '240': true, - '241': true, - '242': false, - '243': false, - '244': true, - '245': true, - '246': true, - '247': false, - '248': true, - '249': true, - '250': false, - '251': false, - '252': true, - '253': true, - '254': true, - '255': true, - '256': true, - '257': true, - '258': true, - '259': true, - '260': true, - '261': false, - '262': true, - '263': false, - '264': true, - '265': true, - '266': true, - '267': false, - '268': false, - '269': true, - '270': true, - '271': false, - '272': true, - '273': true, - '274': true, - '275': true, - '276': true, - '277': true, - '278': true, - '279': true, - '280': true, - '281': true, - '282': true, - '283': false, - '284': true, - '285': true, - '286': false, - '287': false, - '288': true, - '289': true, - '290': true, - '291': true, - '292': false, - '293': false, - '294': true, - '295': true, - '296': false, - '297': true, - '298': false, - '299': true, - '300': false, - '301': true, - '302': true, - '303': true, - '304': true, - '305': false, - '306': false, - '307': false, - '308': true, - '309': true, - '310': true, - '311': false, - '312': false, - '313': false, - '314': true, - '315': true, - '316': true, - '317': true, - '318': true, - '319': true, - '320': true, - '321': false, - '322': false, - '323': true, - '324': false, - '325': true, - '326': true, - '327': false, - '328': true, - '329': false, - '330': false, - '331': true, - '332': false, - '333': true, - '334': false, - '335': false, - '336': false, - '337': false, - '338': false, - '339': true, - '340': false, - '341': false, - '342': false, - '343': false, - '344': false, - '345': true, - '346': false, - '347': false, - '348': false, - '349': true, - '350': false, - '351': false, - '352': false, - '353': false, - '354': true, - '355': false, - '356': false, - '357': false, - '358': false, - '359': true + '5': false + } + } + } + }; + + setConsentConfig(staticConfig); + expect(userCMP).to.be.equal('static'); + expect(consentTimeout).to.be.equal(0); // should always return without a timeout when config is used + expect(allowAuction).to.be.false; + expect(staticConsentData).to.be.equal(staticConfig.consentData); + }); + + it('results in user settings overriding system defaults for v2 spec', () => { + let staticConfig = { + cmpApi: 'static', + timeout: 7500, + allowAuctionWithoutConsent: false, + consentData: { + getTCData: { + 'tcString': 'COuqj-POu90rDBcBkBENAZCgAPzAAAPAACiQFwwBAABAA1ADEAbQC4YAYAAgAxAG0A', + 'cmpId': 92, + 'cmpVersion': 100, + 'tcfPolicyVersion': 2, + 'gdprApplies': true, + 'isServiceSpecific': true, + 'useNonStandardStacks': false, + 'purposeOneTreatment': false, + 'publisherCC': 'US', + 'cmpStatus': 'loaded', + 'eventStatus': 'tcloaded', + 'outOfBand': { + 'allowedVendors': {}, + 'discloseVendors': {} + }, + 'purpose': { + 'consents': { + '1': true, + '2': true, + '3': true + }, + 'legitimateInterests': { + '1': false, + '2': false, + '3': false + } + }, + 'vendor': { + 'consents': { + '1': false, + '2': true, + '3': false + }, + 'legitimateInterests': { + '1': false, + '2': true, + '3': false, + '4': false, + '5': false + } + }, + 'specialFeatureOptins': { + '1': false, + '2': false + }, + 'restrictions': {}, + 'publisher': { + 'consents': { + '1': false, + '2': false, + '3': false + }, + 'legitimateInterests': { + '1': false, + '2': false, + '3': false + }, + 'customPurpose': { + 'consents': {}, + 'legitimateInterests': {} + } } } } @@ -518,6 +245,7 @@ describe('consentManagement', function () { expect(userCMP).to.be.equal('static'); expect(consentTimeout).to.be.equal(0); // should always return without a timeout when config is used expect(allowAuction).to.be.false; + expect(gdprScope).to.be.equal(false); expect(staticConsentData).to.be.equal(staticConfig.consentData); }); }); @@ -554,7 +282,6 @@ describe('consentManagement', function () { utils.logWarn.restore(); utils.logError.restore(); config.resetConfig(); - $$PREBID_GLOBAL$$.requestBids.removeAll(); resetConsentData(); }); @@ -593,12 +320,11 @@ describe('consentManagement', function () { beforeEach(function () { didHookReturn = false; - window.__cmp = function() {}; + window.__cmp = function () { }; }); afterEach(function () { config.resetConfig(); - $$PREBID_GLOBAL$$.requestBids.removeAll(); cmpStub.restore(); delete window.__cmp; resetConsentData(); @@ -614,7 +340,7 @@ describe('consentManagement', function () { args[2](testConsentData); }); setConsentConfig(goodConfigWithAllowAuction); - requestBidsHook(() => {}, {}); + requestBidsHook(() => { }, {}); cmpStub.restore(); // reset the stub to ensure it wasn't called during the second round of calls @@ -632,123 +358,66 @@ describe('consentManagement', function () { expect(consent.gdprApplies).to.be.true; sinon.assert.notCalled(cmpStub); }); - }); - - describe('CMP workflow for safeframe page', function () { - let registerStub = sinon.stub(); - beforeEach(function () { - didHookReturn = false; - window.$sf = { - ext: { - register: function() {}, - cmp: function() {} - } + it('should not set consent.gdprApplies to true if defaultGdprScope is true', function () { + let testConsentData = { + gdprApplies: false, + consentData: 'xyz' }; - sinon.stub(utils, 'logError'); - sinon.stub(utils, 'logWarn'); - }); - afterEach(function () { - delete window.$sf; - config.resetConfig(); - $$PREBID_GLOBAL$$.requestBids.removeAll(); - registerStub.restore(); - utils.logError.restore(); - utils.logWarn.restore(); - resetConsentData(); - }); + cmpStub = sinon.stub(window, '__cmp').callsFake((...args) => { + args[2](testConsentData); + }); - it('should return the consent data from a safeframe callback', function () { - var testConsentData = { - data: { - msgName: 'cmpReturn', - vendorConsents: { - metadata: 'abc123def', - gdprApplies: true - }, - vendorConsentData: { - consentData: 'abc123def', - gdprApplies: true - } - } - }; - registerStub = sinon.stub(window.$sf.ext, 'register').callsFake((...args) => { - args[2](testConsentData.data.msgName, testConsentData.data); + setConsentConfig({ + cmpApi: 'iab', + timeout: 7500, + defaultGdprScope: true }); - setConsentConfig(goodConfigWithAllowAuction); requestBidsHook(() => { didHookReturn = true; - }, {adUnits: [{ sizes: [[300, 250]] }]}); + }, {}); + let consent = gdprDataHandler.getConsentData(); - sinon.assert.notCalled(utils.logWarn); - sinon.assert.notCalled(utils.logError); - expect(didHookReturn).to.be.true; - expect(consent.consentString).to.equal('abc123def'); - expect(consent.gdprApplies).to.be.true; + expect(consent.gdprApplies).to.be.false; }); }); - describe('CMP workflow for iframed page', function () { - let ifr = null; - let stringifyResponse = false; - - beforeEach(function () { - sinon.stub(utils, 'logError'); - sinon.stub(utils, 'logWarn'); - ifr = createIFrameMarker(); - window.addEventListener('message', cmpMessageHandler, false); - }); + describe('iframe tests', function () { + let cmpPostMessageCb = () => { }; + let stringifyResponse; - afterEach(function () { - config.resetConfig(); - $$PREBID_GLOBAL$$.requestBids.removeAll(); - delete window.__cmp; - utils.logError.restore(); - utils.logWarn.restore(); - resetConsentData(); - document.body.removeChild(ifr); - window.removeEventListener('message', cmpMessageHandler); - }); - - function createIFrameMarker() { - var ifr = document.createElement('iframe'); + function createIFrameMarker(frameName) { + let ifr = document.createElement('iframe'); ifr.width = 0; ifr.height = 0; - ifr.name = '__cmpLocator'; + ifr.name = frameName; document.body.appendChild(ifr); return ifr; } - function cmpMessageHandler(event) { - if (event && event.data) { - var data = event.data; - if (data.__cmpCall) { - var callId = data.__cmpCall.callId; - var returnValue = null; - var response = { - __cmpReturn: { - callId, - returnValue: { - consentData: 'encoded_consent_data_via_post_message', - gdprApplies: true, - }, - success: true - } - }; - event.source.postMessage(stringifyResponse ? JSON.stringify(response) : response, '*'); + function creatCmpMessageHandler(prefix, returnValue) { + return function (event) { + if (event && event.data) { + let data = event.data; + if (data[`${prefix}Call`]) { + let callId = data[`${prefix}Call`].callId; + let response = { + [`${prefix}Return`]: { + callId, + returnValue, + success: true + } + }; + event.source.postMessage(stringifyResponse ? JSON.stringify(response) : response, '*'); + } } } } - // Run tests with JSON response and String response - // from CMP window postMessage listener. - testIFramedPage('with/JSON response', false); - testIFramedPage('with/String response', true); - - function testIFramedPage(testName, messageFormatString) { + function testIFramedPage(testName, messageFormatString, tarConsentString, ver) { it(`should return the consent string from a postmessage + addEventListener response - ${testName}`, (done) => { stringifyResponse = messageFormatString; setConsentConfig(goodConfigWithAllowAuction); @@ -756,96 +425,256 @@ describe('consentManagement', function () { let consent = gdprDataHandler.getConsentData(); sinon.assert.notCalled(utils.logWarn); sinon.assert.notCalled(utils.logError); - expect(consent.consentString).to.equal('encoded_consent_data_via_post_message'); + expect(consent.consentString).to.equal(tarConsentString); expect(consent.gdprApplies).to.be.true; + expect(consent.apiVersion).to.equal(ver); done(); }, {}); }); } + + beforeEach(function () { + sinon.stub(utils, 'logError'); + sinon.stub(utils, 'logWarn'); + }); + + afterEach(function () { + utils.logError.restore(); + utils.logWarn.restore(); + config.resetConfig(); + resetConsentData(); + }); + + describe('v1 CMP workflow for safeframe page', function () { + let registerStub = sinon.stub(); + let ifrSf = null; + beforeEach(function () { + didHookReturn = false; + window.$sf = { + ext: { + register: function () { }, + cmp: function () { } + } + }; + ifrSf = createIFrameMarker('__cmpLocator'); + }); + + afterEach(function () { + delete window.$sf; + registerStub.restore(); + document.body.removeChild(ifrSf); + }); + + it('should return the consent data from a safeframe callback', function () { + let testConsentData = { + data: { + msgName: 'cmpReturn', + vendorConsents: { + metadata: 'abc123def', + gdprApplies: true + }, + vendorConsentData: { + consentData: 'abc123def', + gdprApplies: true + } + } + }; + registerStub = sinon.stub(window.$sf.ext, 'register').callsFake((...args) => { + args[2](testConsentData.data.msgName, testConsentData.data); + }); + + setConsentConfig(goodConfigWithAllowAuction); + requestBidsHook(() => { + didHookReturn = true; + }, { adUnits: [{ sizes: [[300, 250]] }] }); + let consent = gdprDataHandler.getConsentData(); + + sinon.assert.notCalled(utils.logWarn); + sinon.assert.notCalled(utils.logError); + expect(didHookReturn).to.be.true; + expect(consent.consentString).to.equal('abc123def'); + expect(consent.gdprApplies).to.be.true; + expect(consent.apiVersion).to.equal(1); + }); + }); + + describe('v1 CMP workflow for iframe pages', function () { + stringifyResponse = false; + let ifr1 = null; + + beforeEach(function () { + ifr1 = createIFrameMarker('__cmpLocator'); + cmpPostMessageCb = creatCmpMessageHandler('__cmp', { + consentData: 'encoded_consent_data_via_post_message', + gdprApplies: true, + }); + window.addEventListener('message', cmpPostMessageCb, false); + }); + + afterEach(function () { + delete window.__cmp; // deletes the local copy made by the postMessage CMP call function + document.body.removeChild(ifr1); + window.removeEventListener('message', cmpPostMessageCb); + }); + + // Run tests with JSON response and String response + // from CMP window postMessage listener. + testIFramedPage('with/JSON response', false, 'encoded_consent_data_via_post_message', 1); + testIFramedPage('with/String response', true, 'encoded_consent_data_via_post_message', 1); + }); + + describe('v2 CMP workflow for iframe pages:', function () { + stringifyResponse = false; + let ifr2 = null; + + beforeEach(function () { + ifr2 = createIFrameMarker('__tcfapiLocator'); + cmpPostMessageCb = creatCmpMessageHandler('__tcfapi', { + tcString: 'abc12345234', + gdprApplies: true, + purposeOneTreatment: false, + eventStatus: 'tcloaded' + }); + window.addEventListener('message', cmpPostMessageCb, false); + }); + + afterEach(function () { + delete window.__tcfapi; // deletes the local copy made by the postMessage CMP call function + document.body.removeChild(ifr2); + window.removeEventListener('message', cmpPostMessageCb); + }); + + testIFramedPage('with/JSON response', false, 'abc12345234', 2); + testIFramedPage('with/String response', true, 'abc12345234', 2); + }); }); - describe('CMP workflow for normal pages:', function () { + describe('direct calls to CMP API tests', function () { let cmpStub = sinon.stub(); beforeEach(function () { didHookReturn = false; sinon.stub(utils, 'logError'); sinon.stub(utils, 'logWarn'); - window.__cmp = function() {}; }); afterEach(function () { config.resetConfig(); - $$PREBID_GLOBAL$$.requestBids.removeAll(); cmpStub.restore(); utils.logError.restore(); utils.logWarn.restore(); - delete window.__cmp; resetConsentData(); }); - it('performs lookup check and stores consentData for a valid existing user', function () { - let testConsentData = { - gdprApplies: true, - consentData: 'BOJy+UqOJy+UqABAB+AAAAAZ+A==' - }; - cmpStub = sinon.stub(window, '__cmp').callsFake((...args) => { - args[2](testConsentData); + describe('v1 CMP workflow for normal pages:', function () { + beforeEach(function () { + window.__cmp = function () { }; }); - setConsentConfig(goodConfigWithAllowAuction); + afterEach(function () { + delete window.__cmp; + }); - requestBidsHook(() => { - didHookReturn = true; - }, {}); - let consent = gdprDataHandler.getConsentData(); + it('performs lookup check and stores consentData for a valid existing user', function () { + let testConsentData = { + gdprApplies: true, + consentData: 'BOJy+UqOJy+UqABAB+AAAAAZ+A==' + }; + cmpStub = sinon.stub(window, '__cmp').callsFake((...args) => { + args[2](testConsentData); + }); - sinon.assert.notCalled(utils.logWarn); - sinon.assert.notCalled(utils.logError); - expect(didHookReturn).to.be.true; - expect(consent.consentString).to.equal(testConsentData.consentData); - expect(consent.gdprApplies).to.be.true; + setConsentConfig(goodConfigWithAllowAuction); + + requestBidsHook(() => { + didHookReturn = true; + }, {}); + let consent = gdprDataHandler.getConsentData(); + + sinon.assert.notCalled(utils.logWarn); + sinon.assert.notCalled(utils.logError); + expect(didHookReturn).to.be.true; + expect(consent.consentString).to.equal(testConsentData.consentData); + expect(consent.gdprApplies).to.be.true; + expect(consent.apiVersion).to.equal(1); + }); }); - it('throws an error when processCmpData check failed while config had allowAuction set to false', function () { - let testConsentData = {}; - let bidsBackHandlerReturn = false; + describe('v2 CMP workflow for normal pages:', function () { + beforeEach(function() { + window.__tcfapi = function () { }; + }); - cmpStub = sinon.stub(window, '__cmp').callsFake((...args) => { - args[2](testConsentData); + afterEach(function () { + delete window.__tcfapi; }); - setConsentConfig(goodConfigWithCancelAuction); + it('performs lookup check and stores consentData for a valid existing user', function () { + let testConsentData = { + tcString: 'abc12345234', + gdprApplies: true, + purposeOneTreatment: false, + eventStatus: 'tcloaded' + }; + cmpStub = sinon.stub(window, '__tcfapi').callsFake((...args) => { + args[2](testConsentData, true); + }); - requestBidsHook(() => { - didHookReturn = true; - }, { bidsBackHandler: () => bidsBackHandlerReturn = true }); - let consent = gdprDataHandler.getConsentData(); + setConsentConfig(goodConfigWithAllowAuction); - sinon.assert.calledOnce(utils.logError); - expect(didHookReturn).to.be.false; - expect(bidsBackHandlerReturn).to.be.true; - expect(consent).to.be.null; - }); + requestBidsHook(() => { + didHookReturn = true; + }, {}); + let consent = gdprDataHandler.getConsentData(); + sinon.assert.notCalled(utils.logWarn); + sinon.assert.notCalled(utils.logError); + expect(didHookReturn).to.be.true; + expect(consent.consentString).to.equal(testConsentData.tcString); + expect(consent.gdprApplies).to.be.true; + expect(consent.apiVersion).to.equal(2); + }); - it('throws a warning + stores consentData + calls callback when processCmpData check failed while config had allowAuction set to true', function () { - let testConsentData = {}; + it('throws an error when processCmpData check failed while config had allowAuction set to false', function () { + let testConsentData = {}; + let bidsBackHandlerReturn = false; - cmpStub = sinon.stub(window, '__cmp').callsFake((...args) => { - args[2](testConsentData); + cmpStub = sinon.stub(window, '__tcfapi').callsFake((...args) => { + args[2](testConsentData); + }); + + setConsentConfig(goodConfigWithCancelAuction); + + requestBidsHook(() => { + didHookReturn = true; + }, { bidsBackHandler: () => bidsBackHandlerReturn = true }); + let consent = gdprDataHandler.getConsentData(); + + sinon.assert.calledOnce(utils.logError); + expect(didHookReturn).to.be.false; + expect(bidsBackHandlerReturn).to.be.true; + expect(consent).to.be.null; }); - setConsentConfig(goodConfigWithAllowAuction); + it('throws a warning + stores consentData + calls callback when processCmpData check failed while config had allowAuction set to true', function () { + let testConsentData = {}; - requestBidsHook(() => { - didHookReturn = true; - }, {}); - let consent = gdprDataHandler.getConsentData(); + cmpStub = sinon.stub(window, '__tcfapi').callsFake((...args) => { + args[2](testConsentData); + }); - sinon.assert.calledOnce(utils.logWarn); - expect(didHookReturn).to.be.true; - expect(consent.consentString).to.be.undefined; - expect(consent.gdprApplies).to.be.undefined; + setConsentConfig(goodConfigWithAllowAuction); + + requestBidsHook(() => { + didHookReturn = true; + }, {}); + let consent = gdprDataHandler.getConsentData(); + + sinon.assert.calledOnce(utils.logWarn); + expect(didHookReturn).to.be.true; + expect(consent.consentString).to.be.undefined; + expect(consent.gdprApplies).to.be.false; + expect(consent.apiVersion).to.equal(2); + }); }); }); }); diff --git a/test/spec/modules/consumableBidAdapter_spec.js b/test/spec/modules/consumableBidAdapter_spec.js index 7785454f8e1..44076194885 100644 --- a/test/spec/modules/consumableBidAdapter_spec.js +++ b/test/spec/modules/consumableBidAdapter_spec.js @@ -1,6 +1,6 @@ import {expect} from 'chai'; -import {spec} from 'modules/consumableBidAdapter'; -import {createBid} from 'src/bidfactory'; +import {spec} from 'modules/consumableBidAdapter.js'; +import {createBid} from 'src/bidfactory.js'; const ENDPOINT = 'https://e.serverbid.com/api/v2'; const SMARTSYNC_CALLBACK = 'serverbidCallBids'; diff --git a/test/spec/modules/contentigniteBidAdapter_spec.js b/test/spec/modules/contentigniteBidAdapter_spec.js deleted file mode 100644 index 1867791a234..00000000000 --- 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/convergeBidAdapter_spec.js b/test/spec/modules/convergeBidAdapter_spec.js new file mode 100644 index 00000000000..e92ed475497 --- /dev/null +++ b/test/spec/modules/convergeBidAdapter_spec.js @@ -0,0 +1,899 @@ +import { expect } from 'chai'; +import { spec, resetUserSync, getSyncUrl } from 'modules/convergeBidAdapter.js'; +import { newBidder } from 'src/adapters/bidderFactory.js'; + +describe('ConvergeAdapter', 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': 'converge', + 'params': { + 'uid': '1' + }, + '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; + } + + const bidderRequest = { + refererInfo: { + referer: 'https://example.com' + } + }; + const referrer = bidderRequest.refererInfo.referer; + + let bidRequests = [ + { + 'bidder': 'converge', + 'params': { + 'uid': '59' + }, + 'adUnitCode': 'adunit-code-1', + 'sizes': [[300, 250], [300, 600]], + 'bidId': '30b31c1838de1e', + 'bidderRequestId': '22edbae2733bf6', + 'auctionId': '1d1a030790a475', + }, + { + 'bidder': 'converge', + 'params': { + 'uid': '59' + }, + 'adUnitCode': 'adunit-code-2', + 'sizes': [[728, 90], [300, 250]], + 'bidId': '3150ccb55da321', + 'bidderRequestId': '22edbae2733bf6', + 'auctionId': '1d1a030790a475', + }, + { + 'bidder': 'converge', + 'params': { + 'uid': '60' + }, + '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]], bidderRequest); + expect(request.data).to.be.an('string'); + const payload = parseRequest(request.data); + expect(payload).to.have.property('u', referrer); + expect(payload).to.have.property('pt', 'net'); + expect(payload).to.have.property('auids', '59'); + expect(payload).to.have.property('sizes', '300x250,300x600'); + expect(payload).to.have.property('r', '22edbae2733bf6'); + expect(payload).to.have.property('wrapperType', 'Prebid_js'); + expect(payload).to.have.property('wrapperVersion', '$prebid.version$'); + }); + + it('sizes must not be duplicated', function () { + const request = spec.buildRequests(bidRequests, bidderRequest); + expect(request.data).to.be.an('string'); + const payload = parseRequest(request.data); + expect(payload).to.have.property('u', referrer); + expect(payload).to.have.property('pt', 'net'); + expect(payload).to.have.property('auids', '59,59,60'); + expect(payload).to.have.property('sizes', '300x250,300x600,728x90'); + 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, bidderRequest); + expect(request.data).to.be.an('string'); + const payload = parseRequest(request.data); + expect(payload).to.have.property('u', referrer); + expect(payload).to.have.property('pt', 'gross'); + expect(payload).to.have.property('auids', '59,59,60'); + expect(payload).to.have.property('sizes', '300x250,300x600,728x90'); + 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, bidderRequest); + expect(request.data).to.be.an('string'); + const payload = parseRequest(request.data); + expect(payload).to.have.property('u', referrer); + expect(payload).to.have.property('pt', 'net'); + expect(payload).to.have.property('auids', '59,59,60'); + expect(payload).to.have.property('sizes', '300x250,300x600,728x90'); + expect(payload).to.have.property('r', '22edbae2733bf6'); + delete bidRequests[1].params.priceType; + }); + + it('if gdprConsent is present payload must have gdpr params', function () { + const bidderRequestWithGDPR = Object.assign({gdprConsent: {consentString: 'AAA', gdprApplies: true}}, bidderRequest); + const request = spec.buildRequests(bidRequests, bidderRequestWithGDPR); + 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 bidderRequestWithGDPR = Object.assign({gdprConsent: {consentString: 'AAA', gdprApplies: false}}, bidderRequest); + const request = spec.buildRequests(bidRequests, bidderRequestWithGDPR); + 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 bidderRequestWithGDPR = Object.assign({gdprConsent: {consentString: 'AAA'}}, bidderRequest); + const request = spec.buildRequests(bidRequests, bidderRequestWithGDPR); + 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 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({}, + bidRequests[1], + { + params: { + uid: '59', + keywords: { + single: 'val', + singleArr: ['val'], + singleArrNum: [5], + multiValMixed: ['value1', 2, 'value3'], + singleValNum: 123, + emptyStr: '', + emptyArr: [''], + badValue: {'foo': 'bar'} // should be dropped + } + } + } + ); + + const request = spec.buildRequests(bidRequestWithKeywords, bidderRequest); + expect(request.data).to.be.an('string'); + const payload = parseRequest(request.data); + expect(payload.keywords).to.be.an('string'); + payload.keywords = JSON.parse(payload.keywords); + + expect(payload.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'] + }, { + 'key': 'emptyStr' + }, { + 'key': 'emptyArr' + }]); + }); + }); + + describe('interpretResponse', function () { + const responses = [ + {'bid': [{'price': 1.15, 'adm': '
test content 1
', 'auid': 59, 'h': 250, 'w': 300}], 'seat': '1'}, + {'bid': [{'price': 0.5, 'adm': '
test content 2
', 'auid': 60, 'h': 600, 'w': 300}], 'seat': '1'}, + {'bid': [{'price': 0.15, 'adm': '
test content 3
', 'auid': 59, 'h': 90, 'w': 728}], 'seat': '1'}, + {'bid': [{'price': 0, 'auid': 61, 'h': 250, 'w': 300}], 'seat': '1'}, + {'bid': [{'price': 0, 'adm': '
test content 5
', 'h': 250, 'w': 300}], 'seat': '1'}, + undefined, + {'bid': [], 'seat': '1'}, + {'seat': '1'}, + ]; + + it('should get correct bid response', function () { + const bidRequests = [ + { + 'bidder': 'converge', + 'params': { + 'uid': '59' + }, + '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': 59, + 'dealId': undefined, + 'width': 300, + 'height': 250, + 'ad': '
test content 1
', + 'bidderCode': 'converge', + 'currency': 'EUR', + 'mediaType': 'banner', + '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': 'converge', + 'params': { + 'uid': '59' + }, + 'adUnitCode': 'adunit-code-1', + 'sizes': [[300, 250], [300, 600]], + 'bidId': '300bfeb0d71a5b', + 'bidderRequestId': '2c2bb1972df9a', + 'auctionId': '1fa09aee5c8c99', + }, + { + 'bidder': 'converge', + 'params': { + 'uid': '60' + }, + 'adUnitCode': 'adunit-code-1', + 'sizes': [[300, 250], [300, 600]], + 'bidId': '4dff80cc4ee346', + 'bidderRequestId': '2c2bb1972df9a', + 'auctionId': '1fa09aee5c8c99', + }, + { + 'bidder': 'converge', + 'params': { + 'uid': '59' + }, + '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': 59, + 'dealId': undefined, + 'width': 300, + 'height': 250, + 'ad': '
test content 1
', + 'bidderCode': 'converge', + 'currency': 'EUR', + 'mediaType': 'banner', + 'netRevenue': true, + 'ttl': 360, + }, + { + 'requestId': '4dff80cc4ee346', + 'cpm': 0.5, + 'creativeId': 60, + 'dealId': undefined, + 'width': 300, + 'height': 600, + 'ad': '
test content 2
', + 'bidderCode': 'converge', + 'currency': 'EUR', + 'mediaType': 'banner', + 'netRevenue': true, + 'ttl': 360, + }, + { + 'requestId': '5703af74d0472a', + 'cpm': 0.15, + 'creativeId': 59, + 'dealId': undefined, + 'width': 728, + 'height': 90, + 'ad': '
test content 3
', + 'bidderCode': 'converge', + 'currency': 'EUR', + 'mediaType': 'banner', + 'netRevenue': true, + 'ttl': 360, + } + ]; + + const result = spec.interpretResponse({'body': {'seatbid': responses.slice(0, 3)}}, request); + expect(result).to.deep.equal(expectedResponse); + }); + + it('handles wrong and nobid responses', function () { + const bidRequests = [ + { + 'bidder': 'converge', + 'params': { + 'uid': '61' + }, + 'adUnitCode': 'adunit-code-1', + 'sizes': [[300, 250], [300, 600]], + 'bidId': '300bfeb0d7190gf', + 'bidderRequestId': '2c2bb1972d23af', + 'auctionId': '1fa09aee5c84d34', + }, + { + 'bidder': 'converge', + 'params': { + 'uid': '65' + }, + 'adUnitCode': 'adunit-code-1', + 'sizes': [[300, 250], [300, 600]], + 'bidId': '300bfeb0d71321', + 'bidderRequestId': '2c2bb1972d23af', + 'auctionId': '1fa09aee5c84d34', + }, + { + 'bidder': 'converge', + 'params': { + 'uid': '70' + }, + '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(3)}}, request); + expect(result.length).to.equal(0); + }); + + it('complicated case', function () { + const fullResponse = [ + {'bid': [{'price': 1.15, 'adm': '
test content 1
', 'auid': 59, 'h': 250, 'w': 300}], 'seat': '1'}, + {'bid': [{'price': 0.5, 'adm': '
test content 2
', 'auid': 60, 'h': 600, 'w': 300}], 'seat': '1'}, + {'bid': [{'price': 0.15, 'adm': '
test content 3
', 'auid': 59, 'h': 90, 'w': 728}], 'seat': '1'}, + {'bid': [{'price': 0.15, 'adm': '
test content 4
', 'auid': 59, 'h': 600, 'w': 300}], 'seat': '1'}, + {'bid': [{'price': 0.5, 'adm': '
test content 5
', 'auid': 60, 'h': 600, 'w': 350}], 'seat': '1'}, + ]; + const bidRequests = [ + { + 'bidder': 'converge', + 'params': { + 'uid': '59' + }, + 'adUnitCode': 'adunit-code-1', + 'sizes': [[300, 250], [300, 600]], + 'bidId': '2164be6358b9', + 'bidderRequestId': '106efe3247', + 'auctionId': '32a1f276cb87cb8', + }, + { + 'bidder': 'converge', + 'params': { + 'uid': '59' + }, + 'adUnitCode': 'adunit-code-1', + 'sizes': [[300, 250], [300, 600]], + 'bidId': '326bde7fbf69', + 'bidderRequestId': '106efe3247', + 'auctionId': '32a1f276cb87cb8', + }, + { + 'bidder': 'converge', + 'params': { + 'uid': '60' + }, + 'adUnitCode': 'adunit-code-1', + 'sizes': [[300, 250], [300, 600]], + 'bidId': '4e111f1b66e4', + 'bidderRequestId': '106efe3247', + 'auctionId': '32a1f276cb87cb8', + }, + { + 'bidder': 'converge', + 'params': { + 'uid': '59' + }, + 'adUnitCode': 'adunit-code-2', + 'sizes': [[728, 90]], + 'bidId': '26d6f897b516', + 'bidderRequestId': '106efe3247', + 'auctionId': '32a1f276cb87cb8', + }, + { + 'bidder': 'converge', + 'params': { + 'uid': '60' + }, + 'adUnitCode': 'adunit-code-2', + 'sizes': [[728, 90]], + 'bidId': '1751cd90161', + 'bidderRequestId': '106efe3247', + 'auctionId': '32a1f276cb87cb8', + } + ]; + const request = spec.buildRequests(bidRequests); + const expectedResponse = [ + { + 'requestId': '2164be6358b9', + 'cpm': 1.15, + 'creativeId': 59, + 'dealId': undefined, + 'width': 300, + 'height': 250, + 'ad': '
test content 1
', + 'bidderCode': 'converge', + 'currency': 'EUR', + 'mediaType': 'banner', + 'netRevenue': true, + 'ttl': 360, + }, + { + 'requestId': '4e111f1b66e4', + 'cpm': 0.5, + 'creativeId': 60, + 'dealId': undefined, + 'width': 300, + 'height': 600, + 'ad': '
test content 2
', + 'bidderCode': 'converge', + 'currency': 'EUR', + 'mediaType': 'banner', + 'netRevenue': true, + 'ttl': 360, + }, + { + 'requestId': '26d6f897b516', + 'cpm': 0.15, + 'creativeId': 59, + 'dealId': undefined, + 'width': 728, + 'height': 90, + 'ad': '
test content 3
', + 'bidderCode': 'converge', + 'currency': 'EUR', + 'mediaType': 'banner', + 'netRevenue': true, + 'ttl': 360, + }, + { + 'requestId': '326bde7fbf69', + 'cpm': 0.15, + 'creativeId': 59, + 'dealId': undefined, + 'width': 300, + 'height': 600, + 'ad': '
test content 4
', + 'bidderCode': 'converge', + 'currency': 'EUR', + 'mediaType': 'banner', + 'netRevenue': true, + 'ttl': 360, + } + ]; + + const result = spec.interpretResponse({'body': {'seatbid': fullResponse}}, request); + expect(result).to.deep.equal(expectedResponse); + }); + + it('dublicate uids and sizes in one slot', function () { + const fullResponse = [ + {'bid': [{'price': 1.15, 'adm': '
test content 1
', 'auid': 59, 'h': 250, 'w': 300}], 'seat': '1'}, + {'bid': [{'price': 0.5, 'adm': '
test content 2
', 'auid': 59, 'h': 250, 'w': 300}], 'seat': '1'}, + ]; + const bidRequests = [ + { + 'bidder': 'converge', + 'params': { + 'uid': '59' + }, + 'adUnitCode': 'adunit-code-1', + 'sizes': [[300, 250], [300, 600]], + 'bidId': '5126e301f4be', + 'bidderRequestId': '171c5405a390', + 'auctionId': '35bcbc0f7e79c', + }, + { + 'bidder': 'converge', + 'params': { + 'uid': '59' + }, + 'adUnitCode': 'adunit-code-1', + 'sizes': [[300, 250], [300, 600]], + 'bidId': '57b2ebe70e16', + 'bidderRequestId': '171c5405a390', + 'auctionId': '35bcbc0f7e79c', + }, + { + 'bidder': 'converge', + 'params': { + 'uid': '59' + }, + 'adUnitCode': 'adunit-code-1', + 'sizes': [[300, 250], [300, 600]], + 'bidId': '225fcd44b18c', + 'bidderRequestId': '171c5405a390', + 'auctionId': '35bcbc0f7e79c', + } + ]; + const request = spec.buildRequests(bidRequests); + const expectedResponse = [ + { + 'requestId': '5126e301f4be', + 'cpm': 1.15, + 'creativeId': 59, + 'dealId': undefined, + 'width': 300, + 'height': 250, + 'ad': '
test content 1
', + 'bidderCode': 'converge', + 'currency': 'EUR', + 'mediaType': 'banner', + 'netRevenue': true, + 'ttl': 360, + }, + { + 'requestId': '57b2ebe70e16', + 'cpm': 0.5, + 'creativeId': 59, + 'dealId': undefined, + 'width': 300, + 'height': 250, + 'ad': '
test content 2
', + 'bidderCode': 'converge', + 'currency': 'EUR', + 'mediaType': 'banner', + 'netRevenue': true, + 'ttl': 360, + } + ]; + + const result = spec.interpretResponse({'body': {'seatbid': fullResponse}}, request); + expect(result).to.deep.equal(expectedResponse); + }); + }); + + it('should get correct video bid response', function () { + const bidRequests = [ + { + 'bidder': 'converge', + 'params': { + 'uid': '58' + }, + 'adUnitCode': 'adunit-code-1', + 'sizes': [[300, 250], [300, 600]], + 'bidId': '57dfefb80eca', + 'bidderRequestId': '20394420a762a2', + 'auctionId': '140132d07b031', + 'mediaTypes': { + 'video': { + 'context': 'instream' + } + } + }, + { + 'bidder': 'converge', + 'params': { + 'uid': '60' + }, + 'adUnitCode': 'adunit-code-1', + 'sizes': [[300, 250], [300, 600]], + 'bidId': 'e893c787c22dd', + 'bidderRequestId': '20394420a762a2', + 'auctionId': '140132d07b031', + 'mediaTypes': { + 'video': { + 'context': 'instream' + } + } + } + ]; + const response = [ + {'bid': [{'price': 1.15, 'adm': '\n<\/Ad>\n<\/VAST>', 'auid': 58, content_type: 'video', w: 300, h: 600}], 'seat': '2'}, + {'bid': [{'price': 1.00, 'adm': '\n<\/Ad>\n<\/VAST>', 'auid': 60, content_type: 'video'}], 'seat': '2'} + ]; + const request = spec.buildRequests(bidRequests); + const expectedResponse = [ + { + 'requestId': '57dfefb80eca', + 'cpm': 1.15, + 'creativeId': 58, + 'dealId': undefined, + 'width': 300, + 'height': 600, + 'bidderCode': 'converge', + 'currency': 'EUR', + 'mediaType': 'video', + 'netRevenue': true, + 'ttl': 360, + 'vastXml': '\n<\/Ad>\n<\/VAST>', + 'adResponse': { + 'content': '\n<\/Ad>\n<\/VAST>' + } + } + ]; + + const result = spec.interpretResponse({'body': {'seatbid': response}}, request); + expect(result).to.deep.equal(expectedResponse); + }); + + it('should have right renderer in the bid response', function () { + const spySetRenderer = sinon.spy(); + const stubRenderer = { + setRender: spySetRenderer + }; + const spyRendererInstall = sinon.spy(function() { return stubRenderer; }); + const stubRendererConst = { + install: spyRendererInstall + }; + const bidRequests = [ + { + 'bidder': 'converge', + 'params': { + 'uid': '58' + }, + 'adUnitCode': 'adunit-code-1', + 'sizes': [[300, 250], [300, 600]], + 'bidId': 'e6e65553fc8', + 'bidderRequestId': '1380f393215dc7', + 'auctionId': '10b8d2f3c697e3', + 'mediaTypes': { + 'video': { + 'context': 'outstream' + } + } + }, + { + 'bidder': 'converge', + 'params': { + 'uid': '60' + }, + 'adUnitCode': 'adunit-code-1', + 'sizes': [[300, 250], [300, 600]], + 'bidId': 'c8fdcb3f269f', + 'bidderRequestId': '1380f393215dc7', + 'auctionId': '10b8d2f3c697e3' + }, + { + 'bidder': 'converge', + 'params': { + 'uid': '61' + }, + 'adUnitCode': 'adunit-code-1', + 'sizes': [[300, 250], [300, 600]], + 'bidId': '1de036c37685', + 'bidderRequestId': '1380f393215dc7', + 'auctionId': '10b8d2f3c697e3', + 'renderer': {} + } + ]; + const response = [ + {'bid': [{'price': 1.15, 'adm': '\n<\/Ad>\n<\/VAST>', 'auid': 58, content_type: 'video', w: 300, h: 600}], 'seat': '2'}, + {'bid': [{'price': 1.00, 'adm': '\n<\/Ad>\n<\/VAST>', 'auid': 60, content_type: 'video', w: 300, h: 250}], 'seat': '2'}, + {'bid': [{'price': 1.20, 'adm': '\n<\/Ad>\n<\/VAST>', 'auid': 61, content_type: 'video', w: 300, h: 250}], 'seat': '2'} + ]; + const request = spec.buildRequests(bidRequests); + const expectedResponse = [ + { + 'requestId': 'e6e65553fc8', + 'cpm': 1.15, + 'creativeId': 58, + 'dealId': undefined, + 'width': 300, + 'height': 600, + 'bidderCode': 'converge', + 'currency': 'EUR', + 'mediaType': 'video', + 'netRevenue': true, + 'ttl': 360, + 'vastXml': '\n<\/Ad>\n<\/VAST>', + 'adResponse': { + 'content': '\n<\/Ad>\n<\/VAST>' + }, + 'renderer': stubRenderer + }, + { + 'requestId': 'c8fdcb3f269f', + 'cpm': 1.00, + 'creativeId': 60, + 'dealId': undefined, + 'width': 300, + 'height': 250, + 'bidderCode': 'converge', + 'currency': 'EUR', + 'mediaType': 'video', + 'netRevenue': true, + 'ttl': 360, + 'vastXml': '\n<\/Ad>\n<\/VAST>', + 'adResponse': { + 'content': '\n<\/Ad>\n<\/VAST>' + }, + 'renderer': stubRenderer + }, + { + 'requestId': '1de036c37685', + 'cpm': 1.20, + 'creativeId': 61, + 'dealId': undefined, + 'width': 300, + 'height': 250, + 'bidderCode': 'converge', + 'currency': 'EUR', + 'mediaType': 'video', + 'netRevenue': true, + 'ttl': 360, + 'vastXml': '\n<\/Ad>\n<\/VAST>', + 'adResponse': { + 'content': '\n<\/Ad>\n<\/VAST>' + } + } + ]; + + const result = spec.interpretResponse({'body': {'seatbid': response}}, request, stubRendererConst); + + expect(spySetRenderer.calledTwice).to.equal(true); + expect(spySetRenderer.getCall(0).args[0]).to.be.a('function'); + expect(spySetRenderer.getCall(1).args[0]).to.be.a('function'); + + expect(spyRendererInstall.calledTwice).to.equal(true); + expect(spyRendererInstall.getCall(0).args[0]).to.deep.equal({ + id: 'e6e65553fc8', + url: 'https://acdn.adnxs.com/video/outstream/ANOutstreamVideo.js', + loaded: false + }); + expect(spyRendererInstall.getCall(1).args[0]).to.deep.equal({ + id: 'c8fdcb3f269f', + url: 'https://acdn.adnxs.com/video/outstream/ANOutstreamVideo.js', + loaded: false + }); + + expect(result).to.deep.equal(expectedResponse); + }); + + describe('user sync', function () { + const syncUrl = getSyncUrl(); + + beforeEach(function () { + resetUserSync(); + }); + + it('should register sync image', function () { + let syncs = spec.getUserSyncs({ + pixelEnabled: true + }); + + expect(syncs).to.deep.equal({type: 'image', url: syncUrl}); + }); + + it('should not register sync image more than once', function () { + let syncs = spec.getUserSyncs({ + pixelEnabled: true + }); + expect(syncs).to.deep.equal({type: 'image', url: syncUrl}); + + // when called again, should still have only been called once + syncs = spec.getUserSyncs(); + expect(syncs).to.equal(undefined); + }); + + it('should pass gdpr params if consent is true', function () { + expect(spec.getUserSyncs({ pixelEnabled: true }, {}, { + gdprApplies: true, consentString: 'foo' + })).to.deep.equal({ + type: 'image', url: `${syncUrl}&gdpr=1&gdpr_consent=foo` + }); + }); + + it('should pass gdpr params if consent is false', function () { + expect(spec.getUserSyncs({ pixelEnabled: true }, {}, { + gdprApplies: false, consentString: 'foo' + })).to.deep.equal({ + type: 'image', url: `${syncUrl}&gdpr=0&gdpr_consent=foo` + }); + }); + + it('should pass gdpr param gdpr_consent only when gdprApplies is undefined', function () { + expect(spec.getUserSyncs({ pixelEnabled: true }, {}, { + consentString: 'foo' + })).to.deep.equal({ + type: 'image', url: `${syncUrl}&gdpr_consent=foo` + }); + }); + + it('should pass no params if gdpr consentString is not defined', function () { + expect(spec.getUserSyncs({ pixelEnabled: true }, {}, {})).to.deep.equal({ + type: 'image', url: syncUrl + }); + }); + + it('should pass no params if gdpr consentString is a number', function () { + expect(spec.getUserSyncs({ pixelEnabled: true }, {}, { + consentString: 0 + })).to.deep.equal({ + type: 'image', url: syncUrl + }); + }); + + it('should pass no params if gdpr consentString is null', function () { + expect(spec.getUserSyncs({ pixelEnabled: true }, {}, { + consentString: null + })).to.deep.equal({ + type: 'image', url: syncUrl + }); + }); + + it('should pass no params if gdpr consentString is a object', function () { + expect(spec.getUserSyncs({ pixelEnabled: true }, {}, { + consentString: {} + })).to.deep.equal({ + type: 'image', url: syncUrl + }); + }); + + it('should pass no params if gdpr is not defined', function () { + expect(spec.getUserSyncs({ pixelEnabled: true }, {}, undefined)).to.deep.equal({ + type: 'image', url: syncUrl + }); + }); + + it('should pass usPrivacy param if it is available', function() { + expect(spec.getUserSyncs({ pixelEnabled: true }, {}, {}, '1YNN')).to.deep.equal({ + type: 'image', url: `${syncUrl}&us_privacy=1YNN` + }); + }); + }); +}); diff --git a/test/spec/modules/conversantBidAdapter_spec.js b/test/spec/modules/conversantBidAdapter_spec.js index 67dd721a059..7c6d6e5dd6c 100644 --- a/test/spec/modules/conversantBidAdapter_spec.js +++ b/test/spec/modules/conversantBidAdapter_spec.js @@ -1,6 +1,7 @@ import {expect} from 'chai'; -import {spec} from 'modules/conversantBidAdapter'; -import * as utils from 'src/utils'; +import {spec, storage} from 'modules/conversantBidAdapter.js'; +import * as utils from 'src/utils.js'; +import { createEidsArray } from 'modules/userId/eids.js'; describe('Conversant adapter tests', function() { const siteId = '108060'; @@ -320,6 +321,12 @@ describe('Conversant adapter tests', function() { expect(payload).to.not.have.property('user'); // there should be no user by default }); + it('Verify override url', function() { + const testUrl = 'https://someurl?name=value'; + const request = spec.buildRequests([{params: {white_label_url: testUrl}}]); + expect(request.url).to.equal(testUrl); + }); + it('Verify interpretResponse', function() { const request = spec.buildRequests(bidRequests); const response = spec.interpretResponse(bidResponses, request); @@ -395,6 +402,7 @@ describe('Conversant adapter tests', function() { // add pubcid to every entry requests.forEach((unit) => { Object.assign(unit, {userId: {pubcid: 67890}}); + Object.assign(unit, {userIdAsEids: createEidsArray(unit.userId)}); }); // construct http post payload const payload = spec.buildRequests(requests).data; @@ -468,13 +476,14 @@ describe('Conversant adapter tests', function() { // add pubcid to every entry requests.forEach((unit) => { - Object.assign(unit, {userId: {pubcid: 112233, tdid: 223344, idl_env: 334455}}); + Object.assign(unit, {userId: {pubcid: '112233', tdid: '223344', idl_env: '334455'}}); + Object.assign(unit, {userIdAsEids: createEidsArray(unit.userId)}); }); // construct http post payload const payload = spec.buildRequests(requests).data; expect(payload).to.have.deep.nested.property('user.ext.eids', [ - {source: 'adserver.org', uids: [{id: 223344, atype: 1}]}, - {source: 'liveramp.com', uids: [{id: 334455, atype: 1}]} + {source: 'adserver.org', uids: [{id: '223344', atype: 1, ext: {rtiPartner: 'TDID'}}]}, + {source: 'liveramp.com', uids: [{id: '334455', atype: 1}]} ]); }); }); @@ -505,7 +514,7 @@ describe('Conversant adapter tests', function() { const requests = utils.deepClone(bidRequests); // add a pubcid cookie - utils.setCookie(ID_NAME, '12345', expStr(TIMEOUT)); + storage.setCookie(ID_NAME, '12345', expStr(TIMEOUT)); // construct http post payload const payload = spec.buildRequests(requests).data; @@ -518,7 +527,7 @@ describe('Conversant adapter tests', function() { requests[0].params.pubcid_name = CUSTOM_ID_NAME; // add a pubcid cookie - utils.setCookie(CUSTOM_ID_NAME, '12345', expStr(TIMEOUT)); + storage.setCookie(CUSTOM_ID_NAME, '12345', expStr(TIMEOUT)); // construct http post payload const payload = spec.buildRequests(requests).data; @@ -530,8 +539,8 @@ describe('Conversant adapter tests', function() { const requests = utils.deepClone(bidRequests); // add a pubcid in local storage - utils.setDataInLocalStorage(ID_NAME + EXP, ''); - utils.setDataInLocalStorage(ID_NAME, 'abcde'); + storage.setDataInLocalStorage(ID_NAME + EXP, ''); + storage.setDataInLocalStorage(ID_NAME, 'abcde'); // construct http post payload const payload = spec.buildRequests(requests).data; @@ -543,8 +552,8 @@ describe('Conversant adapter tests', function() { const requests = utils.deepClone(bidRequests); // add a pubcid in local storage - utils.setDataInLocalStorage(ID_NAME + EXP, expStr(TIMEOUT)); - utils.setDataInLocalStorage(ID_NAME, 'fghijk'); + storage.setDataInLocalStorage(ID_NAME + EXP, expStr(TIMEOUT)); + storage.setDataInLocalStorage(ID_NAME, 'fghijk'); // construct http post payload const payload = spec.buildRequests(requests).data; @@ -556,8 +565,8 @@ describe('Conversant adapter tests', function() { const requests = utils.deepClone(bidRequests); // add a pubcid in local storage - utils.setDataInLocalStorage(ID_NAME + EXP, expStr(-TIMEOUT)); - utils.setDataInLocalStorage(ID_NAME, 'lmnopq'); + storage.setDataInLocalStorage(ID_NAME + EXP, expStr(-TIMEOUT)); + storage.setDataInLocalStorage(ID_NAME, 'lmnopq'); // construct http post payload const payload = spec.buildRequests(requests).data; @@ -570,8 +579,8 @@ describe('Conversant adapter tests', function() { requests[0].params.pubcid_name = CUSTOM_ID_NAME; // add a pubcid in local storage - utils.setDataInLocalStorage(CUSTOM_ID_NAME + EXP, expStr(TIMEOUT)); - utils.setDataInLocalStorage(CUSTOM_ID_NAME, 'fghijk'); + storage.setDataInLocalStorage(CUSTOM_ID_NAME + EXP, expStr(TIMEOUT)); + storage.setDataInLocalStorage(CUSTOM_ID_NAME, 'fghijk'); // construct http post payload const payload = spec.buildRequests(requests).data; diff --git a/test/spec/modules/cosmosBidAdapter_spec.js b/test/spec/modules/cosmosBidAdapter_spec.js index 348f5ae3ddf..b33f53221e2 100644 --- a/test/spec/modules/cosmosBidAdapter_spec.js +++ b/test/spec/modules/cosmosBidAdapter_spec.js @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import { spec } from 'modules/cosmosBidAdapter'; -import * as utils from 'src/utils'; +import { spec } from 'modules/cosmosBidAdapter.js'; +import * as utils from 'src/utils.js'; const constants = require('src/constants.json'); describe('Cosmos adapter', function () { @@ -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 3dd06a484d9..9e794d3e098 100755 --- a/test/spec/modules/cpmstarBidAdapter_spec.js +++ b/test/spec/modules/cpmstarBidAdapter_spec.js @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import { spec } from 'modules/cpmstarBidAdapter'; -import { deepClone } from 'src/utils'; +import { spec } from 'modules/cpmstarBidAdapter.js'; +import { deepClone } from 'src/utils.js'; describe('Cpmstar Bid Adapter', function () { describe('isBidRequestValid', function () { @@ -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/criteoBidAdapter_spec.js b/test/spec/modules/criteoBidAdapter_spec.js index e5d789ff60d..042f1a4d61d 100755 --- a/test/spec/modules/criteoBidAdapter_spec.js +++ b/test/spec/modules/criteoBidAdapter_spec.js @@ -1,23 +1,26 @@ import { expect } from 'chai'; -import { tryGetCriteoFastBid, spec, PROFILE_ID_PUBLISHERTAG, ADAPTER_VERSION, PUBLISHER_TAG_URL } from 'modules/criteoBidAdapter'; -import { createBid } from 'src/bidfactory'; +import { tryGetCriteoFastBid, spec, PROFILE_ID_PUBLISHERTAG, ADAPTER_VERSION } from 'modules/criteoBidAdapter.js'; +import { createBid } from 'src/bidfactory.js'; import CONSTANTS from 'src/constants.json'; -import * as utils from 'src/utils'; -import { config } from '../../../src/config'; -import { VIDEO } from '../../../src/mediaTypes'; +import * as utils from 'src/utils.js'; +import { config } from '../../../src/config.js'; +import { NATIVE, VIDEO } from '../../../src/mediaTypes.js'; describe('The Criteo bidding adapter', function () { - let utilsMock; + let utilsMock, sandbox; beforeEach(function () { // Remove FastBid to avoid side effects localStorage.removeItem('criteo_fast_bid'); utilsMock = sinon.mock(utils); + + sandbox = sinon.sandbox.create(); }); afterEach(function() { global.Criteo = undefined; utilsMock.restore(); + sandbox.restore(); }); describe('isBidRequestValid', function () { @@ -382,6 +385,7 @@ describe('The Criteo bidding adapter', function () { '91': 1 }, }, + apiVersion: 1, }, }; @@ -433,7 +437,7 @@ describe('The Criteo bidding adapter', function () { expect(ortbRequest.slots[0].zoneid).to.equal(123); expect(ortbRequest.gdprConsent.consentData).to.equal('concentDataString'); expect(ortbRequest.gdprConsent.gdprApplies).to.equal(true); - expect(ortbRequest.gdprConsent.consentGiven).to.equal(true); + expect(ortbRequest.gdprConsent.version).to.equal(1); }); it('should properly build a networkId request', function () { @@ -481,7 +485,6 @@ describe('The Criteo bidding adapter', function () { expect(ortbRequest.slots[0].sizes[1]).to.equal('728x90'); expect(ortbRequest.gdprConsent.consentData).to.equal(undefined); expect(ortbRequest.gdprConsent.gdprApplies).to.equal(false); - expect(ortbRequest.gdprConsent.consentGiven).to.equal(undefined); }); it('should properly build a mixed request', function () { @@ -530,7 +533,7 @@ describe('The Criteo bidding adapter', function () { expect(ortbRequest.gdprConsent).to.equal(undefined); }); - it('should properly build request with undefined gdpr consent fields when they are not provided', function () { + it('should properly build a request with undefined gdpr consent fields when they are not provided', function () { const bidRequests = [ { bidder: 'criteo', @@ -550,7 +553,49 @@ describe('The Criteo bidding adapter', function () { const ortbRequest = spec.buildRequests(bidRequests, bidderRequest).data; expect(ortbRequest.gdprConsent.consentData).to.equal(undefined); expect(ortbRequest.gdprConsent.gdprApplies).to.equal(undefined); - expect(ortbRequest.gdprConsent.consentGiven).to.equal(undefined); + }); + + it('should properly build a request with ccpa consent field', function () { + const bidRequests = [ + { + bidder: 'criteo', + adUnitCode: 'bid-123', + transactionId: 'transaction-123', + sizes: [[728, 90]], + params: { + zoneId: 123, + }, + }, + ]; + const bidderRequest = { + timeout: 3000, + uspConsent: '1YNY', + }; + + const request = spec.buildRequests(bidRequests, bidderRequest); + expect(request.data.user).to.not.be.null; + expect(request.data.user.uspIab).to.equal('1YNY'); + }); + + it('should properly build a request with if ccpa consent field is not provided', function () { + const bidRequests = [ + { + bidder: 'criteo', + adUnitCode: 'bid-123', + transactionId: 'transaction-123', + sizes: [[728, 90]], + params: { + zoneId: 123, + }, + }, + ]; + const bidderRequest = { + timeout: 3000 + }; + + const request = spec.buildRequests(bidRequests, bidderRequest); + expect(request.data.user).to.not.be.null; + expect(request.data.user.uspIab).to.equal(undefined); }); it('should properly build a video request', function () { @@ -662,6 +707,115 @@ describe('The Criteo bidding adapter', function () { expect(request.data.user).to.not.be.null; expect(request.data.user.ceh).to.equal('hashedemail'); }); + + it('should properly build a request without first party data', function () { + const bidRequests = [ + { + bidder: 'criteo', + adUnitCode: 'bid-123', + transactionId: 'transaction-123', + sizes: [[728, 90]], + params: { + zoneId: 123 + } + }, + ]; + + sandbox.stub(config, 'getConfig').callsFake(key => { + const config = { + }; + return utils.deepAccess(config, key); + }); + + const request = spec.buildRequests(bidRequests, bidderRequest); + expect(request.data.publisher.ext).to.equal(undefined); + expect(request.data.user.ext).to.equal(undefined); + expect(request.data.slots[0].ext).to.equal(undefined); + }); + + it('should properly build a request with criteo specific ad unit first party data', function () { + const bidRequests = [ + { + bidder: 'criteo', + adUnitCode: 'bid-123', + transactionId: 'transaction-123', + sizes: [[728, 90]], + params: { + zoneId: 123, + ext: { + bidfloor: 0.75 + } + } + }, + ]; + + sandbox.stub(config, 'getConfig').callsFake(key => { + const config = { + }; + return utils.deepAccess(config, key); + }); + + const request = spec.buildRequests(bidRequests, bidderRequest); + expect(request.data.slots[0].ext).to.deep.equal({ + bidfloor: 0.75, + }); + }); + + it('should properly build a request with first party data', function () { + const contextData = { + keywords: ['power tools'], + data: { + pageType: 'article' + } + }; + const userData = { + gender: 'M', + data: { + registered: true + } + }; + const bidRequests = [ + { + bidder: 'criteo', + adUnitCode: 'bid-123', + transactionId: 'transaction-123', + sizes: [[728, 90]], + params: { + zoneId: 123, + ext: { + bidfloor: 0.75 + } + }, + fpd: { + context: { + data: { + someContextAttribute: 'abc' + } + } + } + }, + ]; + + sandbox.stub(config, 'getConfig').callsFake(key => { + const config = { + fpd: { + context: contextData, + user: userData + } + }; + return utils.deepAccess(config, key); + }); + + const request = spec.buildRequests(bidRequests, bidderRequest); + expect(request.data.publisher.ext).to.deep.equal(contextData); + expect(request.data.user.ext).to.deep.equal(userData); + expect(request.data.slots[0].ext).to.deep.equal({ + bidfloor: 0.75, + data: { + someContextAttribute: 'abc' + } + }); + }); }); describe('interpretResponse', function () { @@ -704,7 +858,7 @@ describe('The Criteo bidding adapter', function () { expect(bids[0].dealId).to.equal('myDealCode'); }); - it('should properly parse a bid responsewith with a zoneId', function () { + it('should properly parse a bid response with a zoneId', function () { const response = { body: { slots: [{ @@ -737,7 +891,7 @@ describe('The Criteo bidding adapter', function () { expect(bids[0].height).to.equal(90); }); - it('should properly parse a bid responsewith with a video', function () { + it('should properly parse a bid response with a video', function () { const response = { body: { slots: [{ @@ -770,7 +924,120 @@ describe('The Criteo bidding adapter', function () { expect(bids[0].mediaType).to.equal(VIDEO); }); - it('should properly parse a bid responsewith with a zoneId passed as a string', function () { + it('should properly parse a bid response with native', function () { + const response = { + body: { + slots: [{ + impid: 'test-requestId', + bidId: 'abc123', + cpm: 1.23, + width: 728, + height: 90, + zoneid: 123, + native: { + 'products': [{ + 'title': 'Product title', + 'description': 'Product desc', + 'price': '100', + 'click_url': 'https://product.click', + 'image': { + 'url': 'https://publisherdirect.criteo.com/publishertag/preprodtest/creative.png', + 'height': 300, + 'width': 300 + }, + 'call_to_action': 'Try it now!' + }], + 'advertiser': { + 'description': 'sponsor', + 'domain': 'criteo.com', + 'logo': {'url': 'https://www.criteo.com/images/criteo-logo.svg', 'height': 300, 'width': 300} + }, + 'privacy': { + 'optout_click_url': 'https://info.criteo.com/privacy/informations', + 'optout_image_url': 'https://static.criteo.net/flash/icon/nai_small.png', + }, + 'impression_pixels': [{'url': 'https://my-impression-pixel/test/impression'}, {'url': 'https://cas.com/lg.com'}] + } + }], + }, + }; + const request = { + bidRequests: [{ + adUnitCode: 'test-requestId', + bidId: 'test-bidId', + params: { + zoneId: 123, + }, + native: true, + }] + }; + config.setConfig({'enableSendAllBids': false}); + const bids = spec.interpretResponse(response, request); + expect(bids).to.have.lengthOf(1); + expect(bids[0].requestId).to.equal('test-bidId'); + expect(bids[0].adId).to.equal('abc123'); + expect(bids[0].cpm).to.equal(1.23); + expect(bids[0].mediaType).to.equal(NATIVE); + }); + + it('should not parse bid response with native when enableSendAllBids is true', function () { + const response = { + body: { + slots: [{ + impid: 'test-requestId', + bidId: 'abc123', + cpm: 1.23, + width: 728, + height: 90, + zoneid: 123, + native: {} + }], + }, + }; + const request = { + bidRequests: [{ + adUnitCode: 'test-requestId', + bidId: 'test-bidId', + params: { + zoneId: 123, + }, + native: true, + }] + }; + config.setConfig({'enableSendAllBids': true}); + const bids = spec.interpretResponse(response, request); + expect(bids).to.have.lengthOf(0); + }); + + it('should not parse bid response with native when enableSendAllBids is not set', function () { + const response = { + body: { + slots: [{ + impid: 'test-requestId', + bidId: 'abc123', + cpm: 1.23, + width: 728, + height: 90, + zoneid: 123, + native: {} + }], + }, + }; + const request = { + bidRequests: [{ + adUnitCode: 'test-requestId', + bidId: 'test-bidId', + params: { + zoneId: 123, + }, + native: true, + }] + }; + const bids = spec.interpretResponse(response, request); + expect(bids).to.have.lengthOf(0); + }); + + it('should properly parse a bid response with a zoneId passed as a string', function () { const response = { body: { slots: [{ @@ -850,6 +1117,7 @@ describe('The Criteo bidding adapter', function () { utilsMock.expects('logInfo').withExactArgs('Using Criteo FastBid').once(); utilsMock.expects('logWarn').withExactArgs('No hash found in FastBid').never(); utilsMock.expects('logWarn').withExactArgs('Invalid Criteo FastBid found').never(); + utilsMock.expects('insertElement').once(); tryGetCriteoFastBid(); @@ -897,6 +1165,132 @@ describe('The Criteo bidding adapter', function () { }); }); + describe('when pubtag prebid adapter is not available', function () { + it('should not warn if sendId is provided on required fields for native bidRequest', () => { + const bidderRequest = { }; + const bidRequestsWithSendId = [ + { + bidder: 'criteo', + adUnitCode: 'bid-123', + transactionId: 'transaction-123', + sizes: [[728, 90]], + params: { + zoneId: 123, + publisherSubId: '123', + nativeCallback: function() {} + }, + nativeParams: { + image: { + sendId: true + }, + icon: { + sendId: true + }, + clickUrl: { + sendId: true + }, + displayUrl: { + sendId: true + }, + privacyLink: { + sendId: true + }, + privacyIcon: { + sendId: true + } + } + } + ]; + + utilsMock.expects('logWarn').withArgs('Criteo: all native assets containing URL should be sent as placeholders with sendId(icon, image, clickUrl, displayUrl, privacyLink, privacyIcon)').never(); + const request = spec.buildRequests(bidRequestsWithSendId, bidderRequest); + utilsMock.verify(); + }); + + it('should warn only once if sendId is not provided on required fields for native bidRequest', () => { + const bidderRequest = { }; + const bidRequests = [ + { + bidder: 'criteo', + adUnitCode: 'bid-123', + transactionId: 'transaction-123', + sizes: [[728, 90]], + params: { + zoneId: 123, + publisherSubId: '123', + nativeCallback: function() {} + }, + }, + { + bidder: 'criteo', + adUnitCode: 'bid-456', + transactionId: 'transaction-456', + sizes: [[728, 90]], + params: { + zoneId: 456, + publisherSubId: '456', + nativeCallback: function() {} + }, + }, + ]; + + const nativeParamsWithoutSendId = [ + { + nativeParams: { + image: { + sendId: false + }, + } + }, + { + nativeParams: { + icon: { + sendId: false + }, + } + }, + { + nativeParams: { + clickUrl: { + sendId: false + }, + } + }, + { + nativeParams: { + displayUrl: { + sendId: false + }, + } + }, + { + nativeParams: { + privacyLink: { + sendId: false + }, + } + }, + { + nativeParams: { + privacyIcon: { + sendId: false + }, + } + } + ]; + + utilsMock.expects('logWarn') + .withArgs('Criteo: all native assets containing URL should be sent as placeholders with sendId(icon, image, clickUrl, displayUrl, privacyLink, privacyIcon)') + .exactly(nativeParamsWithoutSendId.length * bidRequests.length); + nativeParamsWithoutSendId.forEach(nativeParams => { + let transformedBidRequests = {...bidRequests}; + transformedBidRequests = [Object.assign(transformedBidRequests[0], nativeParams), Object.assign(transformedBidRequests[1], nativeParams)]; + spec.buildRequests(transformedBidRequests, bidderRequest); + }); + utilsMock.verify(); + }); + }); + describe('when pubtag prebid adapter is available', function () { it('should forward response to pubtag when calling interpretResponse', () => { const response = {}; diff --git a/test/spec/modules/criteoIdSystem_spec.js b/test/spec/modules/criteoIdSystem_spec.js index 44decfd56b6..aa5807da0da 100644 --- a/test/spec/modules/criteoIdSystem_spec.js +++ b/test/spec/modules/criteoIdSystem_spec.js @@ -1,7 +1,6 @@ -import { criteoIdSubmodule } from 'modules/criteoIdSystem'; -import * as utils from 'src/utils'; -import * as ajaxLib from 'src/ajax'; -import * as urlLib from 'src/url'; +import { criteoIdSubmodule, storage } from 'modules/criteoIdSystem.js'; +import * as utils from 'src/utils.js'; +import * as ajaxLib from 'src/ajax.js'; const pastDateString = new Date(0).toString() @@ -27,14 +26,14 @@ describe('CriteoId module', function () { let triggerPixelStub; beforeEach(function (done) { - getCookieStub = sinon.stub(utils, 'getCookie'); - setCookieStub = sinon.stub(utils, 'setCookie'); - getLocalStorageStub = sinon.stub(utils, 'getDataFromLocalStorage'); - setLocalStorageStub = sinon.stub(utils, 'setDataInLocalStorage'); - removeFromLocalStorageStub = sinon.stub(utils, 'removeDataFromLocalStorage'); + getCookieStub = sinon.stub(storage, 'getCookie'); + setCookieStub = sinon.stub(storage, 'setCookie'); + getLocalStorageStub = sinon.stub(storage, 'getDataFromLocalStorage'); + setLocalStorageStub = sinon.stub(storage, 'setDataInLocalStorage'); + removeFromLocalStorageStub = sinon.stub(storage, 'removeDataFromLocalStorage'); timeStampStub = sinon.stub(utils, 'timestamp').returns(nowTimestamp); ajaxBuilderStub = sinon.stub(ajaxLib, 'ajaxBuilder').callsFake(mockResponse('{}')); - parseUrlStub = sinon.stub(urlLib, 'parse').returns({protocol: 'https', hostname: 'testdev.com'}) + parseUrlStub = sinon.stub(utils, 'parseUrl').returns({protocol: 'https', hostname: 'testdev.com'}) triggerPixelStub = sinon.stub(utils, 'triggerPixel'); done(); }); @@ -132,4 +131,26 @@ describe('CriteoId module', function () { } }); })); + + const gdprConsentTestCases = [ + { consentData: { gdprApplies: true, consentString: 'expectedConsentString' }, expected: 'expectedConsentString' }, + { consentData: { gdprApplies: false, consentString: 'expectedConsentString' }, expected: undefined }, + { consentData: { gdprApplies: true, consentString: undefined }, expected: undefined }, + { consentData: { gdprApplies: 'oui', consentString: 'expectedConsentString' }, expected: undefined }, + { consentData: undefined, expected: undefined } + ]; + + gdprConsentTestCases.forEach(testCase => it('should call user sync url with the gdprConsent', function () { + const emptyObj = '{}'; + let ajaxStub = sinon.stub().callsFake((url, callback) => callback(emptyObj)); + ajaxBuilderStub.callsFake(mockResponse(undefined, ajaxStub)) + + criteoIdSubmodule.getId(undefined, testCase.consentData); + + if (testCase.expected) { + expect(ajaxStub.calledWithMatch(`gdprString=${testCase.expected}`)).to.be.true; + } else { + expect(ajaxStub.calledWithMatch('gdprString')).not.to.be.true; + } + })); }); diff --git a/test/spec/modules/criteortusIdSystem_spec.js b/test/spec/modules/criteortusIdSystem_spec.js deleted file mode 100644 index 217a2f86ba7..00000000000 --- a/test/spec/modules/criteortusIdSystem_spec.js +++ /dev/null @@ -1,90 +0,0 @@ -import { criteortusIdSubmodule } from 'modules/criteortusIdSystem'; -import * as utils from 'src/utils'; - -describe('Criteo RTUS', function() { - let xhr; - let requests; - let getCookieStub; - let logErrorStub; - - beforeEach(function () { - xhr = sinon.useFakeXMLHttpRequest(); - requests = []; - xhr.onCreate = request => requests.push(request); - getCookieStub = sinon.stub(utils, 'getCookie'); - logErrorStub = sinon.stub(utils, 'logError'); - }); - - afterEach(function () { - xhr.restore(); - getCookieStub.restore(); - logErrorStub.restore(); - }); - - it('should log error when configParams are not passed', function() { - criteortusIdSubmodule.getId(); - expect(logErrorStub.calledOnce).to.be.true; - }) - - it('should call criteo endpoint to get user id', function() { - getCookieStub.returns(null); - let configParams = { - clientIdentifier: { - 'sampleBidder': 1 - } - } - - let response = { 'status': 'ok', 'userid': 'sample-userid' } - let callBackSpy = sinon.spy(); - const idResp = criteortusIdSubmodule.getId(configParams); - const submoduleCallback = idResp.callback; - submoduleCallback(callBackSpy); - requests[0].respond( - 200, - { 'Content-Type': 'text/plain' }, - JSON.stringify(response) - ); - expect(callBackSpy.calledOnce).to.be.true; - expect(callBackSpy.calledWith({'sampleBidder': response})).to.be.true; - }) - - it('should get uid from cookie and not call endpoint', function() { - let response = {'appnexus': {'status': 'ok', 'userid': 'sample-userid'}} - getCookieStub.returns(JSON.stringify(response)); - let configParams = { - clientIdentifier: { - 'sampleBidder': 1 - } - } - let uid = criteortusIdSubmodule.getId(configParams); - expect(requests.length).to.equal(0); - }) - - it('should call criteo endpoint for multiple bidders', function() { - getCookieStub.returns(null); - let configParams = { - clientIdentifier: { - 'sampleBidder': 1, - 'sampleBidder2': 2 - } - } - - let response = { 'status': 'ok', 'userid': 'sample-userid' } - let callBackSpy = sinon.spy(); - const idResp = criteortusIdSubmodule.getId(configParams); - const submoduleCallback = idResp.callback; - submoduleCallback(callBackSpy); - requests[0].respond( - 200, - { 'Content-Type': 'text/plain' }, - JSON.stringify(response) - ); - expect(callBackSpy.calledOnce).to.be.false; - requests[1].respond( - 200, - { 'Content-Type': 'text/plain' }, - JSON.stringify(response) - ); - expect(callBackSpy.calledOnce).to.be.true; - }) -}); diff --git a/test/spec/modules/currency_spec.js b/test/spec/modules/currency_spec.js index 98f51b72251..ccd205964a9 100644 --- a/test/spec/modules/currency_spec.js +++ b/test/spec/modules/currency_spec.js @@ -1,14 +1,16 @@ import { getCurrencyRates -} from 'test/fixtures/fixtures'; +} from 'test/fixtures/fixtures.js'; + +import { getGlobal } from 'src/prebidGlobal.js'; import { setConfig, addBidResponseHook, currencySupportEnabled, currencyRates -} from 'modules/currency'; +} from 'modules/currency.js'; var assert = require('chai').assert; var expect = require('chai').expect; @@ -43,8 +45,12 @@ describe('currency', function () { it('results in currencySupportEnabled = false when currency not configured', function () { setConfig({}); expect(currencySupportEnabled).to.equal(false); + expect(getGlobal().convertCurrency).to.be.undefined; + }); + it('adds conversion function onto pbjs global var once initiated', function () { + setConfig({ 'adServerCurrency': 'JPY' }); + expect(getGlobal().convertCurrency).to.be.a('function'); }); - it('results in currencySupportEnabled = true and currencyRates being loaded when configured', function () { fakeCurrencyFileServer.respondWith(JSON.stringify(getCurrencyRates())); setConfig({ 'adServerCurrency': 'JPY' }); @@ -124,6 +130,38 @@ describe('currency', function () { }); }); + describe('global currency function', function () { + it('still returns conversion if default rates present with fetch not returned yet', function () { + setConfig({ + 'adServerCurrency': 'USD', + 'defaultRates': { + 'USD': { EUR: 2, JPY: 100 } + } + }); + // first conversion should use default rates + expect(getGlobal().convertCurrency(1.0, 'USD', 'EUR')).to.equal(2); + expect(getGlobal().convertCurrency(1.0, 'USD', 'JPY')).to.equal(100); + fakeCurrencyFileServer.respond(); + }); + it('uses fetch rates if returned', function () { + fakeCurrencyFileServer.respondWith(JSON.stringify({ + 'dataAsOf': '2017-04-25', + 'conversions': { + 'USD': { EUR: 4, JPY: 200 } + } + })); + setConfig({ + 'adServerCurrency': 'USD', + 'defaultRates': { + 'USD': { EUR: 2, JPY: 100 } + } + }); + // now respond and should use updates rates + fakeCurrencyFileServer.respond(); + expect(getGlobal().convertCurrency(1.0, 'USD', 'EUR')).to.equal(4); + expect(getGlobal().convertCurrency(1.0, 'USD', 'JPY')).to.equal(200); + }); + }); describe('bidder override', function () { it('allows setConfig to set bidder currency', function () { setConfig({}); diff --git a/test/spec/modules/dailyhuntBidAdapter_spec.js b/test/spec/modules/dailyhuntBidAdapter_spec.js index 617c1be04bb..de384d0a1f7 100644 --- a/test/spec/modules/dailyhuntBidAdapter_spec.js +++ b/test/spec/modules/dailyhuntBidAdapter_spec.js @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import { spec } from 'modules/dailyhuntBidAdapter'; +import { spec } from 'modules/dailyhuntBidAdapter.js'; const PROD_PREBID_ENDPOINT_URL = 'https://money.dailyhunt.in/openrtb2/auction'; diff --git a/test/spec/modules/danmarketBidAdapter_spec.js b/test/spec/modules/danmarketBidAdapter_spec.js deleted file mode 100644 index 973cd2afb1c..00000000000 --- 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 d39116ccb71..18b8aac7371 100644 --- a/test/spec/modules/datablocksBidAdapter_spec.js +++ b/test/spec/modules/datablocksBidAdapter_spec.js @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import { spec } from '../../../modules/datablocksBidAdapter'; +import { spec } from '../../../modules/datablocksBidAdapter.js'; let bid = { bidId: '2dd581a2b6281d', @@ -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 3c8569b3b61..00000000000 --- 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/deepintentBidAdapter_spec.js b/test/spec/modules/deepintentBidAdapter_spec.js index f4adad7faf2..8b462b3217d 100644 --- a/test/spec/modules/deepintentBidAdapter_spec.js +++ b/test/spec/modules/deepintentBidAdapter_spec.js @@ -1,6 +1,6 @@ import {expect} from 'chai'; -import {spec} from 'modules/deepintentBidAdapter'; -import * as utils from '../../../src/utils'; +import {spec} from 'modules/deepintentBidAdapter.js'; +import * as utils from '../../../src/utils.js'; describe('Deepintent adapter', function () { let request; @@ -19,6 +19,7 @@ describe('Deepintent adapter', function () { tagId: '100013', w: 728, h: 90, + pos: 1, user: { id: 'di_testuid', buyeruid: 'di_testbuyeruid', @@ -129,6 +130,11 @@ describe('Deepintent adapter', function () { expect(data.imp[0].ext).to.be.a('object'); expect(data.imp[0].ext.deepintent.position).to.equal('right-box'); }); + it('bid request check: position check', function () { + let bRequest = spec.buildRequests(request); + let data = JSON.parse(bRequest.data); + expect(data.imp[0].banner.pos).to.equal(1); + }); it('bid request check: displaymanager check', function() { let bRequest = spec.buildRequests(request); let data = JSON.parse(bRequest.data); @@ -143,7 +149,19 @@ describe('Deepintent adapter', function () { expect(data.user.buyeruid).to.equal('di_testbuyeruid'); expect(data.user.yob).to.equal(2002); expect(data.user.gender).to.equal('F'); - }) + }); + it('bid request check: CCPA Check', function () { + let bidRequest = { + uspConsent: '1NYN' + }; + let bRequest = spec.buildRequests(request, bidRequest); + let data = JSON.parse(bRequest.data); + expect(data.regs.ext.us_privacy).to.equal('1NYN'); + let bidRequest2 = {}; + let bRequest2 = spec.buildRequests(request, bidRequest2); + let data2 = JSON.parse(bRequest2.data); + expect(data2.regs).to.equal(undefined); + }); }); describe('user sync check', function () { it('user sync url check', function () { @@ -153,7 +171,7 @@ describe('Deepintent adapter', function () { let userSync = spec.getUserSyncs(syncOptions); expect(userSync).to.be.an('array').with.length.above(0); expect(userSync[0].type).to.equal('iframe'); - expect(userSync[0].url).to.equal('https://beacon.deepintent.com/usersync.html'); + expect(userSync[0].url).to.equal('https://cdn.deepintent.com/syncpixel.html'); }); }); describe('response check', function () { diff --git a/test/spec/modules/dfpAdServerVideo_spec.js b/test/spec/modules/dfpAdServerVideo_spec.js index 6271c9b38f4..895416bae2b 100644 --- a/test/spec/modules/dfpAdServerVideo_spec.js +++ b/test/spec/modules/dfpAdServerVideo_spec.js @@ -1,14 +1,14 @@ import { expect } from 'chai'; import parse from 'url-parse'; -import { buildDfpVideoUrl, buildAdpodVideoUrl } from 'modules/dfpAdServerVideo'; -import { parseQS } from 'src/url'; -import adUnit from 'test/fixtures/video/adUnit'; -import * as utils from 'src/utils'; -import { config } from 'src/config'; -import { targeting } from 'src/targeting'; -import { auctionManager } from 'src/auctionManager'; -import * as adpod from 'modules/adpod'; +import { buildDfpVideoUrl, buildAdpodVideoUrl } from 'modules/dfpAdServerVideo.js'; +import adUnit from 'test/fixtures/video/adUnit.json'; +import * as utils from 'src/utils.js'; +import { config } from 'src/config.js'; +import { targeting } from 'src/targeting.js'; +import { auctionManager } from 'src/auctionManager.js'; +import * as adpod from 'modules/adpod.js'; +import { server } from 'test/mocks/xhr.js'; const bid = { videoCacheKey: 'abc', @@ -32,7 +32,7 @@ describe('The DFP video support module', function () { expect(url.protocol).to.equal('https:'); expect(url.host).to.equal('securepubads.g.doubleclick.net'); - const queryParams = parseQS(url.query); + const queryParams = utils.parseQS(url.query); expect(queryParams).to.have.property('correlator'); expect(queryParams).to.have.property('description_url', 'someUrl.com'); expect(queryParams).to.have.property('env', 'vp'); @@ -56,7 +56,7 @@ describe('The DFP video support module', function () { expect(url.host).to.equal('video.adserver.example'); - const queryObject = parseQS(url.query); + const queryObject = utils.parseQS(url.query); expect(queryObject.description_url).to.equal('vastUrl.example'); }); @@ -77,7 +77,7 @@ describe('The DFP video support module', function () { params: { iu: 'my/adUnit' } })); - const queryObject = parseQS(url.query); + const queryObject = utils.parseQS(url.query); expect(queryObject.iu).to.equal('my/adUnit'); }); @@ -91,7 +91,7 @@ describe('The DFP video support module', function () { } })); - expect(parseQS(url.query)).to.have.property('output', 'vast'); + expect(utils.parseQS(url.query)).to.have.property('output', 'vast'); }); it('should include the cache key and adserver targeting in cust_params', function () { @@ -107,8 +107,8 @@ describe('The DFP video support module', function () { 'iu': 'my/adUnit' } })); - const queryObject = parseQS(url.query); - const customParams = parseQS('?' + decodeURIComponent(queryObject.cust_params)); + const queryObject = utils.parseQS(url.query); + const customParams = utils.parseQS('?' + decodeURIComponent(queryObject.cust_params)); expect(customParams).to.have.property('hb_adid', 'ad_id'); expect(customParams).to.have.property('hb_uuid', bid.videoCacheKey); @@ -177,8 +177,8 @@ describe('The DFP video support module', function () { 'iu': 'my/adUnit' } })); - const queryObject = parseQS(url.query); - const customParams = parseQS('?' + decodeURIComponent(queryObject.cust_params)); + const queryObject = utils.parseQS(url.query); + const customParams = utils.parseQS('?' + decodeURIComponent(queryObject.cust_params)); expect(customParams).to.have.property('hb_adid', 'ad_id'); expect(customParams).to.have.property('hb_uuid', bid.videoCacheKey); @@ -204,8 +204,8 @@ describe('The DFP video support module', function () { }, }, })); - const queryObject = parseQS(url.query); - const customParams = parseQS('?' + decodeURIComponent(queryObject.cust_params)); + const queryObject = utils.parseQS(url.query); + const customParams = utils.parseQS('?' + decodeURIComponent(queryObject.cust_params)); expect(customParams).to.have.property('hb_adid', 'ad_id'); expect(customParams).to.have.property('my_targeting', 'foo'); @@ -223,8 +223,8 @@ describe('The DFP video support module', function () { url: 'https://video.adserver.example/ads?sz=640x480&iu=/123/aduniturl&impl=s&cust_params=section%3dblog%26mykey%3dmyvalue' })); - const queryObject = parseQS(url.query); - const customParams = parseQS('?' + decodeURIComponent(queryObject.cust_params)); + const queryObject = utils.parseQS(url.query); + const customParams = utils.parseQS('?' + decodeURIComponent(queryObject.cust_params)); expect(customParams).to.have.property('hb_adid', 'ad_id'); expect(customParams).to.have.property('section', 'blog'); @@ -246,7 +246,7 @@ describe('The DFP video support module', function () { } })); - const queryObject = parseQS(url.query); + const queryObject = utils.parseQS(url.query); expect(queryObject.description_url).to.equal('descriptionurl.example'); }); @@ -271,8 +271,8 @@ describe('The DFP video support module', function () { 'iu': 'my/adUnit' } })); - const queryObject = parseQS(url.query); - const customParams = parseQS('?' + decodeURIComponent(queryObject.cust_params)); + const queryObject = utils.parseQS(url.query); + const customParams = utils.parseQS('?' + decodeURIComponent(queryObject.cust_params)); expect(customParams).to.have.property('hb_uuid', bid.videoCacheKey); expect(customParams).to.have.property('hb_cache_id', bid.videoCacheKey); @@ -292,8 +292,8 @@ describe('The DFP video support module', function () { 'iu': 'my/adUnit' } })); - const queryObject = parseQS(url.query); - const customParams = parseQS('?' + decodeURIComponent(queryObject.cust_params)); + const queryObject = utils.parseQS(url.query); + const customParams = utils.parseQS('?' + decodeURIComponent(queryObject.cust_params)); expect(customParams).to.have.property('hb_uuid', 'def'); expect(customParams).to.have.property('hb_cache_id', 'def'); @@ -302,8 +302,6 @@ describe('The DFP video support module', function () { describe('adpod unit tests', function () { let amStub; let amGetAdUnitsStub; - let xhr; - let requests; before(function () { let adUnits = [{ @@ -333,10 +331,6 @@ describe('The DFP video support module', function () { }); beforeEach(function () { - xhr = sinon.useFakeXMLHttpRequest(); - requests = []; - xhr.onCreate = request => requests.push(request); - config.setConfig({ adpod: { brandCategoryExclusion: true, @@ -347,7 +341,6 @@ describe('The DFP video support module', function () { afterEach(function() { config.resetConfig(); - xhr.restore(); }); after(function () { @@ -376,7 +369,7 @@ describe('The DFP video support module', function () { expect(url.protocol).to.equal('https:'); expect(url.host).to.equal('securepubads.g.doubleclick.net'); - const queryParams = parseQS(url.query); + const queryParams = utils.parseQS(url.query); expect(queryParams).to.have.property('correlator'); expect(queryParams).to.have.property('description_url', 'someUrl.com'); expect(queryParams).to.have.property('env', 'vp'); @@ -388,7 +381,7 @@ describe('The DFP video support module', function () { expect(queryParams).to.have.property('url'); expect(queryParams).to.have.property('cust_params'); - const custParams = parseQS(decodeURIComponent(queryParams.cust_params)); + const custParams = utils.parseQS(decodeURIComponent(queryParams.cust_params)); expect(custParams).to.have.property('hb_cache_id', '123'); expect(custParams).to.have.property('hb_pb_cat_dur', '15.00_395_15s,15.00_406_30s,10.00_395_15s'); } @@ -430,7 +423,7 @@ describe('The DFP video support module', function () { expect(url.protocol).to.equal('https:'); expect(url.host).to.equal('securepubads.g.doubleclick.net'); - const queryParams = parseQS(url.query); + const queryParams = utils.parseQS(url.query); expect(queryParams).to.have.property('correlator'); expect(queryParams).to.have.property('description_url', 'someUrl.com'); expect(queryParams).to.have.property('env', 'vp'); @@ -442,7 +435,7 @@ describe('The DFP video support module', function () { expect(queryParams).to.have.property('url'); expect(queryParams).to.have.property('cust_params'); - const custParams = parseQS(decodeURIComponent(queryParams.cust_params)); + const custParams = utils.parseQS(decodeURIComponent(queryParams.cust_params)); expect(custParams).to.have.property('hb_cache_id', '123'); expect(custParams).to.have.property('hb_pb_cat_dur', '10.00_15s,15.00_15s,15.00_30s'); } @@ -466,7 +459,7 @@ describe('The DFP video support module', function () { } })); - requests[0].respond(503, { + server.requests[0].respond(503, { 'Content-Type': 'plain/text', }, 'The server could not save anything at the moment.'); diff --git a/test/spec/modules/dgadsBidAdapter_spec.js b/test/spec/modules/dgadsBidAdapter_spec.js deleted file mode 100644 index 2454885217d..00000000000 --- 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/digitrustIdSystem_spec.js b/test/spec/modules/digitrustIdSystem_spec.js index 55035bc4b4e..befd6eb75b6 100644 --- a/test/spec/modules/digitrustIdSystem_spec.js +++ b/test/spec/modules/digitrustIdSystem_spec.js @@ -1,13 +1,42 @@ import { digiTrustIdSubmodule, surfaceTestHook -} from 'modules/digiTrustIdSystem'; +} from 'modules/digiTrustIdSystem.js'; let assert = require('chai').assert; let expect = require('chai').expect; - var testHook = null; +/** +* A mock implementation of IAB Consent Provider +*/ +function mockCmp(command, version, callback, parameter) { + var resultVal; + if (command == 'ping') { + resultVal = { + gdprAppliesGlobally: mockCmp.stubSettings.isGlobal + }; + callback(resultVal); + } else if (command == 'getVendorConsents') { + let cbResult = { + vendorConsents: [] + } + cbResult.vendorConsents[version] = mockCmp.stubSettings.consents; + callback(cbResult); + } +} + +mockCmp.stubSettings = { + isGlobal: false, + consents: true +}; + +function setupCmpMock(isGlobal, consents) { + window.__cmp = mockCmp; + mockCmp.stubSettings.isGlobal = isGlobal; + mockCmp.stubSettings.consents = consents; +} + describe('DigiTrust Id System', function () { it('Should create the test hook', function (done) { testHook = surfaceTestHook(); @@ -47,4 +76,56 @@ describe('DigiTrust Id System', function () { expect(window.DigiTrust.isClient).to.be.true; done(); }); + + it('Should allow consent when given', function (done) { + testHook = surfaceTestHook(); + setupCmpMock(true, true); + var handler = function(result) { + expect(result).to.be.true; + done(); + } + + testHook.gdpr.hasConsent(null, handler); + }); + + it('Should consent if does not apply', function (done) { + testHook = surfaceTestHook(); + setupCmpMock(false, true); + var handler = function (result) { + expect(result).to.be.true; + done(); + } + + testHook.gdpr.hasConsent(null, handler); + }); + + it('Should not allow consent when not given', function (done) { + testHook = surfaceTestHook(); + setupCmpMock(true, false); + var handler = function (result) { + expect(result).to.be.false; + done(); + } + + testHook.gdpr.hasConsent(null, handler); + }); + it('Should deny consent if timeout', function (done) { + window.__cmp = function () { }; + var handler = function (result) { + expect(result).to.be.false; + done(); + } + + testHook.gdpr.hasConsent({ consentTimeout: 1 }, handler); + }); + it('Should pass consent test if cmp not present', function (done) { + delete window.__cmp + testHook = surfaceTestHook(); + var handler = function (result) { + expect(result).to.be.true; + done(); + } + + testHook.gdpr.hasConsent(null, handler); + }); }); diff --git a/test/spec/modules/districtmDmxBidAdapter_spec.js b/test/spec/modules/districtmDmxBidAdapter_spec.js index ac8698f63a9..d8f0beb9a36 100644 --- a/test/spec/modules/districtmDmxBidAdapter_spec.js +++ b/test/spec/modules/districtmDmxBidAdapter_spec.js @@ -1,6 +1,6 @@ import {expect} from 'chai'; import * as _ from 'lodash'; -import {spec, matchRequest, checkDeepArray, defaultSize, upto5, cleanSizes, shuffle} from '../../../modules/districtmDMXBidAdapter'; +import {spec, matchRequest, checkDeepArray, defaultSize, upto5, cleanSizes, shuffle} from '../../../modules/districtmDMXBidAdapter.js'; const supportedSize = [ { @@ -40,7 +40,7 @@ const bidRequest = [{ 'bidder': 'districtmDMX', 'params': { 'dmxid': 100001, - 'memberid': 100003 + 'memberid': 100003, }, 'adUnitCode': 'div-gpt-ad-12345678-1', 'transactionId': 'f6d13fa6-ebc1-41ac-9afa-d8171d22d2c2', @@ -53,6 +53,22 @@ const bidRequest = [{ 'auctionId': '3d62f2d3-56a2-4991-888e-f7754619ddcf' }]; +const bidRequestNoCoppa = [{ + 'bidder': 'districtmDMX', + 'params': { + 'dmxid': 100001, + 'memberid': 100003 + }, + 'adUnitCode': 'div-gpt-ad-12345678-1', + 'transactionId': 'f6d13fa6-ebc1-41ac-9afa-d8171d22d2c2', + 'sizes': [ + [300, 250], + [300, 600] + ], + 'bidId': '29a28a1bbc8a8d', + 'bidderRequestId': '124b579a136515', + 'auctionId': '3d62f2d3-56a2-4991-888e-f7754619ddcf' +}]; const bidderRequest = { 'bidderCode': 'districtmDMX', 'auctionId': '3d62f2d3-56a2-4991-888e-f7754619ddcf', @@ -61,7 +77,7 @@ const bidderRequest = { 'bidder': 'districtmDMX', 'params': { 'dmxid': 100001, - 'memberid': 100003 + 'memberid': 100003, }, 'adUnitCode': 'div-gpt-ad-12345678-1', 'transactionId': 'f6d13fa6-ebc1-41ac-9afa-d8171d22d2c2', @@ -75,6 +91,7 @@ const bidderRequest = { }], 'auctionStart': 1529511035677, 'timeout': 700, + 'uspConsent': '1NY', 'gdprConsent': { 'consentString': 'BOPqNzUOPqNzUAHABBAAA5AAAAAAAA', 'vendorData': { @@ -419,6 +436,32 @@ const bidderRequest = { 'doneCbCallCount': 0 }; +const bidderRequestNoCoppa = { + 'bidderCode': 'districtmDMX', + 'auctionId': '3d62f2d3-56a2-4991-888e-f7754619ddcf', + 'bidderRequestId': '124b579a136515', + 'bids': [{ + 'bidder': 'districtmDMX', + 'params': { + 'dmxid': 100001, + 'memberid': 100003, + }, + 'adUnitCode': 'div-gpt-ad-12345678-1', + 'transactionId': 'f6d13fa6-ebc1-41ac-9afa-d8171d22d2c2', + 'sizes': [ + [300, 250], + [300, 600] + ], + 'bidId': '29a28a1bbc8a8d', + 'bidderRequestId': '124b579a136515', + 'auctionId': '3d62f2d3-56a2-4991-888e-f7754619ddcf' + }], + 'auctionStart': 1529511035677, + 'timeout': 700, + 'start': 1529511035686, + 'doneCbCallCount': 0 +}; + const responses = { 'body': { 'id': '1f45b37c-5298-4934-b517-4d911aadabfd', @@ -521,9 +564,26 @@ describe('DistrictM Adaptor', function () { describe(`buildRequests test usage`, function () { const buildRequestResults = districtm.buildRequests(bidRequest, bidderRequest); + const buildRequestResultsNoCoppa = districtm.buildRequests(bidRequestNoCoppa, bidderRequestNoCoppa); it(`the function should return an array`, function () { expect(buildRequestResults).to.be.an('object'); }); + it(`contain gdpr consent & ccpa`, function() { + const bidr = JSON.parse(buildRequestResults.data) + expect(bidr.regs.ext.gdpr).to.be.equal(1); + expect(bidr.regs.ext.us_privacy).to.be.equal('1NY'); + expect(bidr.user.ext.consent).to.be.an('string'); + }); + it(`test contain COPPA`, function() { + const bidr = JSON.parse(buildRequestResults.data) + bidr.regs = bidr.regs || {}; + bidr.regs.coppa = 1; + expect(bidr.regs.coppa).to.be.equal(1) + }) + it(`test should not contain COPPA`, function() { + const bidr = JSON.parse(buildRequestResultsNoCoppa.data) + expect(bidr.regs.coppa).to.be.equal(0) + }) it(`the function should return array length of 1`, function () { expect(buildRequestResults.data).to.be.a('string'); }); @@ -552,6 +612,32 @@ describe('DistrictM Adaptor', function () { }); }); + describe(`check validation for id sync gdpr ccpa`, () => { + let allin = spec.getUserSyncs({iframeEnabled: true}, {}, bidderRequest.gdprConsent, bidderRequest.uspConsent)[0] + let noCCPA = spec.getUserSyncs({iframeEnabled: true}, {}, bidderRequest.gdprConsent, null)[0] + let noGDPR = spec.getUserSyncs({iframeEnabled: true}, {}, null, bidderRequest.uspConsent)[0] + let nothing = spec.getUserSyncs({iframeEnabled: true}, {}, null, null)[0] + + /* + + 'uspConsent': '1NY', + 'gdprConsent': { + 'consentString': 'BOPqNzUOPqNzUAHABBAAA5AAAAAAAA', + */ + it(`gdpr & ccpa should be present`, () => { + expect(allin.url).to.be.equal('https://cdn.districtm.io/ids/index.html?gdpr=BOPqNzUOPqNzUAHABBAAA5AAAAAAAA&ccpa=1NY') + }) + it(`ccpa should be present`, () => { + expect(noGDPR.url).to.be.equal('https://cdn.districtm.io/ids/index.html?ccpa=1NY') + }) + it(`gdpr should be present`, () => { + expect(noCCPA.url).to.be.equal('https://cdn.districtm.io/ids/index.html?gdpr=BOPqNzUOPqNzUAHABBAAA5AAAAAAAA') + }) + it(`gdpr & ccpa shouldn't be present`, () => { + expect(nothing.url).to.be.equal('https://cdn.districtm.io/ids/index.html') + }) + }) + describe(`Helper function testing`, function () { const bid = matchRequest('29a28a1bbc8a8d', {bidderRequest}); const {width, height} = defaultSize(bid); diff --git a/test/spec/modules/djaxBidAdapter_spec.js b/test/spec/modules/djaxBidAdapter_spec.js index 82955ba43bc..bef2b1fddc5 100644 --- a/test/spec/modules/djaxBidAdapter_spec.js +++ b/test/spec/modules/djaxBidAdapter_spec.js @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import { spec } from 'modules/djaxBidAdapter'; +import { spec } from 'modules/djaxBidAdapter.js'; const ENDPOINT = 'https://demo.reviveadservermod.com/headerbidding_adminshare/www/admin/plugins/Prebid/getAd.php'; diff --git a/test/spec/modules/dspxBidAdapter_spec.js b/test/spec/modules/dspxBidAdapter_spec.js index 7eeac43680a..2513a6174cd 100644 --- a/test/spec/modules/dspxBidAdapter_spec.js +++ b/test/spec/modules/dspxBidAdapter_spec.js @@ -1,8 +1,9 @@ import { expect } from 'chai'; -import { spec } from 'modules/dspxBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; +import { spec } from 'modules/dspxBidAdapter.js'; +import { newBidder } from 'src/adapters/bidderFactory.js'; const ENDPOINT_URL = 'https://buyer.dspx.tv/request/'; +const ENDPOINT_URL_DEV = 'https://dcbuyer.dspx.tv/request/'; describe('dspxAdapter', function () { const adapter = newBidder(spec); @@ -61,7 +62,22 @@ describe('dspxAdapter', function () { 'bidId': '30b31c1838de1e', 'bidderRequestId': '22edbae2733bf6', 'auctionId': '1d1a030790a475' - }]; + }, + { + 'bidder': 'dspx', + 'params': { + 'placement': '101', + 'devMode': true + }, + 'sizes': [ + [300, 250] + ], + 'bidId': '30b31c1838de1e', + 'bidderRequestId': '22edbae2733bf6', + 'auctionId': '1d1a030790a475' + } + + ]; let bidderRequest = { refererInfo: { @@ -72,9 +88,17 @@ describe('dspxAdapter', function () { const request = spec.buildRequests(bidRequests, bidderRequest); it('sends bid request to our endpoint via GET', function () { expect(request[0].method).to.equal('GET'); + expect(request[0].url).to.equal(ENDPOINT_URL); 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'); }); + + it('sends bid request to our DEV endpoint via GET', function () { + expect(request[1].method).to.equal('GET'); + expect(request[1].url).to.equal(ENDPOINT_URL_DEV); + let data = request[1].data.replace(/rnd=\d+\&/g, '').replace(/ref=.*\&bid/g, 'bid'); + expect(data).to.equal('_f=html&alternative=prebid_js&inventory_item_id=101&srw=300&srh=250&idt=100&bid_id=30b31c1838de1e&prebidDevMode=1'); + }); }); describe('interpretResponse', function () { @@ -84,6 +108,7 @@ describe('dspxAdapter', function () { 'crid': 100500, 'width': '300', 'height': '250', + 'type': 'sspHTML', 'tag': '', 'requestId': '220ed41385952a', 'currency': 'EUR', @@ -103,7 +128,7 @@ describe('dspxAdapter', function () { currency: 'EUR', netRevenue: true, ttl: 300, - referrer: '', + type: 'sspHTML', ad: '' }]; diff --git a/test/spec/modules/e_volutionBidAdapter_spec.js b/test/spec/modules/e_volutionBidAdapter_spec.js new file mode 100644 index 00000000000..447420616d1 --- /dev/null +++ b/test/spec/modules/e_volutionBidAdapter_spec.js @@ -0,0 +1,235 @@ +import {expect} from 'chai'; +import {spec} from '../../../modules/e_volutionBidAdapter.js'; + +describe('EvolutionTechBidAdapter', function () { + let bid = { + bidId: '23fhj33i987f', + bidder: 'e_volution', + 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('https://service.e-volution.ai/?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', 'sizes'); + 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', 'mediaType'); + 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', 'mediaType'); + 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', + 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', 'ttl', 'creativeId', 'netRevenue', 'currency', 'mediaType', 'native'); + expect(dataItem.native).to.have.keys('clickUrl', 'impressionTrackers', 'title', 'image') + expect(dataItem.requestId).to.equal('23fhj33i987f'); + expect(dataItem.cpm).to.equal(0.4); + expect(dataItem.native.clickUrl).to.equal('test.com'); + expect(dataItem.native.title).to.equal('Test'); + expect(dataItem.native.image).to.equal('test.com'); + expect(dataItem.native.impressionTrackers).to.be.an('array').that.is.not.empty; + expect(dataItem.native.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 () { + if (spec.noSync) { + expect(userSync).to.be.equal(false); + } else { + 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('https://service.e-volution.ai/?c=o&m=sync'); + } + }); + }); +}); diff --git a/test/spec/modules/ebdrBidAdapter_spec.js b/test/spec/modules/ebdrBidAdapter_spec.js index d742e28f2e6..ba1cad475da 100644 --- a/test/spec/modules/ebdrBidAdapter_spec.js +++ b/test/spec/modules/ebdrBidAdapter_spec.js @@ -1,7 +1,7 @@ import { expect } from 'chai'; -import { spec } from 'modules/ebdrBidAdapter'; -import { VIDEO, BANNER } from 'src/mediaTypes'; -import * as utils from 'src/utils'; +import { spec } from 'modules/ebdrBidAdapter.js'; +import { VIDEO, BANNER } from 'src/mediaTypes.js'; +import * as utils from 'src/utils.js'; describe('ebdrBidAdapter', function () { let bidRequests; @@ -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/eids_spec.js b/test/spec/modules/eids_spec.js new file mode 100644 index 00000000000..ed32ecc51d2 --- /dev/null +++ b/test/spec/modules/eids_spec.js @@ -0,0 +1,181 @@ +import {createEidsArray} from 'modules/userId/eids.js'; +import {expect} from 'chai'; + +// Note: In unit tets cases for bidders, call the createEidsArray function over userId object that is used for calling fetchBids +// this way the request will stay consistent and unit test cases will not need lots of changes. + +describe('eids array generation for known sub-modules', function() { + it('pubCommonId', function() { + const userId = { + pubcid: 'some-random-id-value' + }; + const newEids = createEidsArray(userId); + expect(newEids.length).to.equal(1); + expect(newEids[0]).to.deep.equal({ + source: 'pubcid.org', + uids: [{id: 'some-random-id-value', atype: 1}] + }); + }); + + it('unifiedId: ext generation', function() { + const userId = { + tdid: 'some-random-id-value' + }; + const newEids = createEidsArray(userId); + expect(newEids.length).to.equal(1); + expect(newEids[0]).to.deep.equal({ + source: 'adserver.org', + uids: [{id: 'some-random-id-value', atype: 1, ext: { rtiPartner: 'TDID' }}] + }); + }); + + it('id5Id', function() { + const userId = { + id5id: 'some-random-id-value' + }; + const newEids = createEidsArray(userId); + expect(newEids.length).to.equal(1); + expect(newEids[0]).to.deep.equal({ + source: 'id5-sync.com', + uids: [{id: 'some-random-id-value', atype: 1}] + }); + }); + + it('parrableId', function() { + const userId = { + parrableid: 'some-random-id-value' + }; + const newEids = createEidsArray(userId); + expect(newEids.length).to.equal(1); + expect(newEids[0]).to.deep.equal({ + source: 'parrable.com', + uids: [{id: 'some-random-id-value', atype: 1}] + }); + }); + + it('identityLink', function() { + const userId = { + idl_env: 'some-random-id-value' + }; + const newEids = createEidsArray(userId); + expect(newEids.length).to.equal(1); + expect(newEids[0]).to.deep.equal({ + source: 'liveramp.com', + uids: [{id: 'some-random-id-value', atype: 1}] + }); + }); + + it('liveIntentId; getValue call and ext', function() { + const userId = { + lipb: { + lipbid: 'some-random-id-value', + segments: ['s1', 's2'] + } + }; + const newEids = createEidsArray(userId); + expect(newEids.length).to.equal(1); + expect(newEids[0]).to.deep.equal({ + source: 'liveintent.com', + uids: [{id: 'some-random-id-value', atype: 1}], + ext: {segments: ['s1', 's2']} + }); + }); + + it('liveIntentId; getValue call and NO ext', function() { + const userId = { + lipb: { + lipbid: 'some-random-id-value' + } + }; + const newEids = createEidsArray(userId); + expect(newEids.length).to.equal(1); + expect(newEids[0]).to.deep.equal({ + source: 'liveintent.com', + uids: [{id: 'some-random-id-value', atype: 1}] + }); + }); + + it('britepoolId', function() { + const userId = { + britepoolid: 'some-random-id-value' + }; + const newEids = createEidsArray(userId); + expect(newEids.length).to.equal(1); + expect(newEids[0]).to.deep.equal({ + source: 'britepool.com', + uids: [{id: 'some-random-id-value', atype: 1}] + }); + }); + + it('DigiTrust; getValue call', function() { + const userId = { + digitrustid: { + data: { + id: 'some-random-id-value' + } + } + }; + const newEids = createEidsArray(userId); + expect(newEids.length).to.equal(1); + expect(newEids[0]).to.deep.equal({ + source: 'digitru.st', + uids: [{id: 'some-random-id-value', atype: 1}] + }); + }); + + it('criteo', function() { + const userId = { + criteoId: 'some-random-id-value' + }; + const newEids = createEidsArray(userId); + expect(newEids.length).to.equal(1); + expect(newEids[0]).to.deep.equal({ + source: 'criteo.com', + uids: [{id: 'some-random-id-value', atype: 1}] + }); + }); + + it('NetId', function() { + const userId = { + netId: 'some-random-id-value' + }; + const newEids = createEidsArray(userId); + expect(newEids.length).to.equal(1); + expect(newEids[0]).to.deep.equal({ + source: 'netid.de', + uids: [{id: 'some-random-id-value', atype: 1}] + }); + }); +}); + +describe('Negative case', function() { + it('eids array generation for UN-known sub-module', function() { + // UnknownCommonId + const userId = { + unknowncid: 'some-random-id-value' + }; + const newEids = createEidsArray(userId); + expect(newEids.length).to.equal(0); + }); + + it('eids array generation for known sub-module with non-string value', function() { + // pubCommonId + let userId = { + pubcid: undefined + }; + let newEids = createEidsArray(userId); + expect(newEids.length).to.equal(0); + userId.pubcid = 123; + newEids = createEidsArray(userId); + expect(newEids.length).to.equal(0); + userId.pubcid = []; + newEids = createEidsArray(userId); + expect(newEids.length).to.equal(0); + userId.pubcid = {}; + newEids = createEidsArray(userId); + expect(newEids.length).to.equal(0); + userId.pubcid = null; + newEids = createEidsArray(userId); + expect(newEids.length).to.equal(0); + }); +}); diff --git a/test/spec/modules/emoteevBidAdapter_spec.js b/test/spec/modules/emoteevBidAdapter_spec.js index b6a62c16963..43ae62f1eb9 100644 --- a/test/spec/modules/emoteevBidAdapter_spec.js +++ b/test/spec/modules/emoteevBidAdapter_spec.js @@ -47,10 +47,10 @@ import { validateExternalId, VENDOR_ID, WALLPAPER, -} from 'modules/emoteevBidAdapter'; -import * as url from '../../../src/url'; -import * as utils from '../../../src/utils'; -import {config} from '../../../src/config'; + storage +} from 'modules/emoteevBidAdapter.js'; +import * as utils from '../../../src/utils.js'; +import {config} from '../../../src/config.js'; const cannedValidBidRequests = [{ adUnitCode: '/19968336/header-bid-tag-1', @@ -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, @@ -329,108 +329,108 @@ describe('emoteevBidAdapter', function () { }); describe('eventsUrl', function () { - expect(eventsUrl(null)).to.deep.equal(url.format({ + expect(eventsUrl(null)).to.deep.equal(utils.buildUrl({ protocol: 'https', hostname: domain(DEFAULT_ENV), pathname: EVENTS_PATH })); - expect(eventsUrl('anything')).to.deep.equal(url.format({ + expect(eventsUrl('anything')).to.deep.equal(utils.buildUrl({ protocol: 'https', hostname: domain(DEFAULT_ENV), pathname: EVENTS_PATH })); - expect(eventsUrl(PRODUCTION)).to.deep.equal(url.format({ + expect(eventsUrl(PRODUCTION)).to.deep.equal(utils.buildUrl({ protocol: 'https', hostname: domain(PRODUCTION), pathname: EVENTS_PATH })); - expect(eventsUrl(STAGING)).to.deep.equal(url.format({ + expect(eventsUrl(STAGING)).to.deep.equal(utils.buildUrl({ protocol: 'https', hostname: domain(STAGING), pathname: EVENTS_PATH })); - expect(eventsUrl(DEVELOPMENT)).to.deep.equal(url.format({ + expect(eventsUrl(DEVELOPMENT)).to.deep.equal(utils.buildUrl({ hostname: domain(DEVELOPMENT), pathname: EVENTS_PATH })); }); describe('bidderUrl', function () { - expect(bidderUrl(null)).to.deep.equal(url.format({ + expect(bidderUrl(null)).to.deep.equal(utils.buildUrl({ protocol: 'https', hostname: domain(DEFAULT_ENV), pathname: BIDDER_PATH })); - expect(bidderUrl('anything')).to.deep.equal(url.format({ + expect(bidderUrl('anything')).to.deep.equal(utils.buildUrl({ protocol: 'https', hostname: domain(DEFAULT_ENV), pathname: BIDDER_PATH })); - expect(bidderUrl(PRODUCTION)).to.deep.equal(url.format({ + expect(bidderUrl(PRODUCTION)).to.deep.equal(utils.buildUrl({ protocol: 'https', hostname: domain(PRODUCTION), pathname: BIDDER_PATH })); - expect(bidderUrl(STAGING)).to.deep.equal(url.format({ + expect(bidderUrl(STAGING)).to.deep.equal(utils.buildUrl({ protocol: 'https', hostname: domain(STAGING), pathname: BIDDER_PATH })); - expect(bidderUrl(DEVELOPMENT)).to.deep.equal(url.format({ + expect(bidderUrl(DEVELOPMENT)).to.deep.equal(utils.buildUrl({ hostname: domain(DEVELOPMENT), pathname: BIDDER_PATH })); }); describe('userSyncIframeUrl', function () { - expect(userSyncIframeUrl(null)).to.deep.equal(url.format({ + expect(userSyncIframeUrl(null)).to.deep.equal(utils.buildUrl({ protocol: 'https', hostname: domain(DEFAULT_ENV), pathname: USER_SYNC_IFRAME_PATH })); - expect(userSyncIframeUrl('anything')).to.deep.equal(url.format({ + expect(userSyncIframeUrl('anything')).to.deep.equal(utils.buildUrl({ protocol: 'https', hostname: domain(DEFAULT_ENV), pathname: USER_SYNC_IFRAME_PATH })); - expect(userSyncIframeUrl(PRODUCTION)).to.deep.equal(url.format({ + expect(userSyncIframeUrl(PRODUCTION)).to.deep.equal(utils.buildUrl({ protocol: 'https', hostname: domain(PRODUCTION), pathname: USER_SYNC_IFRAME_PATH })); - expect(userSyncIframeUrl(STAGING)).to.deep.equal(url.format({ + expect(userSyncIframeUrl(STAGING)).to.deep.equal(utils.buildUrl({ protocol: 'https', hostname: domain(STAGING), pathname: USER_SYNC_IFRAME_PATH })); - expect(userSyncIframeUrl(DEVELOPMENT)).to.deep.equal(url.format({ + expect(userSyncIframeUrl(DEVELOPMENT)).to.deep.equal(utils.buildUrl({ hostname: domain(DEVELOPMENT), pathname: USER_SYNC_IFRAME_PATH })); }); describe('userSyncImageUrl', function () { - expect(userSyncImageUrl(null)).to.deep.equal(url.format({ + expect(userSyncImageUrl(null)).to.deep.equal(utils.buildUrl({ protocol: 'https', hostname: domain(DEFAULT_ENV), pathname: USER_SYNC_IMAGE_PATH })); - expect(userSyncImageUrl('anything')).to.deep.equal(url.format({ + expect(userSyncImageUrl('anything')).to.deep.equal(utils.buildUrl({ protocol: 'https', hostname: domain(DEFAULT_ENV), pathname: USER_SYNC_IMAGE_PATH })); - expect(userSyncImageUrl(PRODUCTION)).to.deep.equal(url.format({ + expect(userSyncImageUrl(PRODUCTION)).to.deep.equal(utils.buildUrl({ protocol: 'https', hostname: domain(PRODUCTION), pathname: USER_SYNC_IMAGE_PATH })); - expect(userSyncImageUrl(STAGING)).to.deep.equal(url.format({ + expect(userSyncImageUrl(STAGING)).to.deep.equal(utils.buildUrl({ protocol: 'https', hostname: domain(STAGING), pathname: USER_SYNC_IMAGE_PATH })); - expect(userSyncImageUrl(DEVELOPMENT)).to.deep.equal(url.format({ + expect(userSyncImageUrl(DEVELOPMENT)).to.deep.equal(utils.buildUrl({ hostname: domain(DEVELOPMENT), pathname: USER_SYNC_IMAGE_PATH })); @@ -736,18 +736,25 @@ describe('emoteevBidAdapter', function () { }); describe('side effects', function () { - let triggerPixelSpy; + let triggerPixelStub; let getCookieSpy; let getConfigSpy; let getParameterByNameSpy; + + before(function() { + config.resetConfig(); + }); + after(function() { + config.resetConfig(); + }); beforeEach(function () { - triggerPixelSpy = sinon.spy(utils, 'triggerPixel'); - getCookieSpy = sinon.spy(utils, 'getCookie'); + triggerPixelStub = sinon.stub(utils, 'triggerPixel'); + getCookieSpy = sinon.spy(storage, 'getCookie'); getConfigSpy = sinon.spy(config, 'getConfig'); getParameterByNameSpy = sinon.spy(utils, 'getParameterByName'); }); afterEach(function () { - triggerPixelSpy.restore(); + triggerPixelStub.restore(); getCookieSpy.restore(); getConfigSpy.restore(); getParameterByNameSpy.restore(); @@ -769,8 +776,8 @@ describe('emoteevBidAdapter', function () { }; spec.isBidRequestValid(validBidRequest); sinon.assert.notCalled(utils.triggerPixel); - sinon.assert.notCalled(utils.getCookie); - sinon.assert.notCalled(config.getConfig); + sinon.assert.notCalled(storage.getCookie); + // sinon.assert.notCalled(config.getConfig); sinon.assert.notCalled(utils.getParameterByName); }); }); @@ -779,8 +786,9 @@ describe('emoteevBidAdapter', function () { const invalidBidRequest = {}; spec.isBidRequestValid(invalidBidRequest); sinon.assert.notCalled(utils.triggerPixel); - sinon.assert.notCalled(utils.getCookie); - sinon.assert.notCalled(config.getConfig); + sinon.assert.notCalled(storage.getCookie); + // disabling these getConfig tests as they have been flaky in browserstack testing + // sinon.assert.notCalled(config.getConfig); sinon.assert.notCalled(utils.getParameterByName); }); }); @@ -788,8 +796,8 @@ describe('emoteevBidAdapter', function () { it('has intended side-effects', function () { spec.buildRequests(cannedValidBidRequests, cannedBidderRequest); sinon.assert.notCalled(utils.triggerPixel); - sinon.assert.notCalled(utils.getCookie); - sinon.assert.callCount(config.getConfig, 3); + sinon.assert.notCalled(storage.getCookie); + // sinon.assert.callCount(config.getConfig, 3); sinon.assert.callCount(utils.getParameterByName, 2); }); }); @@ -797,8 +805,8 @@ describe('emoteevBidAdapter', function () { it('has intended side-effects', function () { spec.interpretResponse(serverResponse); sinon.assert.notCalled(utils.triggerPixel); - sinon.assert.notCalled(utils.getCookie); - sinon.assert.notCalled(config.getConfig); + sinon.assert.notCalled(storage.getCookie); + // sinon.assert.notCalled(config.getConfig); sinon.assert.notCalled(utils.getParameterByName); }); }); @@ -807,8 +815,8 @@ describe('emoteevBidAdapter', function () { const bidObject = serverResponse.body[0]; spec.onBidWon(bidObject); sinon.assert.calledOnce(utils.triggerPixel); - sinon.assert.calledOnce(utils.getCookie); - sinon.assert.calledOnce(config.getConfig); + sinon.assert.calledOnce(storage.getCookie); + // sinon.assert.calledOnce(config.getConfig); sinon.assert.calledOnce(utils.getParameterByName); }); }); @@ -816,8 +824,8 @@ describe('emoteevBidAdapter', function () { it('has intended side-effects', function () { spec.onTimeout(cannedValidBidRequests[0]); sinon.assert.calledOnce(utils.triggerPixel); - sinon.assert.notCalled(utils.getCookie); - sinon.assert.calledOnce(config.getConfig); + sinon.assert.notCalled(storage.getCookie); + // sinon.assert.calledOnce(config.getConfig); sinon.assert.calledOnce(utils.getParameterByName); }); }); @@ -825,8 +833,8 @@ describe('emoteevBidAdapter', function () { it('has intended side-effects', function () { spec.getUserSyncs({}); sinon.assert.notCalled(utils.triggerPixel); - sinon.assert.notCalled(utils.getCookie); - sinon.assert.calledOnce(config.getConfig); + sinon.assert.notCalled(storage.getCookie); + // sinon.assert.calledOnce(config.getConfig); sinon.assert.calledOnce(utils.getParameterByName); }); }); diff --git a/test/spec/modules/emx_digitalBidAdapter_spec.js b/test/spec/modules/emx_digitalBidAdapter_spec.js index 525e5808e40..7be8a2ce5ac 100644 --- a/test/spec/modules/emx_digitalBidAdapter_spec.js +++ b/test/spec/modules/emx_digitalBidAdapter_spec.js @@ -1,7 +1,7 @@ import { expect } from 'chai'; -import { spec } from 'modules/emx_digitalBidAdapter'; -import * as utils from 'src/utils'; -import { newBidder } from 'src/adapters/bidderFactory'; +import { spec } from 'modules/emx_digitalBidAdapter.js'; +import * as utils from 'src/utils.js'; +import { newBidder } from 'src/adapters/bidderFactory.js'; describe('emx_digital Adapter', function () { describe('callBids', function () { @@ -276,9 +276,9 @@ describe('emx_digital Adapter', function () { 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); + expect(request.site).to.have.property('domain', 'example.com'); + expect(request.site).to.have.property('page', 'https://example.com/index.html?pbjs_debug=true'); + expect(request.site).to.have.property('ref', window.top.document.referrer); }); it('builds correctly formatted request banner object', function () { @@ -335,11 +335,12 @@ describe('emx_digital Adapter', function () { it('should have the right gdpr info when enabled', function () { let consentString = 'OIJSZsOAFsABAB8EMXZZZZZ+A=='; - bidderRequest.gdprConsent = { + const gdprBidderRequest = utils.deepClone(bidderRequest); + gdprBidderRequest.gdprConsent = { 'consentString': consentString, 'gdprApplies': true }; - let request = spec.buildRequests(bidderRequest.bids, bidderRequest); + let request = spec.buildRequests(gdprBidderRequest.bids, gdprBidderRequest); request = JSON.parse(request.data) expect(request.regs.ext).to.have.property('gdpr', 1); @@ -347,18 +348,21 @@ describe('emx_digital Adapter', function () { }); it('should\'t contain consent string if gdpr isn\'t applied', function () { - bidderRequest.gdprConsent = { + const nonGdprBidderRequest = utils.deepClone(bidderRequest); + nonGdprBidderRequest.gdprConsent = { 'gdprApplies': false }; - let request = spec.buildRequests(bidderRequest.bids, bidderRequest); + let request = spec.buildRequests(nonGdprBidderRequest.bids, nonGdprBidderRequest); 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() { + const uspBidderRequest = utils.deepClone(bidderRequest); let consentString = '1YNN'; - bidderRequest.uspConsent = consentString; - let request = spec.buildRequests(bidderRequest.bids, bidderRequest); + uspBidderRequest.uspConsent = consentString; + let request = spec.buildRequests(uspBidderRequest.bids, uspBidderRequest); request = JSON.parse(request.data); expect(request.us_privacy).to.exist; expect(request.us_privacy).to.exist.and.to.equal(consentString); @@ -388,6 +392,52 @@ describe('emx_digital Adapter', function () { 'auctionId': '1d1a01234a475' }; + const bid_outstream = { + 'bidderRequest': { + 'bids': [{ + 'bidder': 'emx_digital', + 'params': { + 'tagid': '25251', + 'video': {} + }, + 'mediaTypes': { + 'video': { + 'context': 'outstream', + 'playerSize': [640, 480] + } + }, + 'adUnitCode': 'adunit-code', + 'sizes': [ + [300, 250], + [300, 600] + ], + 'bidId': '987654321cba', + 'bidderRequestId': '22edbae3120bf6', + 'auctionId': '1d1a01234a475' + }, { + 'bidder': 'emx_digital', + 'params': { + 'tagid': '25252', + 'video': {} + }, + 'mediaTypes': { + 'video': { + 'context': 'instream', + 'playerSize': [640, 480] + } + }, + 'adUnitCode': 'adunit-code', + 'sizes': [ + [300, 250], + [300, 600] + ], + 'bidId': '987654321dcb', + 'bidderRequestId': '22edbae3120bf6', + 'auctionId': '1d1a01234a475' + }] + } + }; + const serverResponse = { 'id': '12819a18-56e1-4256-b836-b69a10202668', 'seatbid': [{ @@ -408,7 +458,7 @@ describe('emx_digital Adapter', function () { 'adm': '', 'crid': '3434abab35', 'h': 600, - 'id': '987654321cba', + 'id': '987654321dcb', 'price': 0.5, 'ttl': 300, 'w': 300 @@ -506,25 +556,39 @@ describe('emx_digital Adapter', function () { }); it('returns a vastXml kvp for video creatives', function () { - serverResponse.seatbid[0].bid[0].adm = ''; - serverResponse.seatbid[1].bid[0].adm = ''; + const vastServerResponse = utils.deepClone(serverResponse); + vastServerResponse.seatbid[0].bid[0].adm = ''; + vastServerResponse.seatbid[1].bid[0].adm = ''; let result = spec.interpretResponse({ - body: serverResponse + body: vastServerResponse }, { 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.vastXml).to.equal(vastServerResponse.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.vastXml).to.equal(vastServerResponse.seatbid[1].bid[0].adm); expect(ad1.ad).to.exist.and.to.be.a('string'); }); + it('returns a renderer for outstream video creatives', function () { + const vastServerResponse = utils.deepClone(serverResponse); + vastServerResponse.seatbid[0].bid[0].adm = ''; + vastServerResponse.seatbid[1].bid[0].adm = ''; + let result = spec.interpretResponse({body: vastServerResponse}, bid_outstream); + const ad0 = result[0]; + const ad1 = result[1]; + expect(ad0.renderer).to.exist.and.to.be.a('object'); + expect(ad0.renderer.url).to.equal('https://js.brealtime.com/outstream/1.30.0/bundle.js'); + expect(ad0.renderer.id).to.equal('987654321cba'); + expect(ad1.renderer).to.equal(undefined); + }); + it('handles nobid responses', function () { let serverResponse = { 'bids': [] @@ -537,11 +601,12 @@ describe('emx_digital Adapter', function () { }); 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' + const badAdmServerResponse = utils.deepClone(serverResponse); + badAdmServerResponse.seatbid[0].bid[0].adm = '\\<\\/script\\>'; + badAdmServerResponse.seatbid[1].bid[0].adm = '%3F%%3Demx%3C3prebid'; assert.doesNotThrow(() => spec.interpretResponse({ - body: serverResponse + body: badAdmServerResponse })); }); }); diff --git a/test/spec/modules/envivoBidAdapter_spec.js b/test/spec/modules/envivoBidAdapter_spec.js new file mode 100644 index 00000000000..7bd1dd1ccf1 --- /dev/null +++ b/test/spec/modules/envivoBidAdapter_spec.js @@ -0,0 +1,159 @@ +import { expect } from 'chai'; +import { spec } from 'modules/envivoBidAdapter.js'; + +const ENDPOINT = 'https://ad.nvivo.tv/ads/www/admin/plugins/Prebid/getAd.php'; + +describe('The Envivo bidding adapter', function () { + describe('isBidRequestValid', function () { + it('should return false when given an invalid bid', function () { + const bid = { + bidder: 'envivo', + }; + const isValid = spec.isBidRequestValid(bid); + expect(isValid).to.equal(false); + }); + + it('should return true when given a publisherId in bid', function () { + const bid = { + bidder: 'envivo', + params: { + publisherId: 14 + }, + }; + const isValid = spec.isBidRequestValid(bid); + expect(isValid).to.equal(true); + }); + }); + + describe('buildRequests', function () { + const bidRequests = [{ + 'bidder': 'envivo', + 'params': { + 'publisherId': 14 + }, + 'adUnitCode': 'adunit-code', + 'sizes': [ + [300, 250], + [300, 600] + ] + }]; + + const request = spec.buildRequests(bidRequests); + + it('sends bid request to our endpoint via POST', function () { + expect(request.method).to.equal('POST'); + }); + + it('check endpoint url', function () { + expect(request.url).to.equal(ENDPOINT) + }); + + it('sets the proper banner object', function () { + expect(bidRequests[0].params.publisherId).to.equal(14); + }) + }); + const response = { + body: [ + { + 'requestId': '2ee937f15015c6', + 'cpm': '0.2000', + 'width': 300, + 'height': 600, + 'creativeId': '4', + 'currency': 'USD', + 'netRevenue': true, + 'ad': 'ads.html', + 'mediaType': 'banner' + }, + { + 'requestId': '3e1af92622bdc', + 'cpm': '0.2000', + 'creativeId': '4', + 'context': 'outstream', + 'currency': 'USD', + 'netRevenue': true, + 'vastUrl': 'tezt.xml', + 'width': 640, + 'height': 480, + 'mediaType': 'video' + }] + }; + + const request = [ + { + 'bidder': 'envivo', + 'params': { + 'publisherId': 14 + }, + 'mediaTypes': { + 'banner': { + 'sizes': [ + [300, 600] + ] + } + }, + 'bidId': '2ee937f15015c6', + 'src': 'client', + }, + { + 'bidder': 'envivo', + 'params': { + 'publisherId': 14 + }, + 'mediaTypes': { + 'video': { + 'context': 'outstream', + 'playerSize': [ + [640, 480] + ] + } + }, + 'bidId': '3e1af92622bdc', + 'src': 'client', + } + ]; + + describe('interpretResponse', function () { + it('return empty array when no ad found', function () { + const response = {}; + const request = { bidRequests: [] }; + const bids = spec.interpretResponse(response, request); + expect(bids).to.have.lengthOf(0); + }); + + it('check response for banner and video', function () { + const bids = spec.interpretResponse(response, request); + expect(bids).to.have.lengthOf(2); + expect(bids[0].requestId).to.equal('2ee937f15015c6'); + expect(bids[0].cpm).to.equal('0.2000'); + expect(bids[1].cpm).to.equal('0.2000'); + expect(bids[0].width).to.equal(300); + expect(bids[0].height).to.equal(600); + expect(bids[1].vastUrl).to.not.equal(''); + expect(bids[0].ad).to.not.equal(''); + expect(bids[1].adResponse).to.not.equal(''); + expect(bids[1].renderer).not.to.be.an('undefined'); + }); + }); + + describe('On winning bid', function () { + const bids = spec.interpretResponse(response, request); + spec.onBidWon(bids); + }); + + describe('On bid Time out', function () { + const bids = spec.interpretResponse(response, request); + spec.onTimeout(bids); + }); + + describe('user sync', function () { + it('to check the user sync iframe', 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'); + }); + }); +}); diff --git a/test/spec/modules/eplanningAnalyticsAdapter_spec.js b/test/spec/modules/eplanningAnalyticsAdapter_spec.js index 8609024c7d9..9bb71e7033d 100644 --- a/test/spec/modules/eplanningAnalyticsAdapter_spec.js +++ b/test/spec/modules/eplanningAnalyticsAdapter_spec.js @@ -1,24 +1,18 @@ -import eplAnalyticsAdapter from 'modules/eplanningAnalyticsAdapter'; -import includes from 'core-js/library/fn/array/includes'; +import eplAnalyticsAdapter from 'modules/eplanningAnalyticsAdapter.js'; +import includes from 'core-js/library/fn/array/includes.js'; import { expect } from 'chai'; -import {parse as parseURL} from 'src/url'; +import { parseUrl } from 'src/utils.js'; +import { server } from 'test/mocks/xhr.js'; let adapterManager = require('src/adapterManager').default; let events = require('src/events'); let constants = require('src/constants.json'); describe('eplanning 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(); eplAnalyticsAdapter.disableAnalytics(); }); @@ -115,7 +109,7 @@ describe('eplanning analytics adapter', function () { events.emit(constants.EVENTS.AUCTION_END, {auctionId: pauctionId}); // Step 7: Find the request data sent (filtering other hosts) - requests = requests.filter(req => { + let requests = server.requests.filter(req => { return req.url.indexOf(initOptions.host) > -1; }); expect(requests.length).to.equal(1); @@ -124,7 +118,7 @@ describe('eplanning analytics adapter', function () { expect(includes(['https://ads.ar.e-planning.net/hba/1/12345?d='], requests[0].url)); let info = requests[0].url; - let purl = parseURL(info); + let purl = parseUrl(info); let eplData = JSON.parse(decodeURIComponent(purl.search.d)); // Step 8 check that 6 events were sent diff --git a/test/spec/modules/eplanningBidAdapter_spec.js b/test/spec/modules/eplanningBidAdapter_spec.js index 3152c43c6ff..ff03bf033af 100644 --- a/test/spec/modules/eplanningBidAdapter_spec.js +++ b/test/spec/modules/eplanningBidAdapter_spec.js @@ -1,7 +1,6 @@ import { expect } from 'chai'; -import { spec } from 'modules/eplanningBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; -import * as utils from 'src/utils'; +import { spec, storage } from 'modules/eplanningBidAdapter.js'; +import { newBidder } from 'src/adapters/bidderFactory.js'; describe('E-Planning Adapter', function () { const adapter = newBidder('spec'); @@ -13,6 +12,7 @@ describe('E-Planning Adapter', function () { const ADUNIT_CODE_VIEW3 = 'adunit-code-view3'; const CLEAN_ADUNIT_CODE2 = '300x250_1'; const CLEAN_ADUNIT_CODE = '300x250_0'; + const CLEAN_ADUNIT_CODE_ML = 'adunitco_de'; const BID_ID = '123456789'; const BID_ID2 = '987654321'; const BID_ID3 = '998877665'; @@ -32,6 +32,17 @@ describe('E-Planning Adapter', function () { 'adUnitCode': ADUNIT_CODE, 'sizes': [[300, 250], [300, 600]], }; + const ML = '1'; + const validBidMappingLinear = { + 'bidder': 'eplanning', + 'bidId': BID_ID, + 'params': { + 'ci': CI, + 'ml': ML, + }, + 'adUnitCode': ADUNIT_CODE, + 'sizes': [[300, 250], [300, 600]], + }; const validBid2 = { 'bidder': 'eplanning', 'bidId': BID_ID2, @@ -197,6 +208,22 @@ describe('E-Planning Adapter', function () { ] } }; + const refererUrl = 'https://localhost'; + const bidderRequest = { + refererInfo: { + referer: refererUrl + }, + gdprConsent: { + gdprApplies: 1, + consentString: 'concentDataString', + vendorData: { + vendorConsents: { + '90': 1 + }, + }, + }, + uspConsent: 'consentCcpa' + }; describe('inherited functions', function () { it('exists and is a function', function () { @@ -220,32 +247,37 @@ describe('E-Planning Adapter', function () { 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'); + const url = spec.buildRequests(bidRequests, bidderRequest).url; + expect(url).to.equal('https://ads.us.e-planning.net/hb/1/' + CI + '/1/localhost/ROS'); }); it('should return GET method', function () { - const method = spec.buildRequests(bidRequests).method; + const method = spec.buildRequests(bidRequests, bidderRequest).method; expect(method).to.equal('GET'); }); it('should return r parameter with value pbjs', function () { - const r = spec.buildRequests(bidRequests).data.r; + const r = spec.buildRequests(bidRequests, bidderRequest).data.r; expect(r).to.equal('pbjs'); }); it('should return pbv parameter with value prebid version', function () { - const pbv = spec.buildRequests(bidRequests).data.pbv; + const pbv = spec.buildRequests(bidRequests, bidderRequest).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; + const e = spec.buildRequests(bidRequests, bidderRequest).data.e; expect(e).to.equal('300x250_0:300x250,300x600'); }); + it('should return e parameter with linear mapping attribute with value according to the adunit sizes', function () { + let bidRequestsML = [validBidMappingLinear]; + const e = spec.buildRequests(bidRequestsML, bidderRequest).data.e; + expect(e).to.equal(CLEAN_ADUNIT_CODE_ML + ':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'; @@ -259,10 +291,29 @@ describe('E-Planning Adapter', function () { }; bidRequests.push(anotherBid); - const e = spec.buildRequests(bidRequests).data.e; + const e = spec.buildRequests(bidRequests, bidderRequest).data.e; expect(e).to.equal('300x250_0:300x250,300x600+100x100_0:100x100'); }); + it('should return correct e parameter with linear mapping attribute with more than one adunit', function () { + let bidRequestsML = [validBidMappingLinear]; + const NEW_CODE = ADUNIT_CODE + '2'; + const CLEAN_NEW_CODE = CLEAN_ADUNIT_CODE_ML + '2'; + const anotherBid = { + 'bidder': 'eplanning', + 'params': { + 'ci': CI, + 'ml': ML, + }, + 'adUnitCode': NEW_CODE, + 'sizes': [[100, 100]], + }; + bidRequestsML.push(anotherBid); + + const e = spec.buildRequests(bidRequestsML, bidderRequest).data.e; + expect(e).to.equal(CLEAN_ADUNIT_CODE_ML + ':300x250,300x600+' + CLEAN_NEW_CODE + ':100x100'); + }); + it('should return correct e parameter when the adunit has no size', function () { const noSizeBid = { 'bidder': 'eplanning', @@ -272,22 +323,33 @@ describe('E-Planning Adapter', function () { 'adUnitCode': ADUNIT_CODE, }; - const e = spec.buildRequests([noSizeBid]).data.e; + const e = spec.buildRequests([noSizeBid], bidderRequest).data.e; expect(e).to.equal('1x1_0:1x1'); }); + it('should return correct e parameter with linear mapping attribute when the adunit has no size', function () { + const noSizeBid = { + 'bidder': 'eplanning', + 'params': { + 'ci': CI, + 'ml': ML, + }, + 'adUnitCode': ADUNIT_CODE, + }; + + const e = spec.buildRequests([noSizeBid], bidderRequest).data.e; + expect(e).to.equal(CLEAN_ADUNIT_CODE_ML + ':1x1'); + }); + it('should return ur parameter with current window url', function () { - const ur = spec.buildRequests(bidRequests).data.ur; - expect(ur).to.equal(utils.getTopWindowUrl()); + const ur = spec.buildRequests(bidRequests, bidderRequest).data.ur; + expect(ur).to.equal(encodeURIComponent(bidderRequest.refererInfo.referer)); }); 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() + const request = spec.buildRequests(bidRequests, bidderRequest); + const dataRequest = request.data; + expect(dataRequest.fr).to.equal(encodeURIComponent(refererUrl)); }); it('should return crs parameter with document charset', function () { @@ -298,21 +360,34 @@ describe('E-Planning Adapter', function () { expected = document.characterSet; } - const chset = spec.buildRequests(bidRequests).data.crs; + const chset = spec.buildRequests(bidRequests, bidderRequest).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'; + const url = spec.buildRequests([testBid], bidderRequest).url; + const expectedUrl = 'https://' + 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; + const ncb = spec.buildRequests(bidRequests, bidderRequest).data.ncb; expect(ncb).to.equal('1'); }); + + it('should properly build a gdpr request', function () { + const request = spec.buildRequests(bidRequests, bidderRequest); + const dataRequest = request.data; + expect(dataRequest.gdpr).to.equal('1'); + expect(dataRequest.gdprcs).to.equal('concentDataString'); + }); + + it('should properly build a uspConsent request', function () { + const request = spec.buildRequests(bidRequests, bidderRequest); + const dataRequest = request.data; + expect(dataRequest.ccpa).to.equal('consentCcpa'); + }); }); describe('interpretResponse', function () { @@ -385,7 +460,7 @@ describe('E-Planning Adapter', function () { describe('adUnits mapping to bidId', function () { it('should correctly map the bidId to the adunit', function () { - const requests = spec.buildRequests([validBid, validBid2]); + const requests = spec.buildRequests([validBid, validBid2], bidderRequest); const responses = spec.interpretResponse(responseWithTwoAdunits, requests); expect(responses[0].requestId).to.equal(BID_ID); expect(responses[1].requestId).to.equal(BID_ID2); @@ -483,10 +558,10 @@ describe('E-Planning Adapter', function () { }); } beforeEach(function () { - getLocalStorageSpy = sandbox.spy(utils, 'getDataFromLocalStorage'); - setDataInLocalStorageSpy = sandbox.spy(utils, 'setDataInLocalStorage'); + getLocalStorageSpy = sandbox.spy(storage, 'getDataFromLocalStorage'); + setDataInLocalStorageSpy = sandbox.spy(storage, 'setDataInLocalStorage'); - hasLocalStorageStub = sandbox.stub(utils, 'hasLocalStorage'); + hasLocalStorageStub = sandbox.stub(storage, 'hasLocalStorage'); hasLocalStorageStub.returns(true); clock = sandbox.useFakeTimers(); @@ -506,9 +581,9 @@ describe('E-Planning Adapter', function () { it('should create the url correctly without LocalStorage', function() { createElementVisible(); hasLocalStorageStub.returns(false); - const response = spec.buildRequests(bidRequests); + const response = spec.buildRequests(bidRequests, bidderRequest); - expect(response.url).to.equal('//ads.us.e-planning.net/hb/1/' + CI + '/1/localhost/ROS'); + expect(response.url).to.equal('https://ads.us.e-planning.net/hb/1/' + CI + '/1/localhost/ROS'); expect(response.data.vs).to.equal('F'); sinon.assert.notCalled(getLocalStorageSpy); @@ -517,8 +592,8 @@ describe('E-Planning Adapter', function () { 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'); + const response = spec.buildRequests(bidRequests, bidderRequest); + expect(response.url).to.equal('https://ads.us.e-planning.net/hb/1/' + CI + '/1/localhost/ROS'); expect(response.data.vs).to.equal('F'); @@ -527,7 +602,7 @@ describe('E-Planning Adapter', function () { sinon.assert.calledWith(getLocalStorageSpy, storageIdRender); sinon.assert.calledWith(setDataInLocalStorageSpy, storageIdRender); - expect(utils.getDataFromLocalStorage(storageIdRender)).to.equal('1'); + expect(storage.getDataFromLocalStorage(storageIdRender)).to.equal('1'); }); context('when element is fully in view', function() { @@ -536,34 +611,34 @@ describe('E-Planning Adapter', function () { createElementVisible(); }); it('when you have a render', function() { - respuesta = spec.buildRequests(bidRequests); + respuesta = spec.buildRequests(bidRequests, bidderRequest); clock.tick(1005); expect(respuesta.data.vs).to.equal('F'); - expect(utils.getDataFromLocalStorage(storageIdRender)).to.equal('1'); - expect(utils.getDataFromLocalStorage(storageIdView)).to.equal('1'); + expect(storage.getDataFromLocalStorage(storageIdRender)).to.equal('1'); + expect(storage.getDataFromLocalStorage(storageIdView)).to.equal('1'); }); it('when you have more than four render', function() { - utils.setDataInLocalStorage(storageIdRender, 4); - respuesta = spec.buildRequests(bidRequests); + storage.setDataInLocalStorage(storageIdRender, 4); + respuesta = spec.buildRequests(bidRequests, bidderRequest); clock.tick(1005); expect(respuesta.data.vs).to.equal('0'); - expect(utils.getDataFromLocalStorage(storageIdRender)).to.equal('5'); - expect(utils.getDataFromLocalStorage(storageIdView)).to.equal('1'); + expect(storage.getDataFromLocalStorage(storageIdRender)).to.equal('5'); + expect(storage.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); + storage.setDataInLocalStorage(storageIdRender, 4); + storage.setDataInLocalStorage(storageIdView, 4); + respuesta = spec.buildRequests(bidRequests, bidderRequest); clock.tick(1005); expect(respuesta.data.vs).to.equal('a'); - expect(utils.getDataFromLocalStorage(storageIdRender)).to.equal('5'); - expect(utils.getDataFromLocalStorage(storageIdView)).to.equal('5'); + expect(storage.getDataFromLocalStorage(storageIdRender)).to.equal('5'); + expect(storage.getDataFromLocalStorage(storageIdView)).to.equal('5'); }); }); @@ -574,21 +649,21 @@ describe('E-Planning Adapter', function () { }); it('when you have a render', function() { - respuesta = spec.buildRequests(bidRequests); + respuesta = spec.buildRequests(bidRequests, bidderRequest); clock.tick(1005); expect(respuesta.data.vs).to.equal('F'); - expect(utils.getDataFromLocalStorage(storageIdRender)).to.equal('1'); - expect(utils.getDataFromLocalStorage(storageIdView)).to.equal(null); + expect(storage.getDataFromLocalStorage(storageIdRender)).to.equal('1'); + expect(storage.getDataFromLocalStorage(storageIdView)).to.equal(null); }); it('when you have more than four render', function() { - utils.setDataInLocalStorage(storageIdRender, 4); - respuesta = spec.buildRequests(bidRequests); + storage.setDataInLocalStorage(storageIdRender, 4); + respuesta = spec.buildRequests(bidRequests, bidderRequest); clock.tick(1005); expect(respuesta.data.vs).to.equal('0'); - expect(utils.getDataFromLocalStorage(storageIdRender)).to.equal('5'); - expect(utils.getDataFromLocalStorage(storageIdView)).to.equal(null); + expect(storage.getDataFromLocalStorage(storageIdRender)).to.equal('5'); + expect(storage.getDataFromLocalStorage(storageIdView)).to.equal(null); }); }); @@ -596,19 +671,19 @@ describe('E-Planning Adapter', function () { let respuesta; it('should register visibility with more than 50%', function() { createPartiallyVisibleElement(); - respuesta = spec.buildRequests(bidRequests); + respuesta = spec.buildRequests(bidRequests, bidderRequest); clock.tick(1005); - expect(utils.getDataFromLocalStorage(storageIdRender)).to.equal('1'); - expect(utils.getDataFromLocalStorage(storageIdView)).to.equal('1'); + expect(storage.getDataFromLocalStorage(storageIdRender)).to.equal('1'); + expect(storage.getDataFromLocalStorage(storageIdView)).to.equal('1'); }); it('you should not register visibility with less than 50%', function() { createPartiallyInvisibleElement(); - respuesta = spec.buildRequests(bidRequests); + respuesta = spec.buildRequests(bidRequests, bidderRequest); clock.tick(1005); - expect(utils.getDataFromLocalStorage(storageIdRender)).to.equal('1'); - expect(utils.getDataFromLocalStorage(storageIdView)).to.equal(null); + expect(storage.getDataFromLocalStorage(storageIdRender)).to.equal('1'); + expect(storage.getDataFromLocalStorage(storageIdView)).to.equal(null); }); }); context('when width or height of the element is zero', function() { @@ -617,55 +692,55 @@ describe('E-Planning Adapter', function () { }); it('if the width is zero but the height is within the range', function() { element.style.width = '0px'; - spec.buildRequests(bidRequests) + spec.buildRequests(bidRequests, bidderRequest) clock.tick(1005); - expect(utils.getDataFromLocalStorage(storageIdRender)).to.equal('1'); - expect(utils.getDataFromLocalStorage(storageIdView)).to.equal(null); + expect(storage.getDataFromLocalStorage(storageIdRender)).to.equal('1'); + expect(storage.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) + spec.buildRequests(bidRequests, bidderRequest) clock.tick(1005); - expect(utils.getDataFromLocalStorage(storageIdRender)).to.equal('1'); - expect(utils.getDataFromLocalStorage(storageIdView)).to.equal(null); + expect(storage.getDataFromLocalStorage(storageIdRender)).to.equal('1'); + expect(storage.getDataFromLocalStorage(storageIdView)).to.equal(null); }); it('if both are zero', function() { element.style.height = '0px'; element.style.width = '0px'; - spec.buildRequests(bidRequests) + spec.buildRequests(bidRequests, bidderRequest) clock.tick(1005); - expect(utils.getDataFromLocalStorage(storageIdRender)).to.equal('1'); - expect(utils.getDataFromLocalStorage(storageIdView)).to.equal(null); + expect(storage.getDataFromLocalStorage(storageIdRender)).to.equal('1'); + expect(storage.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); + spec.buildRequests(bidRequests, bidderRequest); clock.tick(1005); - expect(utils.getDataFromLocalStorage(storageIdRender)).to.equal('1'); - expect(utils.getDataFromLocalStorage(storageIdView)).to.equal(null); + expect(storage.getDataFromLocalStorage(storageIdRender)).to.equal('1'); + expect(storage.getDataFromLocalStorage(storageIdView)).to.equal(null); }); }); context('segmentBeginsBeforeTheVisibleRange', function() { it('segmentBeginsBeforeTheVisibleRange', function() { createElementOutOfRange(); - spec.buildRequests(bidRequests); + spec.buildRequests(bidRequests, bidderRequest); clock.tick(1005); - expect(utils.getDataFromLocalStorage(storageIdRender)).to.equal('1'); - expect(utils.getDataFromLocalStorage(storageIdView)).to.equal(null); + expect(storage.getDataFromLocalStorage(storageIdRender)).to.equal('1'); + expect(storage.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); + storage.setDataInLocalStorage('pbsr_' + ac, 5); + storage.setDataInLocalStorage('pbvi_' + ac, 5); }); }); afterEach(function () { @@ -682,11 +757,11 @@ describe('E-Planning Adapter', function () { createElementVisible(ADUNIT_CODE_VIEW2); createElementVisible(ADUNIT_CODE_VIEW3); - respuesta = spec.buildRequests(bidRequestMultiple); + respuesta = spec.buildRequests(bidRequestMultiple, bidderRequest); 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(storage.getDataFromLocalStorage('pbsr_' + ac)).to.equal('6'); + expect(storage.getDataFromLocalStorage('pbvi_' + ac)).to.equal('6'); }); expect('aaa').to.equal(respuesta.data.vs); }); @@ -695,11 +770,11 @@ describe('E-Planning Adapter', function () { createElementOutOfView(ADUNIT_CODE_VIEW2); createElementOutOfView(ADUNIT_CODE_VIEW3); - respuesta = spec.buildRequests(bidRequestMultiple); + respuesta = spec.buildRequests(bidRequestMultiple, bidderRequest); 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(storage.getDataFromLocalStorage('pbsr_' + ac)).to.equal('6'); + expect(storage.getDataFromLocalStorage('pbvi_' + ac)).to.equal('5'); }); expect('aaa').to.equal(respuesta.data.vs); @@ -709,13 +784,13 @@ describe('E-Planning Adapter', function () { createElementOutOfView(ADUNIT_CODE_VIEW2); createElementOutOfView(ADUNIT_CODE_VIEW3); - respuesta = spec.buildRequests(bidRequestMultiple); + respuesta = spec.buildRequests(bidRequestMultiple, bidderRequest); clock.tick(1005); - expect(utils.getDataFromLocalStorage('pbsr_' + ADUNIT_CODE_VIEW)).to.equal('6'); - expect(utils.getDataFromLocalStorage('pbvi_' + ADUNIT_CODE_VIEW)).to.equal('6'); + expect(storage.getDataFromLocalStorage('pbsr_' + ADUNIT_CODE_VIEW)).to.equal('6'); + expect(storage.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(storage.getDataFromLocalStorage('pbsr_' + ac)).to.equal('6'); + expect(storage.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 e4cccbf5cf3..4f5e0c224ec 100644 --- a/test/spec/modules/etargetBidAdapter_spec.js +++ b/test/spec/modules/etargetBidAdapter_spec.js @@ -1,7 +1,6 @@ import {assert, expect} from 'chai'; -import * as url from 'src/url'; -import {spec} from 'modules/etargetBidAdapter'; -import { BANNER, VIDEO } from 'src/mediaTypes'; +import {spec} from 'modules/etargetBidAdapter.js'; +import { BANNER, VIDEO } from 'src/mediaTypes.js'; describe('etarget adapter', function () { let serverResponse, bidRequest, bidResponses; @@ -29,7 +28,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 945c0dd0d01..00000000000 --- 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 ecd5db3c051..00000000000 --- 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/feedadBidAdapter_spec.js b/test/spec/modules/feedadBidAdapter_spec.js index 3432a40eca4..066ab6b21f6 100644 --- a/test/spec/modules/feedadBidAdapter_spec.js +++ b/test/spec/modules/feedadBidAdapter_spec.js @@ -1,7 +1,7 @@ import {expect} from 'chai'; -import {spec} from 'modules/feedadBidAdapter'; -import {BANNER, NATIVE, VIDEO} from '../../../src/mediaTypes'; -import * as sinon from 'sinon'; +import {spec} from 'modules/feedadBidAdapter.js'; +import {BANNER, NATIVE, VIDEO} from '../../../src/mediaTypes.js'; +import {server} from 'test/mocks/xhr.js'; const CODE = 'feedad'; @@ -382,28 +382,15 @@ describe('FeedAdAdapter', function () { cases.forEach(([name, data, eventKlass]) => { let subject = spec[name]; describe(name + ' handler', function () { - let xhr; - let requests; - - beforeEach(function () { - xhr = sinon.useFakeXMLHttpRequest(); - requests = []; - xhr.onCreate = xhr => requests.push(xhr); - }); - - afterEach(function () { - xhr.restore(); - }); - it('should do nothing on empty data', function () { subject(undefined); subject(null); - expect(requests.length).to.equal(0); + expect(server.requests.length).to.equal(0); }); it('should do nothing when bid metadata is not set', function () { subject(data); - expect(requests.length).to.equal(0); + expect(server.requests.length).to.equal(0); }); it('should send tracking params when correct metadata was set', function () { @@ -420,8 +407,8 @@ describe('FeedAdAdapter', function () { sdk_version: '1.0.0' }; subject(data); - expect(requests.length).to.equal(1); - let call = requests[0]; + expect(server.requests.length).to.equal(1); + let call = server.requests[0]; expect(call.url).to.equal('https://api.feedad.com/1/prebid/web/events'); expect(JSON.parse(call.requestBody)).to.deep.equal(expectedData); expect(call.method).to.equal('POST'); diff --git a/test/spec/modules/fidelityBidAdapter_spec.js b/test/spec/modules/fidelityBidAdapter_spec.js index 85cd0bb0c3b..1232c20b0d7 100644 --- a/test/spec/modules/fidelityBidAdapter_spec.js +++ b/test/spec/modules/fidelityBidAdapter_spec.js @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import { spec } from 'modules/fidelityBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; +import { spec } from 'modules/fidelityBidAdapter.js'; +import { newBidder } from 'src/adapters/bidderFactory.js'; describe('FidelityAdapter', function () { const adapter = newBidder(spec); @@ -67,7 +67,19 @@ describe('FidelityAdapter', function () { bidId: '2ffb201a808da7', bidderRequestId: '178e34bad3658f', requestId: 'c45dd708-a418-42ec-b8a7-b70a6c6fab0a', - transactionId: 'd45dd707-a418-42ec-b8a7-b70a6c6fab0b' + transactionId: 'd45dd707-a418-42ec-b8a7-b70a6c6fab0b', + schain: { + ver: '1.0', + complete: 1, + nodes: [{ + asi: 'exchange1.com', + sid: '1234', + hp: 1, + rid: 'bid-request-1', + name: 'publisher', + domain: 'publisher.com' + }] + } } ], start: 1472239426002, @@ -78,7 +90,8 @@ describe('FidelityAdapter', function () { } }; - it('should add source and verison to the tag', function () { + it('should add params to the request', function () { + let schainString = '1.0,1!exchange1.com,1234,1,bid-request-1,publisher,publisher.com'; const [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); const payload = request.data; expect(payload.from).to.exist; @@ -92,9 +105,11 @@ describe('FidelityAdapter', function () { expect(payload.flashver).to.exist; expect(payload.tmax).to.exist; expect(payload.defloc).to.exist; + expect(payload.schain).to.exist.and.to.be.a('string'); + expect(payload.schain).to.equal(schainString); }); - it('should add gdpr consent information to the request', function () { + it('should add consent information to the request', function () { let consentString = 'BOJ8RZsOJ8RZsABAB8AAAAAZ+A=='; let uspConsentString = '1YN-'; bidderRequest.gdprConsent = { diff --git a/test/spec/modules/fintezaAnalyticsAdapter_spec.js b/test/spec/modules/fintezaAnalyticsAdapter_spec.js index 2cc2f380016..ae9ceceecc3 100644 --- a/test/spec/modules/fintezaAnalyticsAdapter_spec.js +++ b/test/spec/modules/fintezaAnalyticsAdapter_spec.js @@ -1,7 +1,8 @@ -import fntzAnalyticsAdapter from 'modules/fintezaAnalyticsAdapter'; -import includes from 'core-js/library/fn/array/includes'; +import fntzAnalyticsAdapter from 'modules/fintezaAnalyticsAdapter.js'; +import includes from 'core-js/library/fn/array/includes.js'; import { expect } from 'chai'; -import { parse as parseURL } from 'src/url'; +import { parseUrl } from 'src/utils.js'; +import { server } from 'test/mocks/xhr.js'; let adapterManager = require('src/adapterManager').default; let events = require('src/events'); @@ -18,14 +19,8 @@ describe('finteza analytics adapter', function () { const clientId = 'fntz-client-32145'; const uniqCookie = '5045380421580287382'; - let xhr; - let requests; - beforeEach(function () { setCookie('_fz_uniq', uniqCookie); - xhr = sinon.useFakeXMLHttpRequest(); - requests = []; - xhr.onCreate = request => { requests.push(request) }; sinon.stub(events, 'getEvents').returns([]); sinon.spy(fntzAnalyticsAdapter, 'track'); @@ -49,7 +44,6 @@ describe('finteza analytics adapter', function () { afterEach(function () { setCookie('_fz_uniq', '', new Date(0)); - xhr.restore(); events.getEvents.restore(); fntzAnalyticsAdapter.track.restore(); fntzAnalyticsAdapter.disableAnalytics(); @@ -82,12 +76,12 @@ describe('finteza analytics adapter', function () { // Emit the events with the "real" arguments events.emit(constants.EVENTS.BID_REQUESTED, bidRequest); - expect(requests.length).to.equal(1); + expect(server.requests.length).to.equal(1); - expect(requests[0].method).to.equal('GET'); - expect(requests[0].withCredentials).to.equal(true); + expect(server.requests[0].method).to.equal('GET'); + expect(server.requests[0].withCredentials).to.equal(true); - const url = parseURL(requests[0].url); + const url = parseUrl(server.requests[0].url); expect(url.protocol).to.equal('https'); expect(url.hostname).to.equal('content.mql5.com'); @@ -125,12 +119,12 @@ describe('finteza analytics adapter', function () { // Emit the events with the "real" arguments events.emit(constants.EVENTS.BID_RESPONSE, bidResponse); - expect(requests.length).to.equal(2); + expect(server.requests.length).to.equal(2); - expect(requests[0].method).to.equal('GET'); - expect(requests[0].withCredentials).to.equal(true); + expect(server.requests[0].method).to.equal('GET'); + expect(server.requests[0].withCredentials).to.equal(true); - let url = parseURL(requests[0].url); + let url = parseUrl(server.requests[0].url); expect(url.protocol).to.equal('https'); expect(url.hostname).to.equal('content.mql5.com'); @@ -141,10 +135,10 @@ describe('finteza analytics adapter', function () { expect(url.search.value).to.equal(String(cpm)); expect(url.search.unit).to.equal('usd'); - expect(requests[1].method).to.equal('GET'); - expect(requests[1].withCredentials).to.equal(true); + expect(server.requests[1].method).to.equal('GET'); + expect(server.requests[1].withCredentials).to.equal(true); - url = parseURL(requests[1].url); + url = parseUrl(server.requests[1].url); expect(url.protocol).to.equal('https'); expect(url.hostname).to.equal('content.mql5.com'); @@ -179,12 +173,12 @@ describe('finteza analytics adapter', function () { // Emit the events with the "real" arguments events.emit(constants.EVENTS.BID_WON, bidWon); - expect(requests.length).to.equal(1); + expect(server.requests.length).to.equal(1); - expect(requests[0].method).to.equal('GET'); - expect(requests[0].withCredentials).to.equal(true); + expect(server.requests[0].method).to.equal('GET'); + expect(server.requests[0].withCredentials).to.equal(true); - const url = parseURL(requests[0].url); + const url = parseUrl(server.requests[0].url); expect(url.protocol).to.equal('https'); expect(url.hostname).to.equal('content.mql5.com'); @@ -218,12 +212,12 @@ describe('finteza analytics adapter', function () { // Emit the events with the "real" arguments events.emit(constants.EVENTS.BID_TIMEOUT, bidTimeout); - expect(requests.length).to.equal(1); + expect(server.requests.length).to.equal(1); - expect(requests[0].method).to.equal('GET'); - expect(requests[0].withCredentials).to.equal(true); + expect(server.requests[0].method).to.equal('GET'); + expect(server.requests[0].withCredentials).to.equal(true); - const url = parseURL(requests[0].url); + const url = parseUrl(server.requests[0].url); expect(url.protocol).to.equal('https'); expect(url.hostname).to.equal('content.mql5.com'); diff --git a/test/spec/modules/fluctBidAdapter_spec.js b/test/spec/modules/fluctBidAdapter_spec.js new file mode 100644 index 00000000000..6530a3c36cf --- /dev/null +++ b/test/spec/modules/fluctBidAdapter_spec.js @@ -0,0 +1,201 @@ +import {expect} from 'chai'; +import {spec} from 'modules/fluctBidAdapter.js'; +import {newBidder} from 'src/adapters/bidderFactory.js'; +import {config} from 'src/config.js'; + +describe('fluctAdapter', 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: 'fluct', + params: { + dfpUnitCode: '/1000/dfp_unit_code', + tagId: '10000:100000001', + groupId: '1000000002', + } + }; + 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 = {}; + expect(spec.isBidRequestValid(bid)).to.equal(false); + }); + + it('should return true when dfpUnitCode is not passed', function () { + let bid = Object.assign({}, bid); + delete bid.params; + bid.params = { + tagId: '10000:100000001', + groupId: '1000000002', + }; + expect(spec.isBidRequestValid(bid)).to.equal(true); + }); + + it('should return false when groupId is not passed', function () { + let bid = Object.assign({}, bid); + delete bid.params; + bid.params = { + dfpUnitCode: '/1000/dfp_unit_code', + tagId: '10000:100000001', + }; + expect(spec.isBidRequestValid(bid)).to.equal(false); + }); + }); + + describe('buildRequests', function () { + const bidRequests = [{ + bidder: 'fluct', + params: { + dfpUnitCode: '/100000/unit_code', + tagId: '10000:100000001', + groupId: '1000000002', + }, + adUnitCode: '/10000/unit_code', + sizes: [[300, 250], [336, 280]], + bidId: '237f4d1a293f99', + bidderRequestId: '1a857fa34c1c96', + auctionId: 'a297d1aa-7900-4ce4-a0aa-caa8d46c4af7', + transactionId: '00b2896c-2731-4f01-83e4-7a3ad5da13b6', + }]; + const bidderRequest = { + refererInfo: { + referer: 'http://example.com' + } + }; + + it('sends bid request to ENDPOINT via POST', function () { + const request = spec.buildRequests(bidRequests, bidderRequest)[0]; + expect(request.method).to.equal('POST'); + }); + }); + + describe('interpretResponse', function() { + const callBeaconSnippet = ''; + + it('should get correct bid response', function() { + const bidRequest = { + bidder: 'fluct', + params: { + dfpUnitCode: '/10000/unit_code', + tagid: '10000:100000001', + groupId: '1000000002', + }, + adUnitCode: '/10000/unit_code', + sizes: [[300, 250], [336, 280]], + bidId: '237f4d1a293f99', + bidderRequestId: '1a857fa34c1c96', + auctionId: 'a297d1aa-7900-4ce4-a0aa-caa8d46c4af7', + transactionId: '00b2896c-2731-4f01-83e4-7a3ad5da13b6', + }; + + const serverResponse = { + body: { + id: '237f4d1a293f99', + cur: 'JPY', + seatbid: [{ + bid: [{ + price: 100, + w: 300, + h: 250, + adm: '', + burl: 'https://i.adingo.jp/?test=1&et=hb&bidid=237f4d1a293f99', + crid: 'test_creative', + }] + }] + } + }; + + const expectedResponse = [ + { + bidderCode: 'fluct', + requestId: '237f4d1a293f99', + currency: 'JPY', + cpm: 100, + netRevenue: true, + width: 300, + height: 250, + creativeId: 'test_creative', + ttl: 300, + ad: '' + callBeaconSnippet, + } + ]; + + const result = spec.interpretResponse(serverResponse, bidRequest); + expect(result).to.have.lengthOf(1); + expect(result).to.deep.have.same.members(expectedResponse); + }); + + it('should get correct bid response with dealId', function() { + const bidRequest = { + bidder: 'fluct', + params: { + dfpUnitCode: '/10000/unit_code', + tagid: '10000:100000001', + groupId: '1000000002' + }, + adUnitCode: '/10000/unit_code', + sizes: [[300, 250], [336, 280]], + bidId: '237f4d1a293f99', + bidderRequestId: '1a857fa34c1c96', + auctionId: 'a297d1aa-7900-4ce4-a0aa-caa8d46c4af7', + transactionId: '00b2896c-2731-4f01-83e4-7a3ad5da13b6', + }; + + const serverResponse = { + body: { + id: '237f4d1a293f99', + cur: 'JPY', + seatbid: [{ + bid: [{ + price: 100, + w: 300, + h: 250, + adm: '', + burl: 'https://i.adingo.jp/?test=1&et=hb&bidid=237f4d1a293f99', + crid: 'test_creative', + dealid: 'test_deal', + }] + }] + } + }; + + const expectedResponse = [ + { + bidderCode: 'fluct', + requestId: '237f4d1a293f99', + currency: 'JPY', + cpm: 100, + netRevenue: true, + width: 300, + height: 250, + creativeId: 'test_creative', + ttl: 300, + ad: '' + callBeaconSnippet, + dealId: 'test_deal', + } + ]; + + const result = spec.interpretResponse(serverResponse, bidRequest); + expect(result).to.have.lengthOf(1); + expect(result).to.deep.have.same.members(expectedResponse); + }); + + it('should get empty response when bid server returns 204', function() { + expect(spec.interpretResponse({})).to.be.empty; + }); + }); +}); diff --git a/test/spec/modules/freeWheelAdserverVideo_spec.js b/test/spec/modules/freeWheelAdserverVideo_spec.js index c2afaf8d69f..172909f99ca 100644 --- a/test/spec/modules/freeWheelAdserverVideo_spec.js +++ b/test/spec/modules/freeWheelAdserverVideo_spec.js @@ -1,13 +1,12 @@ import { expect } from 'chai'; -import { adpodUtils } from 'modules/freeWheelAdserverVideo'; -import { auctionManager } from 'src/auctionManager'; -import { config } from 'src/config'; +import { adpodUtils } from 'modules/freeWheelAdserverVideo.js'; +import { auctionManager } from 'src/auctionManager.js'; +import { config } from 'src/config.js'; +import { server } from 'test/mocks/xhr.js'; describe('freeWheel adserver module', function() { let amStub; let amGetAdUnitsStub; - let xhr; - let requests; before(function () { let adUnits = [{ @@ -56,10 +55,6 @@ describe('freeWheel adserver module', function() { }); beforeEach(function () { - xhr = sinon.useFakeXMLHttpRequest(); - requests = []; - xhr.onCreate = request => requests.push(request); - config.setConfig({ adpod: { brandCategoryExclusion: false, @@ -70,7 +65,6 @@ describe('freeWheel adserver module', function() { afterEach(function() { config.resetConfig(); - xhr.restore(); }); after(function () { @@ -188,7 +182,7 @@ describe('freeWheel adserver module', function() { } }); - requests[0].respond( + server.requests[0].respond( 200, { 'Content-Type': 'text/plain' }, JSON.stringify({'responses': getBidsReceived().slice(0, 4)}) @@ -225,7 +219,7 @@ describe('freeWheel adserver module', function() { } }); - requests[0].respond( + server.requests[0].respond( 200, { 'Content-Type': 'text/plain' }, JSON.stringify({'responses': bidsReceived.slice(1)}) @@ -275,7 +269,7 @@ describe('freeWheel adserver module', function() { } }); - requests[0].respond( + server.requests[0].respond( 200, { 'Content-Type': 'text/plain' }, JSON.stringify({'responses': [tier7Bid, bid]}) diff --git a/test/spec/modules/freewheel-sspBidAdapter_spec.js b/test/spec/modules/freewheel-sspBidAdapter_spec.js index 45754d0250c..4b80cce8017 100644 --- a/test/spec/modules/freewheel-sspBidAdapter_spec.js +++ b/test/spec/modules/freewheel-sspBidAdapter_spec.js @@ -1,239 +1,498 @@ -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); - }); - }); -}); +import { expect } from 'chai'; +import { spec } from 'modules/freewheel-sspBidAdapter.js'; +import { newBidder } from 'src/adapters/bidderFactory.js'; + +const ENDPOINT = '//ads.stickyadstv.com/www/delivery/swfIndex.php'; + +describe('freewheelSSP BidAdapter Test', () => { + const adapter = newBidder(spec); + + describe('inherited functions', () => { + it('exists and is a function', () => { + expect(adapter.callBids).to.exist.and.to.be.a('function'); + }); + }); + + describe('isBidRequestValidForBanner', () => { + let bid = { + 'bidder': 'freewheel-ssp', + 'params': { + 'zoneId': '277225' + }, + 'adUnitCode': 'adunit-code', + 'mediaTypes': { + 'banner': { + 'sizes': [ + [300, 250], [300, 600] + ] + } + }, + 'sizes': [[300, 250], [300, 600]], + 'bidId': '30b31c1838de1e', + 'bidderRequestId': '22edbae2733bf6', + 'auctionId': '1d1a030790a475', + }; + + 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', () => { + let bid = Object.assign({}, bid); + delete bid.params; + bid.params = { + wrong: 'missing zone id' + }; + expect(spec.isBidRequestValid(bid)).to.equal(false); + }); + }); + + describe('isBidRequestValidForVideo', () => { + let bid = { + 'bidder': 'freewheel-ssp', + 'params': { + 'zoneId': '277225' + }, + 'adUnitCode': 'adunit-code', + 'mediaTypes': { + 'video': { + 'playerSize': [300, 250], + } + }, + 'sizes': [[300, 250]], + 'bidId': '30b31c1838de1e', + 'bidderRequestId': '22edbae2733bf6', + 'auctionId': '1d1a030790a475', + }; + + 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', () => { + let bid = Object.assign({}, bid); + delete bid.params; + bid.params = { + wrong: 'missing zone id' + }; + expect(spec.isBidRequestValid(bid)).to.equal(false); + }); + }); + + describe('buildRequestsForBanner', () => { + let bidRequests = [ + { + 'bidder': 'freewheel-ssp', + 'params': { + 'zoneId': '277225' + }, + 'adUnitCode': 'adunit-code', + 'mediaTypes': { + 'banner': { + 'sizes': [ + [300, 250], [300, 600] + ] + } + }, + 'sizes': [[300, 250], [300, 600]], + 'bidId': '30b31c1838de1e', + 'bidderRequestId': '22edbae2733bf6', + 'auctionId': '1d1a030790a475', + } + ]; + + it('should add parameters to the tag', () => { + const request = spec.buildRequests(bidRequests); + const payload = request[0].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.playerSize).to.equal('300x600'); + }); + + it('sends bid request to ENDPOINT via GET', () => { + const request = spec.buildRequests(bidRequests); + expect(request[0].url).to.contain(ENDPOINT); + expect(request[0].method).to.equal('GET'); + }); + + it('should add usp consent to the request', () => { + let uspConsentString = '1FW-SSP-uspConsent-'; + let bidderRequest = {}; + bidderRequest.uspConsent = uspConsentString; + const request = spec.buildRequests(bidRequests, bidderRequest); + const payload = request[0].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.playerSize).to.equal('300x600'); + expect(payload._fw_us_privacy).to.exist.and.to.be.a('string'); + expect(payload._fw_us_privacy).to.equal(uspConsentString); + }); + + it('should add gdpr consent to the request', () => { + let gdprConsentString = '1FW-SSP-gdprConsent-'; + let bidderRequest = { + 'gdprConsent': { + 'consentString': gdprConsentString + } + }; + + const request = spec.buildRequests(bidRequests, bidderRequest); + const payload = request[0].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.playerSize).to.equal('300x600'); + expect(payload._fw_gdpr_consent).to.exist.and.to.be.a('string'); + expect(payload._fw_gdpr_consent).to.equal(gdprConsentString); + }); + }) + + describe('buildRequestsForVideo', () => { + let bidRequests = [ + { + 'bidder': 'freewheel-ssp', + 'params': { + 'zoneId': '277225' + }, + 'adUnitCode': 'adunit-code', + 'mediaTypes': { + 'video': { + 'playerSize': [300, 600], + } + }, + 'sizes': [[300, 250], [300, 600]], + 'bidId': '30b31c1838de1e', + 'bidderRequestId': '22edbae2733bf6', + 'auctionId': '1d1a030790a475', + } + ]; + + it('should add parameters to the tag', () => { + const request = spec.buildRequests(bidRequests); + const payload = request[0].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.playerSize).to.equal('300x600'); + }); + + it('sends bid request to ENDPOINT via GET', () => { + const request = spec.buildRequests(bidRequests); + expect(request[0].url).to.contain(ENDPOINT); + expect(request[0].method).to.equal('GET'); + }); + + it('should add usp consent to the request', () => { + let uspConsentString = '1FW-SSP-uspConsent-'; + let bidderRequest = {}; + bidderRequest.uspConsent = uspConsentString; + const request = spec.buildRequests(bidRequests, bidderRequest); + const payload = request[0].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.playerSize).to.equal('300x600'); + expect(payload._fw_us_privacy).to.exist.and.to.be.a('string'); + expect(payload._fw_us_privacy).to.equal(uspConsentString); + }); + + it('should add gdpr consent to the request', () => { + let gdprConsentString = '1FW-SSP-gdprConsent-'; + let bidderRequest = { + 'gdprConsent': { + 'consentString': gdprConsentString + } + }; + + const request = spec.buildRequests(bidRequests, bidderRequest); + const payload = request[0].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.playerSize).to.equal('300x600'); + expect(payload._fw_gdpr_consent).to.exist.and.to.be.a('string'); + expect(payload._fw_gdpr_consent).to.equal(gdprConsentString); + }); + }) + + describe('interpretResponseForBanner', () => { + let bidRequests = [ + { + 'bidder': 'freewheel-ssp', + 'params': { + 'zoneId': '277225' + }, + 'adUnitCode': 'adunit-code', + 'mediaTypes': { + 'banner': { + 'sizes': [ + [300, 250], [300, 600] + ] + } + }, + 'sizes': [[300, 250], [300, 600]], + 'bidId': '30b31c1838de1e', + 'bidderRequestId': '22edbae2733bf6', + 'auctionId': '1d1a030790a475', + } + ]; + + let formattedBidRequests = [ + { + 'bidder': 'freewheel-ssp', + 'params': { + 'zoneId': '277225', + 'format': 'floorad' + }, + 'adUnitCode': 'adunit-code', + 'mediaTypes': { + 'banner': { + 'sizes': [ + [300, 250], [300, 600] + ] + } + }, + 'sizes': [[600, 250], [300, 600]], + 'bidId': '30b3other1c1838de1e', + 'bidderRequestId': '22edbae273other3bf6', + 'auctionId': '1d1a03079test0a475', + }, + { + 'bidder': 'stickyadstv', + 'params': { + 'zoneId': '277225', + 'format': 'test' + }, + 'adUnitCode': 'adunit-code', + 'mediaTypes': { + 'banner': { + 'sizes': [ + [300, 600] + ] + } + }, + 'sizes': [[300, 600]], + 'bidId': '2', + 'bidderRequestId': '3', + 'auctionId': '4', + } + ]; + + let response = '' + + '' + + ' ' + + ' Adswizz' + + ' ' + + ' ' + + ' ' + + ' 00:00:09' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' 0.2000' + + ' ' + + ' ' + + ' ' + + ''; + + let ad = '
'; + let formattedAd = '
'; + + it('should get correct bid response', () => { + var request = spec.buildRequests(bidRequests); + + 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[0]); + expect(Object.keys(result[0])).to.deep.equal(Object.keys(expectedResponse[0])); + }); + + it('should get correct bid response with formated ad', () => { + var request = spec.buildRequests(formattedBidRequests); + + let expectedResponse = [ + { + requestId: '30b31c1838de1e', + cpm: '0.2000', + width: 300, + height: 600, + creativeId: '28517153', + currency: 'EUR', + netRevenue: true, + ttl: 360, + ad: formattedAd + } + ]; + + let result = spec.interpretResponse(response, request[0]); + expect(Object.keys(result[0])).to.deep.equal(Object.keys(expectedResponse[0])); + }); + + it('handles nobid responses', () => { + var request = spec.buildRequests(formattedBidRequests); + let response = ''; + + let result = spec.interpretResponse(response, request[0]); + expect(result.length).to.equal(0); + }); + }); + describe('interpretResponseForVideo', () => { + let bidRequests = [ + { + 'bidder': 'freewheel-ssp', + 'params': { + 'zoneId': '277225' + }, + 'adUnitCode': 'adunit-code', + 'mediaTypes': { + 'video': { + 'playerSize': [300, 600], + } + }, + 'sizes': [[300, 400]], + 'bidId': '30b31c1838de1e', + 'bidderRequestId': '22edbae2733bf6', + 'auctionId': '1d1a030790a475', + } + ]; + + let formattedBidRequests = [ + { + 'bidder': 'freewheel-ssp', + 'params': { + 'zoneId': '277225', + 'format': 'floorad' + }, + 'adUnitCode': 'adunit-code', + 'mediaTypes': { + 'video': { + 'playerSize': [300, 600], + } + }, + 'sizes': [[300, 400]], + 'bidId': '30b3other1c1838de1e', + 'bidderRequestId': '22edbae273other3bf6', + 'auctionId': '1d1a03079test0a475', + }, + { + 'bidder': 'stickyadstv', + 'params': { + 'zoneId': '277225', + 'format': 'test' + }, + 'adUnitCode': 'adunit-code', + 'mediaTypes': { + 'video': { + 'playerSize': [300, 600], + } + }, + 'sizes': [[300, 400]], + 'bidId': '2', + 'bidderRequestId': '3', + 'auctionId': '4', + } + ]; + + let response = '' + + '' + + ' ' + + ' Adswizz' + + ' ' + + ' ' + + ' ' + + ' 00:00:09' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' 0.2000' + + ' ' + + ' ' + + ' ' + + ''; + + let ad = '
'; + let formattedAd = '
'; + + it('should get correct bid response', () => { + var request = spec.buildRequests(bidRequests); + + let expectedResponse = [ + { + requestId: '30b31c1838de1e', + cpm: '0.2000', + width: 300, + height: 600, + creativeId: '28517153', + currency: 'EUR', + netRevenue: true, + ttl: 360, + vastXml: response, + mediaType: 'video', + ad: ad + } + ]; + + let result = spec.interpretResponse(response, request[0]); + expect(Object.keys(result[0])).to.deep.equal(Object.keys(expectedResponse[0])); + }); + + it('should get correct bid response with formated ad', () => { + var request = spec.buildRequests(formattedBidRequests); + + let expectedResponse = [ + { + requestId: '30b31c1838de1e', + cpm: '0.2000', + width: 300, + height: 600, + creativeId: '28517153', + currency: 'EUR', + netRevenue: true, + ttl: 360, + vastXml: response, + mediaType: 'video', + ad: formattedAd + } + ]; + + let result = spec.interpretResponse(response, request[0]); + expect(Object.keys(result[0])).to.deep.equal(Object.keys(expectedResponse[0])); + }); + + it('handles nobid responses', () => { + var request = spec.buildRequests(formattedBidRequests); + let response = ''; + + let result = spec.interpretResponse(response, request[0]); + 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 a16c069d2a0..00000000000 --- 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 index 99593e6e06f..cdaa1b5448a 100644 --- a/test/spec/modules/gammaBidAdapter_spec.js +++ b/test/spec/modules/gammaBidAdapter_spec.js @@ -1,7 +1,6 @@ -import * as utils from 'src/utils'; import { expect } from 'chai'; -import { spec } from 'modules/gammaBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; +import { spec } from 'modules/gammaBidAdapter.js'; +import { newBidder } from 'src/adapters/bidderFactory.js'; describe('gammaBidAdapter', function() { const adapter = newBidder(spec); @@ -22,26 +21,26 @@ describe('gammaBidAdapter', function() { }; let bidArray = [bid]; - describe('isBidRequestValid', function () { - it('should return true when required params found', function () { + describe('isBidRequestValid', () => { + it('should return true when required params found', () => { expect(spec.isBidRequestValid(bid)).to.equal(true); }); - it('should return false when require params are not passed', function () { + it('should return false when require params are not passed', () => { let bid = Object.assign({}, bid); bid.params = {}; expect(spec.isBidRequestValid(bid)).to.equal(false); }); - it('should return false when params not passed correctly', function () { + it('should return false when params not passed correctly', () => { 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 () { + describe('buildRequests', () => { + it('should attempt to send bid requests to the endpoint via GET', () => { const requests = spec.buildRequests(bidArray); requests.forEach(function(requestItem) { expect(requestItem.method).to.equal('GET'); @@ -50,10 +49,10 @@ describe('gammaBidAdapter', function() { }); }); - describe('interpretResponse', function () { + describe('interpretResponse', () => { let serverResponse; - beforeEach(function () { + beforeEach(() => { serverResponse = { body: { 'id': '23beaa6af6cdde', @@ -77,7 +76,7 @@ describe('gammaBidAdapter', function() { }; }) - it('should get the correct bid response', function () { + it('should get the correct bid response', () => { let expectedResponse = [{ 'requestId': '23beaa6af6cdde', 'cpm': 0.45, @@ -94,7 +93,7 @@ describe('gammaBidAdapter', function() { expect(Object.keys(result)).to.deep.equal(Object.keys(expectedResponse)); }); - it('handles empty bid response', function () { + it('handles empty bid response', () => { let response = { body: {} }; diff --git a/test/spec/modules/gamoshiBidAdapter_spec.js b/test/spec/modules/gamoshiBidAdapter_spec.js index 2d63d47a73e..79f58470cb3 100644 --- a/test/spec/modules/gamoshiBidAdapter_spec.js +++ b/test/spec/modules/gamoshiBidAdapter_spec.js @@ -1,41 +1,231 @@ 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'; +import {spec, helper} from 'modules/gamoshiBidAdapter.js'; +import * as utils from 'src/utils.js'; +import {newBidder} from '../../../src/adapters/bidderFactory.js'; 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 () { +const TTL = 360; + +describe('GamoshiAdapter', () => { + let schainConfig, + bidRequest, + bannerBidRequest, + videoBidRequest, + rtbResponse, + videoResponse, + gdprConsent; + + beforeEach(() => { + schainConfig = { + 'ver': '1.0', + 'complete': 1, + 'nodes': [ + { + 'asi': 'indirectseller.com', + 'sid': '00001', + 'hp': 1 + }, + + { + 'asi': 'indirectseller-2.com', + 'sid': '00002', + 'hp': 2 + } + ] + }; + + 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 + }, + schain: schainConfig, + uspConsent: 'gamoshiCCPA' + }; + + 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'} + }; + + 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'} + }; + + rtbResponse = { + 'id': 'imp_5b05b9fde4b09084267a556f', + 'bidid': 'imp_5b05b9fde4b09084267a556f', + 'cur': 'USD', + 'ext': { + 'utrk': [ + {'type': 'iframe', 'url': '//rtb.gamoshi.io/user/sync/1?gdpr=[GDPR]&consent=[CONSENT]&usp=[US_PRIVACY]'}, + {'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', + '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', + 'adm': ' ', + 'adomain': ['bbb.com'], + 'cid': 'fgdlwjh2498ydjhg1', + 'crid': 'kjh34297ydh2133d', + 'attr': [], + 'h': 250, + 'w': 300, + 'ext': { + 'utrk': [ + {'type': 'image', 'url': '//p.partner2.io/user/sync/1'} + ] + } + } + ] + } + ] + }; + + 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', + '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&gdpr=[GDPR]&consent=[CONSENT]&us_privacy=[US_PRIVACY]' + }] + } + }; + + gdprConsent = { + gdprApplies: true, + consentString: 'consent string' + }; + }); + + describe('Get top Frame', () => { + it('check if you are in the top frame', () => { expect(helper.getTopFrame()).to.equal(0); }); - it('verify domain parsing', function () { + + it('verify domain parsing', () => { 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 () { + + describe('Is String start with search', () => { + it('check if a string started with', () => { expect(helper.startsWith('gamoshi.com', 'gamo')).to.equal(true); }); }); - describe('inherited functions', function () { - it('exists and is a function', function () { + describe('inherited functions', () => { + it('exists and is a function', () => { expect(adapter.callBids).to.exist.and.to.be.a('function'); }); }); - describe('isBidRequestValid', function () { - it('should validate supply-partner ID', function () { + describe('isBidRequestValid', () => { + it('should validate supply-partner ID', () => { 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 () { + it('should validate RTB endpoint', () => { 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({ @@ -46,19 +236,19 @@ describe('GamoshiAdapter', function () { })).to.equal(true); }); - it('should validate bid floor', function () { + it('should validate bid floor', () => { 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 () { + it('should validate adpos', () => { 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 () { + it('should validate instl', () => { 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); @@ -68,25 +258,8 @@ describe('GamoshiAdapter', function () { }); }); - 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 () { + describe('buildRequests', () => { + it('returns an array', () => { let response; response = spec.buildRequests([]); expect(Array.isArray(response)).to.equal(true); @@ -101,7 +274,7 @@ describe('GamoshiAdapter', function () { expect(response.length).to.equal(2); }); - it('targets correct endpoint', function () { + it('targets correct endpoint', () => { let response; response = spec.buildRequests([bidRequest], bidRequest)[0]; expect(response.method).to.equal('POST'); @@ -113,11 +286,11 @@ describe('GamoshiAdapter', function () { 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); + it('builds request correctly', () => { + let bidRequest2 = utils.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'); @@ -127,6 +300,9 @@ describe('GamoshiAdapter', function () { 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'); + expect(response.data.regs.ext.us_privacy).to.equal('gamoshiCCPA');// USP/CCPAs + expect(response.data.source.ext.schain).to.deep.equal(bidRequest2.schain); + const bidRequestWithInstlEquals1 = utils.deepClone(bidRequest); bidRequestWithInstlEquals1.params.instl = 1; response = spec.buildRequests([bidRequestWithInstlEquals1], bidRequest2)[0]; @@ -139,10 +315,9 @@ describe('GamoshiAdapter', function () { 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 () { + it('builds request banner object correctly', () => { let response; const bidRequestWithBanner = utils.deepClone(bidRequest); bidRequestWithBanner.mediaTypes = { @@ -161,33 +336,41 @@ describe('GamoshiAdapter', function () { expect(response.data.imp[0].banner.pos).to.equal(bidRequestWithPosEquals1.params.pos); }); - it('builds request video object correctly', function () { + it('builds request video object correctly', () => { let response; const bidRequestWithVideo = utils.deepClone(bidRequest); bidRequestWithVideo.mediaTypes = { video: { - playerSize: [302, 252] + 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); + bidRequestWithVideo.mediaTypes = { + video: { + playerSize: [302, 252] + } + }; + const bidRequestWithPosEquals1 = utils.deepClone(bidRequestWithVideo); + expect(response.data.imp[0].video.w).to.equal(bidRequestWithVideo.mediaTypes.video.playerSize[0]); + expect(response.data.imp[0].video.h).to.equal(bidRequestWithVideo.mediaTypes.video.playerSize[1]); + 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; + it('builds request video object correctly with context', () => { const bidRequestWithVideo = utils.deepClone(bidRequest); bidRequestWithVideo.mediaTypes = { video: { context: 'instream' } }; - response = spec.buildRequests([bidRequestWithVideo], bidRequest)[0]; + let response = spec.buildRequests([bidRequestWithVideo], bidRequest)[0]; expect(response.data.imp[0].video.ext.context).to.equal('instream'); bidRequestWithVideo.mediaTypes.video.context = 'outstream'; @@ -202,7 +385,7 @@ describe('GamoshiAdapter', function () { expect(response.data.imp[0].video.ext.context).to.equal(null); }); - it('builds request video object correctly with multi-dimensions size array', function () { + it('builds request video object correctly with multi-dimensions size array', () => { let response; const bidRequestWithVideo = utils.deepClone(bidRequest); bidRequestWithVideo.mediaTypes.video = { @@ -225,18 +408,19 @@ describe('GamoshiAdapter', function () { expect(response.data.imp[1].video.ext.context).to.equal(null); }); - it('builds request with gdpr consent', function () { + it('builds request with gdpr consent', () => { let response = spec.buildRequests([bidRequest], bidRequest)[0]; - expect(response.data.ext.gdpr_consent).to.exist; + + expect(response.data.ext.gdpr_consent).to.not.equal(null).and.not.equal(undefined); 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.regs.ext.gdpr).to.not.equal(null).and.not.equal(undefined); expect(response.data.user.ext.consent).to.equal('some string'); }); - it('build request with ID5 Id', function () { + it('build request with ID5 Id', () => { const bidRequestClone = utils.deepClone(bidRequest); bidRequestClone.userId = {}; bidRequestClone.userId.id5id = 'id5-user-id'; @@ -252,7 +436,7 @@ describe('GamoshiAdapter', function () { }]); }); - it('build request with unified Id', function () { + it('build request with unified Id', () => { const bidRequestClone = utils.deepClone(bidRequest); bidRequestClone.userId = {}; bidRequestClone.userId.tdid = 'tdid-user-id'; @@ -270,107 +454,8 @@ describe('GamoshiAdapter', function () { }); 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}); + it('returns an empty array on missing response', () => { + let response = spec.interpretResponse(undefined, {bidRequest: bannerBidRequest}); expect(Array.isArray(response)).to.equal(true); expect(response.length).to.equal(0); @@ -379,7 +464,7 @@ describe('GamoshiAdapter', function () { expect(response.length).to.equal(0); }); - it('aggregates banner bids from all seat bids', function () { + it('aggregates banner bids from all seat bids', () => { const response = spec.interpretResponse({body: rtbResponse}, {bidRequest: bannerBidRequest}); expect(Array.isArray(response)).to.equal(true); expect(response.length).to.equal(1); @@ -397,7 +482,7 @@ describe('GamoshiAdapter', function () { expect(ad0.vastUrl).to.be.an('undefined'); }); - it('aggregates video bids from all seat bids', function () { + it('aggregates video bids from all seat bids', () => { const response = spec.interpretResponse({body: rtbResponse}, {bidRequest: videoBidRequest}); expect(Array.isArray(response)).to.equal(true); expect(response.length).to.equal(1); @@ -415,129 +500,62 @@ describe('GamoshiAdapter', function () { expect(ad0.vastUrl).to.equal(rtbResponse.seatbid[0].bid[0].ext.vast_url); }); - it('aggregates user-sync pixels', function () { + it('aggregates user-sync pixels', () => { 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[0].url).to.equal('//rtb.gamoshi.io/user/sync/1?gdpr=0&consent=&usp='); 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[1].url).to.equal('//rtb.gamoshi.io/user/sync/2'); 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[2].url).to.equal('//p.partner1.io/user/sync/1'); 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'); + expect(response[3].url).to.equal('//p.partner2.io/user/sync/1'); }); - 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); + it('supports configuring outstream renderers', () => { + 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('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); + it('validates in/existing of gdpr consent', () => { + let result = spec.getUserSyncs({}, [{body: videoResponse}], gdprConsent, 'gamoshiCCPA'); 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'); + expect(result[0].url).to.equal('https://rtb.gamoshi.io/pix/1275/scm?cb=1545900621675&gdpr=1&consent=consent%20string&us_privacy=gamoshiCCPA'); gdprConsent.gdprApplies = false; - result = spec.getUserSyncs({}, [{body: videoResponse}], gdprConsent); + result = spec.getUserSyncs({}, [{body: videoResponse}], gdprConsent, 'gamoshiCCPA'); 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'); + expect(result[0].url).to.equal('https://rtb.gamoshi.io/pix/1275/scm?cb=1545900621675&gdpr=0&consent=&us_privacy=gamoshiCCPA'); 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'); + expect(result[0].url).to.equal('https://rtb.gamoshi.io/pix/1275/scm'); + }); + + it('validates existence of gdpr, gdpr consent and usp consent', () => { + let result = spec.getUserSyncs({}, [{body: videoResponse}], gdprConsent, 'gamoshiCCPA'); + 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&gdpr=1&consent=consent%20string&us_privacy=gamoshiCCPA'); + + 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&gdpr=0&consent=&us_privacy='); }); }); }); diff --git a/test/spec/modules/gdprEnforcement_spec.js b/test/spec/modules/gdprEnforcement_spec.js new file mode 100644 index 00000000000..5b46441cbbb --- /dev/null +++ b/test/spec/modules/gdprEnforcement_spec.js @@ -0,0 +1,418 @@ +import { deviceAccessHook, setEnforcementConfig, userSyncHook, userIdHook } from 'modules/gdprEnforcement.js'; +import { config } from 'src/config.js'; +import adapterManager, { gdprDataHandler } from 'src/adapterManager.js'; +import * as utils from 'src/utils.js'; +import { validateStorageEnforcement } from 'src/storageManager.js'; +import { executeStorageCallbacks } from 'src/prebid.js'; + +describe('gdpr enforcement', function() { + let nextFnSpy; + let logWarnSpy; + let gdprDataHandlerStub; + let staticConfig = { + cmpApi: 'static', + timeout: 7500, + allowAuctionWithoutConsent: false, + consentData: { + getTCData: { + 'tcString': 'COuqj-POu90rDBcBkBENAZCgAPzAAAPAACiQFwwBAABAA1ADEAbQC4YAYAAgAxAG0A', + 'cmpId': 92, + 'cmpVersion': 100, + 'tcfPolicyVersion': 2, + 'gdprApplies': true, + 'isServiceSpecific': true, + 'useNonStandardStacks': false, + 'purposeOneTreatment': false, + 'publisherCC': 'US', + 'cmpStatus': 'loaded', + 'eventStatus': 'tcloaded', + 'outOfBand': { + 'allowedVendors': {}, + 'discloseVendors': {} + }, + 'purpose': { + 'consents': { + '1': true, + '2': true, + '3': true + }, + 'legitimateInterests': { + '1': false, + '2': false, + '3': false + } + }, + 'vendor': { + 'consents': { + '1': true, + '2': true, + '3': false + }, + 'legitimateInterests': { + '1': false, + '2': true, + '3': false, + '4': false, + '5': false + } + }, + 'specialFeatureOptins': { + '1': false, + '2': false + }, + 'restrictions': {}, + 'publisher': { + 'consents': { + '1': false, + '2': false, + '3': false + }, + 'legitimateInterests': { + '1': false, + '2': false, + '3': false + }, + 'customPurpose': { + 'consents': {}, + 'legitimateInterests': {} + } + } + } + } + }; + + after(function() { + validateStorageEnforcement.getHooks({hook: deviceAccessHook}).remove(); + $$PREBID_GLOBAL$$.requestBids.getHooks({hook: executeStorageCallbacks}).remove(); + }) + + describe('deviceAccessHook', function() { + beforeEach(function() { + nextFnSpy = sinon.spy(); + gdprDataHandlerStub = sinon.stub(gdprDataHandler, 'getConsentData'); + logWarnSpy = sinon.spy(utils, 'logWarn'); + }); + afterEach(function() { + config.resetConfig(); + gdprDataHandler.getConsentData.restore(); + logWarnSpy.restore(); + }); + it('should not allow device access when device access flag is set to false', function() { + config.setConfig({ + deviceAccess: false, + consentManagement: { + gdpr: { + rules: [{ + purpose: 'storage', + enforcePurpose: false, + enforceVendor: false, + vendorExceptions: ['appnexus', 'rubicon'] + }] + } + } + }); + + deviceAccessHook(nextFnSpy); + expect(nextFnSpy.calledOnce).to.equal(true); + let result = { + hasEnforcementHook: true, + valid: false + } + expect(nextFnSpy.calledWith(undefined, result)); + }); + + it('should only check for consent for vendor exceptions when enforcePurpose and enforceVendor are false', function() { + setEnforcementConfig({ + gdpr: { + rules: [{ + purpose: 'storage', + enforcePurpose: false, + enforceVendor: false, + vendorExceptions: ['appnexus'] + }] + } + }); + let consentData = {} + consentData.vendorData = staticConfig.consentData.getTCData; + consentData.gdprApplies = true; + consentData.apiVersion = 2; + gdprDataHandlerStub.returns(consentData); + + deviceAccessHook(nextFnSpy, 1, 'appnexus'); + deviceAccessHook(nextFnSpy, 5, 'rubicon'); + expect(logWarnSpy.callCount).to.equal(0); + }); + + it('should check consent for all vendors when enforcePurpose and enforceVendor are true', function() { + setEnforcementConfig({ + gdpr: { + rules: [{ + purpose: 'storage', + enforcePurpose: true, + enforceVendor: true, + }] + } + }); + let consentData = {} + consentData.vendorData = staticConfig.consentData.getTCData; + consentData.gdprApplies = true; + consentData.apiVersion = 2; + gdprDataHandlerStub.returns(consentData); + + deviceAccessHook(nextFnSpy, 1, 'appnexus'); + deviceAccessHook(nextFnSpy, 3, 'rubicon'); + expect(logWarnSpy.callCount).to.equal(1); + }); + + it('should allow device access when gdprApplies is false and hasDeviceAccess flag is true', function() { + setEnforcementConfig({ + gdpr: { + rules: [{ + purpose: 'storage', + enforcePurpose: true, + enforceVendor: true, + vendorExceptions: [] + }] + } + }); + let consentData = {} + consentData.vendorData = staticConfig.consentData.getTCData; + consentData.gdprApplies = false; + consentData.apiVersion = 2; + gdprDataHandlerStub.returns(consentData); + + deviceAccessHook(nextFnSpy, 1, 'appnexus'); + expect(nextFnSpy.calledOnce).to.equal(true); + let result = { + hasEnforcementHook: true, + valid: true + } + expect(nextFnSpy.calledWith(undefined, result)); + }); + }); + + describe('userSyncHook', function() { + let curBidderStub; + let adapterManagerStub; + + beforeEach(function() { + gdprDataHandlerStub = sinon.stub(gdprDataHandler, 'getConsentData'); + logWarnSpy = sinon.spy(utils, 'logWarn'); + curBidderStub = sinon.stub(config, 'getCurrentBidder'); + adapterManagerStub = sinon.stub(adapterManager, 'getBidAdapter'); + nextFnSpy = sinon.spy(); + }); + + afterEach(function() { + config.getCurrentBidder.restore(); + config.resetConfig(); + gdprDataHandler.getConsentData.restore(); + adapterManager.getBidAdapter.restore(); + logWarnSpy.restore(); + }); + + it('should allow bidder to do user sync if consent is true', function() { + setEnforcementConfig({ + gdpr: { + rules: [{ + purpose: 'storage', + enforcePurpose: false, + enforceVendor: true, + vendorExceptions: ['sampleBidder2'] + }] + } + }); + let consentData = {} + consentData.vendorData = staticConfig.consentData.getTCData; + consentData.gdprApplies = true; + consentData.apiVersion = 2; + gdprDataHandlerStub.returns(consentData); + + curBidderStub.returns('sampleBidder1'); + adapterManagerStub.withArgs('sampleBidder1').returns({ + getSpec: function() { + return { + 'gvlid': 1 + } + } + }); + userSyncHook(nextFnSpy); + + curBidderStub.returns('sampleBidder2'); + adapterManagerStub.withArgs('sampleBidder2').returns({ + getSpec: function() { + return { + 'gvlid': 3 + } + } + }); + userSyncHook(nextFnSpy); + expect(nextFnSpy.calledTwice).to.equal(true); + }); + + it('should not allow bidder to do user sync if user has denied consent', function() { + setEnforcementConfig({ + gdpr: { + rules: [{ + purpose: 'storage', + enforcePurpose: false, + enforceVendor: true, + vendorExceptions: [] + }] + } + }); + let consentData = {} + consentData.vendorData = staticConfig.consentData.getTCData; + consentData.apiVersion = 2; + consentData.gdprApplies = true; + gdprDataHandlerStub.returns(consentData); + + curBidderStub.returns('sampleBidder1'); + adapterManagerStub.withArgs('sampleBidder1').returns({ + getSpec: function() { + return { + 'gvlid': 1 + } + } + }); + userSyncHook(nextFnSpy); + + curBidderStub.returns('sampleBidder2'); + adapterManagerStub.withArgs('sampleBidder2').returns({ + getSpec: function() { + return { + 'gvlid': 3 + } + } + }); + userSyncHook(nextFnSpy); + expect(nextFnSpy.calledOnce).to.equal(true); + expect(logWarnSpy.callCount).to.equal(1); + }); + + it('should not check vendor consent when enforceVendor is false', function() { + setEnforcementConfig({ + gdpr: { + rules: [{ + purpose: 'storage', + enforcePurpose: true, + enforceVendor: false, + vendorExceptions: ['sampleBidder1'] + }] + } + }); + let consentData = {} + consentData.vendorData = staticConfig.consentData.getTCData; + consentData.apiVersion = 2; + consentData.gdprApplies = true; + gdprDataHandlerStub.returns(consentData); + + curBidderStub.returns('sampleBidder1'); + adapterManagerStub.withArgs('sampleBidder1').returns({ + getSpec: function() { + return { + 'gvlid': 1 + } + } + }); + userSyncHook(nextFnSpy); + + curBidderStub.returns('sampleBidder2'); + adapterManagerStub.withArgs('sampleBidder2').returns({ + getSpec: function() { + return { + 'gvlid': 3 + } + } + }); + userSyncHook(nextFnSpy); + expect(nextFnSpy.calledTwice).to.equal(true); + expect(logWarnSpy.callCount).to.equal(0); + }); + }); + + describe('userIdHook', function() { + beforeEach(function() { + logWarnSpy = sinon.spy(utils, 'logWarn'); + nextFnSpy = sinon.spy(); + }); + afterEach(function() { + config.resetConfig(); + logWarnSpy.restore(); + }); + it('should allow user id module if consent is given', function() { + setEnforcementConfig({ + gdpr: { + rules: [{ + purpose: 'storage', + enforcePurpose: false, + enforceVendor: true, + vendorExceptions: [] + }] + } + }); + let consentData = {} + consentData.vendorData = staticConfig.consentData.getTCData; + consentData.apiVersion = 2; + consentData.gdprApplies = true; + let submodules = [{ + submodule: { + gvlid: 1, + name: 'sampleUserId' + } + }] + userIdHook(nextFnSpy, submodules, consentData); + expect(nextFnSpy.calledOnce).to.equal(true); + }); + + it('should allow userId module if gdpr not in scope', function() { + let submodules = [{ + submodule: { + gvlid: 1, + name: 'sampleUserId' + } + }]; + let consentData = null; + userIdHook(nextFnSpy, submodules, consentData); + expect(nextFnSpy.calledOnce).to.equal(true); + expect(nextFnSpy.calledWith(undefined, submodules, consentData)); + }); + + it('should not allow user id module if user denied consent', function() { + setEnforcementConfig({ + gdpr: { + rules: [{ + purpose: 'storage', + enforcePurpose: false, + enforceVendor: true, + vendorExceptions: [] + }] + } + }); + let consentData = {} + consentData.vendorData = staticConfig.consentData.getTCData; + consentData.apiVersion = 2; + consentData.gdprApplies = true; + let submodules = [{ + submodule: { + gvlid: 1, + name: 'sampleUserId' + } + }, { + submodule: { + gvlid: 3, + name: 'sampleUserId1' + } + }] + userIdHook(nextFnSpy, submodules, consentData); + expect(logWarnSpy.callCount).to.equal(1); + let expectedSubmodules = [{ + submodule: { + gvlid: 1, + name: 'sampleUserId' + } + }] + expect(nextFnSpy.calledWith(undefined, expectedSubmodules, consentData)); + }); + }); +}); diff --git a/test/spec/modules/getintentBidAdapter_spec.js b/test/spec/modules/getintentBidAdapter_spec.js index ebbda7e108e..1959bda5c39 100644 --- a/test/spec/modules/getintentBidAdapter_spec.js +++ b/test/spec/modules/getintentBidAdapter_spec.js @@ -1,5 +1,5 @@ import { expect } from 'chai' -import { spec } from 'modules/getintentBidAdapter' +import { spec } from 'modules/getintentBidAdapter.js' describe('GetIntent Adapter Tests:', function () { const bidRequests = [{ @@ -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 bab2415745d..00000000000 --- 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 a18ea1b99c3..00000000000 --- 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/googleAnalyticsAdapter_spec.js b/test/spec/modules/googleAnalyticsAdapter_spec.js index 6bc0d4e192d..b801b5fe696 100644 --- a/test/spec/modules/googleAnalyticsAdapter_spec.js +++ b/test/spec/modules/googleAnalyticsAdapter_spec.js @@ -1,4 +1,4 @@ -import ga from 'modules/googleAnalyticsAdapter'; +import ga from 'modules/googleAnalyticsAdapter.js'; var assert = require('assert'); diff --git a/test/spec/modules/gridBidAdapter_spec.js b/test/spec/modules/gridBidAdapter_spec.js index d972ec25c8a..26ab27f5273 100644 --- a/test/spec/modules/gridBidAdapter_spec.js +++ b/test/spec/modules/gridBidAdapter_spec.js @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import { spec, resetUserSync, getSyncUrl } from 'modules/gridBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; +import { spec, resetUserSync, getSyncUrl } from 'modules/gridBidAdapter.js'; +import { newBidder } from 'src/adapters/bidderFactory.js'; describe('TheMediaGrid Adapter', function () { const adapter = newBidder(spec); @@ -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 = [ { @@ -131,6 +131,14 @@ describe('TheMediaGrid Adapter', function () { expect(payload).to.have.property('gdpr_consent', 'AAA'); 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'); + }); }); describe('interpretResponse', function () { @@ -663,5 +671,11 @@ describe('TheMediaGrid Adapter', function () { type: 'image', url: syncUrl }); }); + + it('should pass usPrivacy param if it is available', function() { + expect(spec.getUserSyncs({ pixelEnabled: true }, {}, {}, '1YNN')).to.deep.equal({ + type: 'image', url: `${syncUrl}&us_privacy=1YNN` + }); + }); }); }); diff --git a/test/spec/modules/gridNMBidAdapter_spec.js b/test/spec/modules/gridNMBidAdapter_spec.js new file mode 100644 index 00000000000..0dbaac0c526 --- /dev/null +++ b/test/spec/modules/gridNMBidAdapter_spec.js @@ -0,0 +1,461 @@ +import { expect } from 'chai'; +import { spec, resetUserSync, getSyncUrl } from 'modules/gridNMBidAdapter.js'; +import { newBidder } from 'src/adapters/bidderFactory.js'; + +describe('TheMediaGridNM 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': 'gridNM', + 'params': { + 'source': 'jwp', + 'secid': '11', + 'pubid': '22', + 'video': { + 'mimes': ['video/mp4', 'video/x-ms-wmv'], + 'protocols': [1, 2, 3, 4, 5, 6] + } + }, + '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 () { + const paramsList = [ + { + 'source': 'jwp', + 'secid': '11', + 'pubid': '22', + 'video': { + 'protocols': [1, 2, 3, 4, 5, 6] + } + }, + { + 'source': 'jwp', + 'secid': '11', + 'pubid': '22', + 'video': { + 'mimes': ['video/mp4', 'video/x-ms-wmv'], + } + }, + { + 'secid': '11', + 'pubid': '22', + 'video': { + 'mimes': ['video/mp4', 'video/x-ms-wmv'], + 'protocols': [1, 2, 3, 4, 5, 6] + } + }, + { + 'source': 'jwp', + 'pubid': '22', + 'video': { + 'mimes': ['video/mp4', 'video/x-ms-wmv'], + 'protocols': [1, 2, 3, 4, 5, 6] + } + }, + { + 'source': 'jwp', + 'secid': '11', + 'video': { + 'mimes': ['video/mp4', 'video/x-ms-wmv'], + 'protocols': [1, 2, 3, 4, 5, 6] + } + } + ]; + paramsList.forEach((params) => { + const invalidBid = Object.assign({}, bid); + delete invalidBid.params; + invalidBid.params = params; + expect(spec.isBidRequestValid(invalidBid)).to.equal(false); + }); + }); + + it('should return false when required params has invalid values', function () { + const paramsList = [ + { + 'source': 'jwp', + 'secid': '11', + 'pubid': '22', + 'video': { + 'mimes': ['video/mp4', 'video/x-ms-wmv'], + 'protocols': '1,2,3,4,5' + } + }, + { + 'source': 'jwp', + 'secid': '11', + 'pubid': '22', + 'video': { + 'mimes': [1, 2], + 'protocols': [1, 2, 3, 4, 5] + } + }, + { + 'source': 'jwp', + 'secid': 11, + 'pubid': '22', + 'video': { + 'mimes': ['video/mp4', 'video/x-ms-wmv'], + 'protocols': [1, 2, 3, 4, 5] + } + }, + { + 'source': 111, + 'secid': '11', + 'pubid': '22', + 'video': { + 'mimes': ['video/mp4', 'video/x-ms-wmv'], + 'protocols': [1, 2, 3, 4, 5] + } + } + ]; + + paramsList.forEach((params) => { + const invalidBid = Object.assign({}, bid); + delete invalidBid.params; + invalidBid.params = params; + expect(spec.isBidRequestValid(invalidBid)).to.equal(false); + }); + }); + }); + + describe('buildRequests', function () { + function parseRequestUrl(url) { + const res = {}; + url.replace(/^[^\?]+\?/, '').split('&').forEach((it) => { + const couple = it.split('='); + res[couple[0]] = decodeURIComponent(couple[1]); + }); + return res; + } + const bidderRequest = {refererInfo: {referer: 'https://example.com'}}; + const referrer = bidderRequest.refererInfo.referer; + let bidRequests = [ + { + 'bidder': 'gridNM', + 'params': { + 'source': 'jwp', + 'secid': '11', + 'pubid': '22', + 'video': { + 'mimes': ['video/mp4', 'video/x-ms-wmv'], + 'protocols': [1, 2, 3, 4, 5, 6] + } + }, + 'adUnitCode': 'adunit-code-1', + 'sizes': [[300, 250], [300, 600]], + 'bidId': '30b31c1838de1e', + 'bidderRequestId': '22edbae2733bf6', + 'auctionId': '1d1a030790a475', + }, + { + 'bidder': 'gridNM', + 'params': { + 'source': 'jwp', + 'secid': '11', + 'pubid': '22', + 'video': { + 'mimes': ['video/mp4'], + 'protocols': [1, 2, 3], + 'skip': 1 + } + }, + 'adUnitCode': 'adunit-code-2', + 'sizes': [[728, 90]], + 'bidId': '3150ccb55da321', + 'bidderRequestId': '22edbae2733bf6', + 'auctionId': '1d1a030790a475', + } + ]; + + it('should attach valid params to the tag', function () { + const requests = spec.buildRequests(bidRequests, bidderRequest); + const requestsSizes = ['300x250,300x600', '728x90']; + requests.forEach((req, i) => { + expect(req.url).to.be.an('string'); + const payload = parseRequestUrl(req.url); + expect(payload).to.have.property('u', referrer); + expect(payload).to.have.property('r', '22edbae2733bf6'); + expect(payload).to.have.property('wrapperType', 'Prebid_js'); + expect(payload).to.have.property('wrapperVersion', '$prebid.version$'); + expect(payload).to.have.property('sizes', requestsSizes[i]); + expect(req.data).to.deep.equal(bidRequests[i].params); + }); + }); + + it('if gdprConsent is present payload must have gdpr params', function () { + const [request] = spec.buildRequests([bidRequests[0]], {gdprConsent: {consentString: 'AAA', gdprApplies: true}, refererInfo: bidderRequest.refererInfo}); + expect(request.url).to.be.an('string'); + const payload = parseRequestUrl(request.url); + expect(payload).to.have.property('u', referrer); + 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[0]], {gdprConsent: {consentString: 'AAA', gdprApplies: false}}); + expect(request.url).to.be.an('string'); + const payload = parseRequestUrl(request.url); + 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[0]], {gdprConsent: {consentString: 'AAA'}}); + expect(request.url).to.be.an('string'); + const payload = parseRequestUrl(request.url); + expect(payload).to.have.property('gdpr_consent', 'AAA'); + 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[0]], bidderRequestWithUSP); + expect(request.url).to.be.an('string'); + const payload = parseRequestUrl(request.url); + expect(payload).to.have.property('us_privacy', '1YNN'); + }); + }); + + describe('interpretResponse', function () { + const responses = [ + {'bid': [{'price': 1.15, 'adm': '\n<\/Ad>\n<\/VAST>', 'content_type': 'video', 'h': 250, 'w': 300, 'dealid': 11}], 'seat': '2'}, + {'bid': [{'price': 0.5, 'adm': '\n<\/Ad>\n<\/VAST>', 'content_type': 'video', 'h': 600, 'w': 300}], 'seat': '2'}, + {'bid': [{'price': 0, 'h': 250, 'w': 300}], 'seat': '2'}, + {'bid': [{'price': 0, 'adm': '\n<\/Ad>\n<\/VAST>', 'h': 250, 'w': 300}], 'seat': '2'}, + undefined, + {'bid': [], 'seat': '2'}, + {'seat': '2'}, + ]; + + it('should get correct video bid response', function () { + const bidRequests = [ + { + 'bidder': 'gridNM', + 'params': { + 'source': 'jwp', + 'secid': '11', + 'pubid': '22', + 'video': { + 'mimes': ['video/mp4', 'video/x-ms-wmv'], + 'protocols': [1, 2, 3, 4, 5, 6] + } + }, + 'adUnitCode': 'adunit-code-1', + 'sizes': [[300, 250], [300, 600]], + 'bidId': '659423fff799cb', + 'bidderRequestId': '5f2009617a7c0a', + 'auctionId': '1cbd2feafe5e8b', + 'mediaTypes': { + 'video': { + 'context': 'instream' + } + } + }, + { + 'bidder': 'gridNM', + 'params': { + 'source': 'jwp', + 'secid': '11', + 'pubid': '22', + 'video': { + 'mimes': ['video/mp4'], + 'protocols': [1, 2, 3, 4, 5], + 'skip': 1 + } + }, + 'adUnitCode': 'adunit-code-1', + 'sizes': [[300, 250], [300, 600]], + 'bidId': '2bc598e42b6a', + 'bidderRequestId': '1e8b5a465f404', + 'auctionId': '1cbd2feafe5e8b', + 'mediaTypes': { + 'video': { + 'context': 'instream' + } + } + } + ]; + const requests = spec.buildRequests(bidRequests); + const expectedResponse = [ + { + 'requestId': '659423fff799cb', + 'cpm': 1.15, + 'creativeId': '5f2009617a7c0a', + 'dealId': 11, + 'width': 300, + 'height': 250, + 'bidderCode': 'gridNM', + 'currency': 'USD', + 'mediaType': 'video', + 'netRevenue': false, + 'ttl': 360, + 'vastXml': '\n<\/Ad>\n<\/VAST>', + 'adResponse': { + 'content': '\n<\/Ad>\n<\/VAST>' + } + }, + { + 'requestId': '2bc598e42b6a', + 'cpm': 0.5, + 'creativeId': '1e8b5a465f404', + 'dealId': undefined, + 'width': 300, + 'height': 600, + 'bidderCode': 'gridNM', + 'currency': 'USD', + 'mediaType': 'video', + 'netRevenue': false, + 'ttl': 360, + 'vastXml': '\n<\/Ad>\n<\/VAST>', + 'adResponse': { + 'content': '\n<\/Ad>\n<\/VAST>' + } + } + ]; + + requests.forEach((req, i) => { + const result = spec.interpretResponse({'body': {'seatbid': [responses[i]]}}, req); + expect(result[0]).to.deep.equal(expectedResponse[i]); + }); + }); + + it('handles wrong and nobid responses', function () { + responses.slice(2).forEach((resp) => { + const request = spec.buildRequests([{ + 'bidder': 'gridNM', + 'params': { + 'source': 'jwp', + 'secid': '11', + 'pubid': '22', + 'video': { + 'mimes': ['video/mp4'], + 'protocols': [1, 2, 3, 4, 5], + 'skip': 1 + } + }, + 'adUnitCode': 'adunit-code-1', + 'sizes': [[300, 250], [300, 600]], + 'bidId': '2bc598e42b6a', + 'bidderRequestId': '39d74f5b71464', + 'auctionId': '1cbd2feafe5e8b', + 'mediaTypes': { + 'video': { + 'context': 'instream' + } + } + }]); + const result = spec.interpretResponse({'body': {'seatbid': [resp]}}, request[0]); + expect(result.length).to.equal(0); + }); + }); + }); + + describe('user sync', function () { + const syncUrl = getSyncUrl(); + + beforeEach(function () { + resetUserSync(); + }); + + it('should register the Emily iframe', function () { + let syncs = spec.getUserSyncs({ + pixelEnabled: true + }); + + expect(syncs).to.deep.equal({type: 'image', url: syncUrl}); + }); + + it('should not register the Emily iframe more than once', function () { + let syncs = spec.getUserSyncs({ + pixelEnabled: true + }); + expect(syncs).to.deep.equal({type: 'image', url: syncUrl}); + + // when called again, should still have only been called once + syncs = spec.getUserSyncs(); + expect(syncs).to.equal(undefined); + }); + + it('should pass gdpr params if consent is true', function () { + expect(spec.getUserSyncs({ pixelEnabled: true }, {}, { + gdprApplies: true, consentString: 'foo' + })).to.deep.equal({ + type: 'image', url: `${syncUrl}&gdpr=1&gdpr_consent=foo` + }); + }); + + it('should pass gdpr params if consent is false', function () { + expect(spec.getUserSyncs({ pixelEnabled: true }, {}, { + gdprApplies: false, consentString: 'foo' + })).to.deep.equal({ + type: 'image', url: `${syncUrl}&gdpr=0&gdpr_consent=foo` + }); + }); + + it('should pass gdpr param gdpr_consent only when gdprApplies is undefined', function () { + expect(spec.getUserSyncs({ pixelEnabled: true }, {}, { + consentString: 'foo' + })).to.deep.equal({ + type: 'image', url: `${syncUrl}&gdpr_consent=foo` + }); + }); + + it('should pass no params if gdpr consentString is not defined', function () { + expect(spec.getUserSyncs({ pixelEnabled: true }, {}, {})).to.deep.equal({ + type: 'image', url: syncUrl + }); + }); + + it('should pass no params if gdpr consentString is a number', function () { + expect(spec.getUserSyncs({ pixelEnabled: true }, {}, { + consentString: 0 + })).to.deep.equal({ + type: 'image', url: syncUrl + }); + }); + + it('should pass no params if gdpr consentString is null', function () { + expect(spec.getUserSyncs({ pixelEnabled: true }, {}, { + consentString: null + })).to.deep.equal({ + type: 'image', url: syncUrl + }); + }); + + it('should pass no params if gdpr consentString is a object', function () { + expect(spec.getUserSyncs({ pixelEnabled: true }, {}, { + consentString: {} + })).to.deep.equal({ + type: 'image', url: syncUrl + }); + }); + + it('should pass no params if gdpr is not defined', function () { + expect(spec.getUserSyncs({ pixelEnabled: true }, {}, undefined)).to.deep.equal({ + type: 'image', url: syncUrl + }); + }); + + it('should pass usPrivacy param if it is available', function() { + expect(spec.getUserSyncs({ pixelEnabled: true }, {}, {}, '1YNN')).to.deep.equal({ + type: 'image', url: `${syncUrl}&us_privacy=1YNN` + }); + }); + }); +}); diff --git a/test/spec/modules/gumgumBidAdapter_spec.js b/test/spec/modules/gumgumBidAdapter_spec.js index cbd71cc82f0..a2fbc2cf029 100644 --- a/test/spec/modules/gumgumBidAdapter_spec.js +++ b/test/spec/modules/gumgumBidAdapter_spec.js @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import { newBidder } from 'src/adapters/bidderFactory'; -import { spec } from 'modules/gumgumBidAdapter'; +import { newBidder } from 'src/adapters/bidderFactory.js'; +import { spec } from 'modules/gumgumBidAdapter.js'; const ENDPOINT = 'https://g2.gumgum.com/hbid/imp'; @@ -106,7 +106,7 @@ describe('gumgumAdapter', function () { expect(request.method).to.equal('GET'); expect(request.id).to.equal('30b31c1838de1e'); }); - it('should correctly set the request paramters depending on params field', function () { + it('should set t and fp parameters in bid request if inScreen request param is found', function () { const request = Object.assign({}, bidRequests[0]); delete request.params; request.params = { @@ -129,7 +129,7 @@ describe('gumgumAdapter', function () { 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 () { + it('should set a ni parameter in bid request if ICV request param is found', function () { const request = Object.assign({}, bidRequests[0]); delete request.params; request.params = { @@ -139,6 +139,36 @@ describe('gumgumAdapter', function () { expect(bidRequest.data.pi).to.equal(5); expect(bidRequest.data).to.include.any.keys('ni'); }); + it('should add parameters associated with video if video request param is found', function () { + const videoVals = { + playerSize: [640, 480], + context: 'instream', + minduration: 1, + maxduration: 2, + linearity: 1, + startdelay: 1, + placement: 123456, + protocols: [1, 2] + }; + const request = Object.assign({}, bidRequests[0]); + delete request.params; + request.mediaTypes = { + video: videoVals + }; + request.params = { + 'video': '10433395' + }; + const bidRequest = spec.buildRequests([request])[0]; + expect(bidRequest.data.pi).to.eq(7); + expect(bidRequest.data.mind).to.eq(videoVals.minduration); + expect(bidRequest.data.maxd).to.eq(videoVals.maxduration); + expect(bidRequest.data.li).to.eq(videoVals.linearity); + expect(bidRequest.data.sd).to.eq(videoVals.startdelay); + expect(bidRequest.data.pt).to.eq(videoVals.placement); + expect(bidRequest.data.pr).to.eq(videoVals.protocols.join(',')); + expect(bidRequest.data.viw).to.eq(videoVals.playerSize[0].toString()); + expect(bidRequest.data.vih).to.eq(videoVals.playerSize[1].toString()); + }); it('should not add additional parameters depending on params field', function () { const request = spec.buildRequests(bidRequests)[0]; expect(request.data).to.not.include.any.keys('ni'); @@ -146,7 +176,7 @@ describe('gumgumAdapter', function () { expect(request.data).to.not.include.any.keys('eAdBuyId'); expect(request.data).to.not.include.any.keys('adBuyId'); }); - it('should add consent parameters if gdprConsent is present', function () { + it('should add gdpr consent parameters if gdprConsent is present', function () { const gdprConsent = { consentString: 'BOJ/P2HOJ/P2HABABMAAAAAZ+A==', gdprApplies: true }; const fakeBidRequest = { gdprConsent: gdprConsent }; const bidRequest = spec.buildRequests(bidRequests, fakeBidRequest)[0]; @@ -159,6 +189,14 @@ describe('gumgumAdapter', function () { const bidRequest = spec.buildRequests(bidRequests, fakeBidRequest)[0]; expect(bidRequest.data).to.not.include.any.keys('gdprConsent') }); + it('should add uspConsent parameter if it is present in the bidderRequest', function () { + const noUspBidRequest = spec.buildRequests(bidRequests)[0]; + const uspConsentObj = { uspConsent: '1YYY' }; + const bidRequest = spec.buildRequests(bidRequests, uspConsentObj)[0]; + expect(noUspBidRequest.data).to.not.include.any.keys('uspConsent'); + expect(bidRequest.data).to.include.any.keys('uspConsent'); + expect(bidRequest.data.uspConsent).to.eq(uspConsentObj.uspConsent); + }); it('should add a tdid parameter if request contains unified id from TradeDesk', function () { const unifiedId = { 'userId': { @@ -190,6 +228,13 @@ describe('gumgumAdapter', function () { expect(bidRequest.data).to.not.include.any.keys('ns'); } }); + it('has jcsi param correctly encoded', function () { + const jcsi = JSON.stringify({ t: 0, rq: 8 }); + const encodedJCSI = encodeURIComponent(jcsi); + const bidRequest = spec.buildRequests(bidRequests)[0]; + expect(bidRequest.data.jcsi).to.not.contain(/\{.*\}/); + expect(bidRequest.data.jcsi).to.eq(encodedJCSI); + }); }) describe('interpretResponse', function () { @@ -222,24 +267,33 @@ describe('gumgumAdapter', function () { method: 'GET', pi: 3 } + let expectedResponse = { + 'ad': '

I am an ad

', + 'cpm': 0, + 'creativeId': 29593, + 'currency': 'USD', + 'height': '250', + 'netRevenue': true, + 'requestId': 12345, + 'width': '300', + // dealId: DEAL_ID, + // referrer: REFERER, + ttl: 60 + }; it('should get correct bid response', function () { - let expectedResponse = { - 'ad': '

I am an ad

', - 'cpm': 0, - 'creativeId': 29593, - 'currency': 'USD', - 'height': '250', - 'netRevenue': true, - 'requestId': 12345, - 'width': '300', - // dealId: DEAL_ID, - // referrer: REFERER, - ttl: 60 - }; expect(spec.interpretResponse({ body: serverResponse }, bidRequest)).to.deep.equal([expectedResponse]); }); + it('should pass correct currency if found in bid response', function () { + const cur = 'EURO'; + let response = Object.assign({}, serverResponse); + let expected = Object.assign({}, expectedResponse); + response.ad.cur = cur; + expected.currency = cur; + expect(spec.interpretResponse({ body: response }, bidRequest)).to.deep.equal([expected]); + }); + it('handles nobid responses', function () { let response = { 'ad': {}, diff --git a/test/spec/modules/gxoneBidAdapter_spec.js b/test/spec/modules/gxoneBidAdapter_spec.js deleted file mode 100644 index afeb2c781f5..00000000000 --- 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 37ec44f07c4..9023fb248e9 100644 --- a/test/spec/modules/hpmdnetworkBidAdapter_spec.js +++ b/test/spec/modules/hpmdnetworkBidAdapter_spec.js @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import { spec } from 'modules/hpmdnetworkBidAdapter'; +import { spec } from 'modules/hpmdnetworkBidAdapter.js'; describe('HPMDNetwork Adapter', function() { describe('isBidRequestValid', function () { @@ -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/hybridBidAdapter_spec.js b/test/spec/modules/hybridBidAdapter_spec.js new file mode 100644 index 00000000000..e5ad878c9b1 --- /dev/null +++ b/test/spec/modules/hybridBidAdapter_spec.js @@ -0,0 +1,275 @@ +import { expect } from 'chai' +import { spec } from 'modules/hybridBidAdapter.js' + +function getSlotConfigs(mediaTypes, params) { + return { + params: params, + sizes: [], + bidId: '2df8c0733f284e', + bidder: 'hybrid', + mediaTypes: mediaTypes, + transactionId: '31a58515-3634-4e90-9c96-f86196db1459' + } +} + +describe('Hybrid.ai Adapter', function() { + const PLACE_ID = '5af45ad34d506ee7acad0c26'; + const bidderRequest = { + refererInfo: { referer: 'referer' } + } + const bannerMandatoryParams = { + placeId: PLACE_ID, + placement: 'banner' + } + const videoMandatoryParams = { + placeId: PLACE_ID, + placement: 'video' + } + const validBidRequests = [ + getSlotConfigs({ banner: {} }, bannerMandatoryParams), + getSlotConfigs({ video: {playerSize: [[640, 480]]} }, videoMandatoryParams) + ] + describe('isBidRequestValid method', function() { + describe('returns true', function() { + describe('when banner slot config has all mandatory params', () => { + describe('and placement has the correct value', function() { + const slotConfig = getSlotConfigs( + { banner: {} }, + { + placeId: PLACE_ID, + placement: 'banner' + } + ) + const isBidRequestValid = spec.isBidRequestValid(slotConfig) + expect(isBidRequestValid).to.equal(true) + }) + describe('when video slot has all mandatory params.', function() { + it('should return true, when video mediatype object are correct.', function() { + const slotConfig = getSlotConfigs( + { + video: { + context: 'instream', + playerSize: [[640, 480]] + } + }, + { + placeId: PLACE_ID, + placement: 'video' + } + ) + const isBidRequestValid = spec.isBidRequestValid(slotConfig) + 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({ + placement: 'banner' + }) + ) + expect(isBidRequestValid).to.equal(false) + }) + it('does not have the placement.', function() { + const isBidRequestValid = spec.isBidRequestValid( + createSlotconfig({ + placeId: PLACE_ID + }) + ) + expect(isBidRequestValid).to.equal(false) + }) + it('does not have a the correct placement.', function() { + const isBidRequestValid = spec.isBidRequestValid( + createSlotconfig({ + placeId: PLACE_ID, + placement: 'something' + }) + ) + expect(isBidRequestValid).to.equal(false) + }) + }) + describe('when video mediaType object is not correct.', function() { + function createVideoSlotconfig(mediaType) { + return getSlotConfigs(mediaType, { + placeId: PLACE_ID, + placement: 'video' + }) + } + it('is a void object', function() { + const isBidRequestValid = spec.isBidRequestValid( + createVideoSlotconfig({ video: {} }) + ) + expect(isBidRequestValid).to.equal(false) + }) + it('does not have playerSize.', function() { + const isBidRequestValid = spec.isBidRequestValid( + createVideoSlotconfig({ video: { context: 'instream' } }) + ) + expect(isBidRequestValid).to.equal(false) + }) + it('does not have context', function() { + const isBidRequestValid = spec.isBidRequestValid( + createVideoSlotconfig({ + video: { + playerSize: [[640, 480]] + } + }) + ) + expect(isBidRequestValid).to.equal(false) + }) + }) + }) + }) + 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://hbe198.hybrid.ai/prebidhb') + }) + + describe('buildRequests method', function() { + 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) + expect(data.url).to.equal('referer') + data.bidRequests.forEach(bid => { + expect(bid.bidId).to.equal('2df8c0733f284e') + expect(bid.placeId).to.equal(PLACE_ID) + expect(bid.transactionId).to.equal('31a58515-3634-4e90-9c96-f86196db1459') + }) + }) + + 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.placement).to.equal(spec.placementTypes[bannerMandatoryParams.placement]) + }) + it('should request a Video', function() { + const bannerBid = bidRequests[1] + expect(bannerBid.placement).to.equal(spec.placementTypes[videoMandatoryParams.placement]) + }) + }) + }) + + describe('interpret response method', function() { + it('should return a void array, when the server response are not correct.', function() { + const request = { data: JSON.stringify({}) } + const serverResponse = { + body: {} + } + const bids = spec.interpretResponse(serverResponse, request) + expect(typeof bids).to.equal('object') + expect(bids.length).to.equal(0) + }) + it('should return a void array, when the server response have not got bids.', function() { + const request = { data: JSON.stringify({}) } + const serverResponse = { body: { bids: [] } } + const bids = spec.interpretResponse(serverResponse, request) + expect(typeof bids).to.equal('object') + 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 request = spec.buildRequests([validBidRequests[0]], bidderRequest) + const serverResponse = { + body: { + bids: [ + { + bidId: '2df8c0733f284e', + price: 0.5, + currency: 'USD', + content: 'html', + width: 100, + height: 100 + } + ] + } + } + const bids = spec.interpretResponse(serverResponse, request) + expect(bids.length).to.equal(1) + expect(bids[0].requestId).to.equal('2df8c0733f284e') + expect(bids[0].mediaType).to.equal(spec.supportedMediaTypes[0]) + 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') + }) + }) + describe('the bid is a video', function() { + it('should return a video bid', function() { + const request = spec.buildRequests([validBidRequests[1]], bidderRequest) + const serverResponse = { + body: { + bids: [ + { + bidId: '2df8c0733f284e', + price: 0.5, + currency: 'USD', + content: 'html', + width: 100, + height: 100 + } + ] + } + } + const bids = spec.interpretResponse(serverResponse, request) + expect(bids.length).to.equal(1) + expect(bids[0].requestId).to.equal('2df8c0733f284e') + expect(bids[0].mediaType).to.equal(spec.supportedMediaTypes[1]) + 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].vastXml).to.equal('string') + }) + }) + }) + }) +}) diff --git a/test/spec/modules/iasBidAdapter_spec.js b/test/spec/modules/iasBidAdapter_spec.js index 8197ee25856..1743ac947e6 100644 --- a/test/spec/modules/iasBidAdapter_spec.js +++ b/test/spec/modules/iasBidAdapter_spec.js @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import { spec } from 'modules/iasBidAdapter'; +import { spec } from 'modules/iasBidAdapter.js'; describe('iasBidAdapter is an adapter that', function () { it('has the correct bidder code', function () { @@ -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 206e227a3b1..45b3bed6e77 100644 --- a/test/spec/modules/imonomyBidAdapter_spec.js +++ b/test/spec/modules/imonomyBidAdapter_spec.js @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import { spec } from 'modules/imonomyBidAdapter'; +import { spec } from 'modules/imonomyBidAdapter.js'; describe('Imonomy Adapter Tests', function () { const bidsRequest = [ @@ -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 8ac8c8e85df..1466b509c54 100644 --- a/test/spec/modules/improvedigitalBidAdapter_spec.js +++ b/test/spec/modules/improvedigitalBidAdapter_spec.js @@ -1,10 +1,10 @@ import { expect } from 'chai'; -import { ImproveDigitalAdServerJSClient, spec } from 'modules/improvedigitalBidAdapter'; -import { config } from 'src/config'; -import { userSync } from 'src/userSync'; +import { ImproveDigitalAdServerJSClient, spec } from 'modules/improvedigitalBidAdapter.js'; +import { config } from 'src/config.js'; +import * as utils from 'src/utils.js'; describe('Improve Digital Adapter Tests', function () { - let idClient = new ImproveDigitalAdServerJSClient('hb'); + const idClient = new ImproveDigitalAdServerJSClient('hb'); const METHOD = 'GET'; const URL = 'https://ice.360yield.com/hb'; @@ -20,9 +20,41 @@ describe('Improve Digital Adapter Tests', function () { bidId: '33e9500b21129f', bidderRequestId: '2772c1e566670b', auctionId: '192721e36a0239', + mediaTypes: { + banner: { + sizes: [[300, 250], [160, 600], ['blah', 150], [-1, 300], [300, -5]] + } + }, sizes: [[300, 250], [160, 600], ['blah', 150], [-1, 300], [300, -5]] }; + const instreamBidRequest = utils.deepClone(simpleBidRequest); + instreamBidRequest.mediaTypes = { + video: { + context: 'instream', + playerSize: [640, 480] + } + }; + + const outstreamBidRequest = utils.deepClone(simpleBidRequest); + outstreamBidRequest.mediaTypes = { + video: { + context: 'outstream', + playerSize: [640, 480] + } + }; + + const multiFormatBidRequest = utils.deepClone(simpleBidRequest); + multiFormatBidRequest.mediaTypes = { + banner: { + sizes: [[300, 250], [160, 600], ['blah', 150], [-1, 300], [300, -5]] + }, + video: { + context: 'outstream', + playerSize: [640, 480] + } + }; + const simpleSmartTagBidRequest = { bidder: 'improvedigital', bidId: '1a2b3c', @@ -33,7 +65,24 @@ describe('Improve Digital Adapter Tests', function () { } }; + const bidderRequest = { + bids: [simpleBidRequest] + }; + + const instreamBidderRequest = { + bids: [instreamBidRequest] + }; + + const outstreamBidderRequest = { + bids: [outstreamBidRequest] + }; + + const multiFormatBidderRequest = { + bids: [multiFormatBidRequest] + }; + const bidderRequestGdpr = { + bids: [simpleBidRequest], gdprConsent: { consentString: 'BOJ/P2HOJ/P2HABABMAAAAAZ+A==', vendorData: {}, @@ -42,6 +91,7 @@ describe('Improve Digital Adapter Tests', function () { }; const bidderRequestReferrer = { + bids: [simpleBidRequest], refererInfo: { referer: 'https://blah.com/test.html', }, @@ -53,12 +103,12 @@ describe('Improve Digital Adapter Tests', function () { }); it('should return false when no bid.params', function () { - let bid = {}; + const bid = {}; expect(spec.isBidRequestValid(bid)).to.equal(false); }); it('should return false when both placementId and placementKey + publisherId are missing', function () { - let bid = { 'params': {} }; + const bid = { 'params': {} }; expect(spec.isBidRequestValid(bid)).to.equal(false); }); @@ -78,31 +128,59 @@ describe('Improve Digital Adapter Tests', function () { }); it('should return true when placementId is passed', function () { - let bid = { 'params': {} }; expect(spec.isBidRequestValid(simpleBidRequest)).to.equal(true); }); it('should return true when both placementKey and publisherId are passed', function () { - let bid = { 'params': {} }; expect(spec.isBidRequestValid(simpleSmartTagBidRequest)).to.equal(true); }); }); describe('buildRequests', function () { it('should make a well-formed request objects', function () { - const requests = spec.buildRequests([simpleBidRequest]); + const requests = spec.buildRequests([simpleBidRequest], bidderRequest); expect(requests).to.be.an('array'); expect(requests.length).to.equal(1); const request = requests[0]; expect(request.method).to.equal(METHOD); expect(request.url).to.equal(URL); + expect(request.bidderRequest).to.deep.equal(bidderRequest); expect(request.data.substring(0, PARAM_PREFIX.length)).to.equal(PARAM_PREFIX); const params = JSON.parse(decodeURIComponent(request.data.substring(PARAM_PREFIX.length))); expect(params.bid_request).to.be.an('object'); expect(params.bid_request.id).to.be.a('string'); expect(params.bid_request.version).to.equal(`${spec.version}-${idClient.CONSTANTS.CLIENT_VERSION}`); + expect(params.bid_request.gdpr).to.not.exist; + expect(params.bid_request.us_privacy).to.not.exist; + expect(params.bid_request.imp).to.deep.equal([ + { + id: '33e9500b21129f', + pid: 1053688, + tid: 'f183e871-fbed-45f0-a427-c8a63c4c01eb', + banner: {} + } + ]); + }); + + it('should make a well-formed request object for multi-format ad unit', function () { + const requests = spec.buildRequests([multiFormatBidRequest], multiFormatBidderRequest); + expect(requests).to.be.an('array'); + expect(requests.length).to.equal(1); + + const request = requests[0]; + expect(request.method).to.equal(METHOD); + expect(request.url).to.equal(URL); + expect(request.bidderRequest).to.deep.equal(multiFormatBidderRequest); + expect(request.data.substring(0, PARAM_PREFIX.length)).to.equal(PARAM_PREFIX); + + const params = JSON.parse(decodeURIComponent(request.data.substring(PARAM_PREFIX.length))); + expect(params.bid_request).to.be.an('object'); + expect(params.bid_request.id).to.be.a('string'); + expect(params.bid_request.version).to.equal(`${spec.version}-${idClient.CONSTANTS.CLIENT_VERSION}`); + expect(params.bid_request.gdpr).to.not.exist; + expect(params.bid_request.us_privacy).to.not.exist; expect(params.bid_request.imp).to.deep.equal([ { id: '33e9500b21129f', @@ -114,33 +192,33 @@ describe('Improve Digital Adapter Tests', function () { }); it('should set placementKey and publisherId for smart tags', function () { - const requests = spec.buildRequests([simpleSmartTagBidRequest]); + const requests = spec.buildRequests([simpleSmartTagBidRequest], bidderRequest); const params = JSON.parse(decodeURIComponent(requests[0].data.substring(PARAM_PREFIX.length))); expect(params.bid_request.imp[0].pubid).to.equal(1032); expect(params.bid_request.imp[0].pkey).to.equal('data_team_test_hb_smoke_test'); }); it('should add keyValues', function () { - let bidRequest = Object.assign({}, simpleBidRequest); + const bidRequest = Object.assign({}, simpleBidRequest); const keyValues = { testKey: [ 'testValue' ] }; bidRequest.params.keyValues = keyValues; - const request = spec.buildRequests([bidRequest])[0]; + const request = spec.buildRequests([bidRequest], bidderRequest)[0]; const params = JSON.parse(decodeURIComponent(request.data.substring(PARAM_PREFIX.length))); expect(params.bid_request.imp[0].kvw).to.deep.equal(keyValues); }); it('should add single size filter', function () { - let bidRequest = Object.assign({}, simpleBidRequest); + const bidRequest = Object.assign({}, simpleBidRequest); const size = { w: 800, h: 600 }; bidRequest.params.size = size; - const request = spec.buildRequests([bidRequest])[0]; + const request = spec.buildRequests([bidRequest], bidderRequest)[0]; const params = JSON.parse(decodeURIComponent(request.data.substring(PARAM_PREFIX.length))); expect(params.bid_request.imp[0].banner).to.deep.equal(size); // When single size filter is set, format shouldn't be populated. This @@ -151,7 +229,7 @@ describe('Improve Digital Adapter Tests', function () { it('should add currency', function () { const bidRequest = Object.assign({}, simpleBidRequest); const getConfigStub = sinon.stub(config, 'getConfig').returns('JPY'); - const request = spec.buildRequests([bidRequest])[0]; + const request = spec.buildRequests([bidRequest], bidderRequest)[0]; const params = JSON.parse(decodeURIComponent(request.data.substring(PARAM_PREFIX.length))); expect(params.bid_request.imp[0].currency).to.equal('JPY'); getConfigStub.restore(); @@ -159,14 +237,14 @@ describe('Improve Digital Adapter Tests', function () { it('should add bid floor', function () { const bidRequest = Object.assign({}, simpleBidRequest); - let request = spec.buildRequests([bidRequest])[0]; + let request = spec.buildRequests([bidRequest], bidderRequest)[0]; let params = JSON.parse(decodeURIComponent(request.data.substring(PARAM_PREFIX.length))); // Floor price currency shouldn't be populated without a floor price expect(params.bid_request.imp[0].bidfloorcur).to.not.exist; // Default floor price currency bidRequest.params.bidFloor = 0.05; - request = spec.buildRequests([bidRequest])[0]; + request = spec.buildRequests([bidRequest], bidderRequest)[0]; params = JSON.parse(decodeURIComponent(request.data.substring(PARAM_PREFIX.length))); expect(params.bid_request.imp[0].bidfloor).to.equal(0.05); expect(params.bid_request.imp[0].bidfloorcur).to.equal('USD'); @@ -186,6 +264,13 @@ describe('Improve Digital Adapter Tests', function () { expect(params.bid_request.gdpr).to.equal('BOJ/P2HOJ/P2HABABMAAAAAZ+A=='); }); + it('should add CCPA consent string', function () { + const bidRequest = Object.assign({}, simpleBidRequest); + const request = spec.buildRequests([bidRequest], { uspConsent: '1YYY' })[0]; + const params = JSON.parse(decodeURIComponent(request.data.substring(PARAM_PREFIX.length))); + expect(params.bid_request.us_privacy).to.equal('1YYY'); + }); + it('should add referrer', function () { const bidRequest = Object.assign({}, simpleBidRequest); const request = spec.buildRequests([bidRequest], bidderRequestReferrer)[0]; @@ -196,7 +281,7 @@ describe('Improve Digital Adapter Tests', function () { it('should add ad type for instream video', function () { let bidRequest = Object.assign({}, simpleBidRequest); bidRequest.mediaType = 'video'; - let request = spec.buildRequests([bidRequest])[0]; + let request = spec.buildRequests([bidRequest], bidderRequest)[0]; let params = JSON.parse(decodeURIComponent(request.data.substring(PARAM_PREFIX.length))); expect(params.bid_request.imp[0].ad_types).to.deep.equal(['video']); @@ -207,38 +292,48 @@ describe('Improve Digital Adapter Tests', function () { playerSize: [640, 480] } }; - request = spec.buildRequests([bidRequest])[0]; + request = spec.buildRequests([bidRequest], bidderRequest)[0]; params = JSON.parse(decodeURIComponent(request.data.substring(PARAM_PREFIX.length))); expect(params.bid_request.imp[0].ad_types).to.deep.equal(['video']); }); + it('should not set ad type for outstream video', function() { + const request = spec.buildRequests([outstreamBidRequest])[0]; + const params = JSON.parse(decodeURIComponent(request.data.substring(PARAM_PREFIX.length))); + expect(params.bid_request.imp[0].ad_types).to.not.exist; + }); + + it('should not set ad type for multi-format bids', function() { + const request = spec.buildRequests([multiFormatBidRequest], bidderRequest)[0]; + const params = JSON.parse(decodeURIComponent(request.data.substring(PARAM_PREFIX.length))); + expect(params.bid_request.imp[0].ad_types).to.not.exist; + }); + it('should not set Prebid sizes in bid request for instream video', function () { const getConfigStub = sinon.stub(config, 'getConfig'); getConfigStub.withArgs('improvedigital.usePrebidSizes').returns(true); - const bidRequest = Object.assign({}, simpleBidRequest); - bidRequest.mediaTypes = { - video: { - context: 'instream', - playerSize: [640, 480] - } - }; - const request = spec.buildRequests([bidRequest])[0]; + const request = spec.buildRequests([instreamBidRequest], bidderRequest)[0]; const params = JSON.parse(decodeURIComponent(request.data.substring(PARAM_PREFIX.length))); expect(params.bid_request.imp[0].banner.format).to.not.exist; getConfigStub.restore(); }); - it('should not set ad type for outstream video', function() { - const bidRequest = Object.assign({}, simpleBidRequest); - bidRequest.mediaTypes = { - video: { - context: 'outstream', - playerSize: [640, 480] - } - }; - const request = spec.buildRequests([bidRequest])[0]; + it('should not set Prebid sizes in bid request for outstream video', function () { + const getConfigStub = sinon.stub(config, 'getConfig'); + getConfigStub.withArgs('improvedigital.usePrebidSizes').returns(true); + const request = spec.buildRequests([outstreamBidRequest], bidderRequest)[0]; const params = JSON.parse(decodeURIComponent(request.data.substring(PARAM_PREFIX.length))); - expect(params.bid_request.imp[0].ad_types).to.not.exist; + expect(params.bid_request.imp[0].banner.format).to.not.exist; + getConfigStub.restore(); + }); + + it('should not set Prebid sizes in multi-format bid request', function () { + const getConfigStub = sinon.stub(config, 'getConfig'); + getConfigStub.withArgs('improvedigital.usePrebidSizes').returns(true); + const request = spec.buildRequests([multiFormatBidRequest], bidderRequest)[0]; + const params = JSON.parse(decodeURIComponent(request.data.substring(PARAM_PREFIX.length))); + expect(params.bid_request.imp[0].banner.format).to.not.exist; + getConfigStub.restore(); }); it('should add schain', function () { @@ -254,9 +349,11 @@ describe('Improve Digital Adapter Tests', function () { const requests = spec.buildRequests([ simpleBidRequest, simpleSmartTagBidRequest - ]); + ], bidderRequest); expect(requests).to.be.an('array'); expect(requests.length).to.equal(2); + expect(requests[0].bidderRequest).to.deep.equal(bidderRequest); + expect(requests[1].bidderRequest).to.deep.equal(bidderRequest); }); it('should return one request in a single request mode', function () { @@ -265,7 +362,7 @@ describe('Improve Digital Adapter Tests', function () { const requests = spec.buildRequests([ simpleBidRequest, simpleSmartTagBidRequest - ]); + ], bidderRequest); expect(requests).to.be.an('array'); expect(requests.length).to.equal(1); getConfigStub.restore(); @@ -274,7 +371,7 @@ describe('Improve Digital Adapter Tests', function () { it('should set Prebid sizes in bid request', function () { const getConfigStub = sinon.stub(config, 'getConfig'); getConfigStub.withArgs('improvedigital.usePrebidSizes').returns(true); - const request = spec.buildRequests([simpleBidRequest])[0]; + const request = spec.buildRequests([simpleBidRequest], bidderRequest)[0]; const params = JSON.parse(decodeURIComponent(request.data.substring(PARAM_PREFIX.length))); expect(params.bid_request.imp[0].banner).to.deep.equal({ format: [ @@ -294,7 +391,7 @@ describe('Improve Digital Adapter Tests', function () { h: 600 }; bidRequest.params.size = size; - const request = spec.buildRequests([bidRequest])[0]; + const request = spec.buildRequests([bidRequest], bidderRequest)[0]; const params = JSON.parse(decodeURIComponent(request.data.substring(PARAM_PREFIX.length))); expect(params.bid_request.imp[0].banner).to.deep.equal({ format: [ @@ -316,17 +413,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 +441,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 +467,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 +567,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 +576,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 +633,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 = [ + const expectedBid = [ { - 'ad': '', + 'ad': '', 'adId': '33e9500b21129f', 'creativeId': '422031', 'cpm': 1.45888594164456, @@ -562,10 +659,10 @@ describe('Improve Digital Adapter Tests', function () { } ]; - let expectedTwoBids = [ + const expectedTwoBids = [ expectedBid[0], { - 'ad': '', + 'ad': '', 'adId': '1234', 'creativeId': '422033', 'cpm': 1.23, @@ -579,7 +676,7 @@ describe('Improve Digital Adapter Tests', function () { } ]; - let expectedBidNative = [ + const expectedBidNative = [ { mediaType: 'native', adId: '33e9500b21129f', @@ -606,29 +703,29 @@ 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' } } ]; - let expectedBidVideo = [ + const expectedBidInstreamVideo = [ { 'vastXml': '', 'adId': '33e9500b21129f', @@ -644,60 +741,72 @@ describe('Improve Digital Adapter Tests', function () { } ]; - it('should return a well-formed bid', function () { - const bids = spec.interpretResponse(serverResponse); + const expectedBidOutstreamVideo = utils.deepClone(expectedBidInstreamVideo); + expectedBidOutstreamVideo[0].adResponse = { + content: expectedBidOutstreamVideo[0].vastXml, + height: expectedBidOutstreamVideo[0].height, + width: expectedBidOutstreamVideo[0].width + }; + + it('should return a well-formed display bid', function () { + const bids = spec.interpretResponse(serverResponse, {bidderRequest}); + expect(bids).to.deep.equal(expectedBid); + }); + + it('should return a well-formed display bid for multi-format ad unit', function () { + const bids = spec.interpretResponse(serverResponse, {bidderRequest: multiFormatBidderRequest}); expect(bids).to.deep.equal(expectedBid); }); it('should return two bids', function () { - const bids = spec.interpretResponse(serverResponseTwoBids); + const bids = spec.interpretResponse(serverResponseTwoBids, {bidderRequest}); expect(bids).to.deep.equal(expectedTwoBids); }); it('should set dealId correctly', function () { - let response = JSON.parse(JSON.stringify(serverResponse)); + const response = JSON.parse(JSON.stringify(serverResponse)); let bids; delete response.body.bid[0].lid; response.body.bid[0].buying_type = 'deal_id'; - bids = spec.interpretResponse(response); + bids = spec.interpretResponse(response, {bidderRequest}); expect(bids[0].dealId).to.not.exist; response.body.bid[0].lid = 268515; delete response.body.bid[0].buying_type; - bids = spec.interpretResponse(response); + bids = spec.interpretResponse(response, {bidderRequest}); expect(bids[0].dealId).to.not.exist; response.body.bid[0].lid = 268515; response.body.bid[0].buying_type = 'classic'; - bids = spec.interpretResponse(response); + bids = spec.interpretResponse(response, {bidderRequest}); expect(bids[0].dealId).to.not.exist; response.body.bid[0].lid = 268515; response.body.bid[0].buying_type = 'deal_id'; - bids = spec.interpretResponse(response); + bids = spec.interpretResponse(response, {bidderRequest}); expect(bids[0].dealId).to.equal(268515); response.body.bid[0].lid = [ 268515, 12456, 34567 ]; response.body.bid[0].buying_type = 'deal_id'; - bids = spec.interpretResponse(response); + bids = spec.interpretResponse(response, {bidderRequest}); expect(bids[0].dealId).to.not.exist; response.body.bid[0].lid = [ 268515, 12456, 34567 ]; response.body.bid[0].buying_type = [ 'deal_id', 'classic' ]; - bids = spec.interpretResponse(response); + bids = spec.interpretResponse(response, {bidderRequest}); expect(bids[0].dealId).to.not.exist; response.body.bid[0].lid = [ 268515, 12456, 34567 ]; response.body.bid[0].buying_type = [ 'classic', 'deal_id', 'deal_id' ]; - bids = spec.interpretResponse(response); + bids = spec.interpretResponse(response, {bidderRequest}); expect(bids[0].dealId).to.equal(12456); }); it('should set currency', function () { - let response = JSON.parse(JSON.stringify(serverResponse)); + const response = JSON.parse(JSON.stringify(serverResponse)); response.body.bid[0].currency = 'eur'; - const bids = spec.interpretResponse(response); + const bids = spec.interpretResponse(response, {bidderRequest}); expect(bids[0].currency).to.equal('EUR'); }); @@ -707,41 +816,41 @@ describe('Improve Digital Adapter Tests', function () { // Price missing or 0 response.body.bid[0].price = 0; - bids = spec.interpretResponse(response); + bids = spec.interpretResponse(response, {bidderRequest}); expect(bids).to.deep.equal([]); delete response.body.bid[0].price; - bids = spec.interpretResponse(response); + bids = spec.interpretResponse(response, {bidderRequest}); expect(bids).to.deep.equal([]); response.body.bid[0].price = null; - bids = spec.interpretResponse(response); + bids = spec.interpretResponse(response, {bidderRequest}); expect(bids).to.deep.equal([]); // errorCode present response = JSON.parse(JSON.stringify(serverResponse)); response.body.bid[0].errorCode = undefined; - bids = spec.interpretResponse(response); + bids = spec.interpretResponse(response, {bidderRequest}); expect(bids).to.deep.equal([]); // adm and native missing response = JSON.parse(JSON.stringify(serverResponse)); delete response.body.bid[0].adm; - bids = spec.interpretResponse(response); + bids = spec.interpretResponse(response, {bidderRequest}); expect(bids).to.deep.equal([]); response.body.bid[0].adm = null; - bids = spec.interpretResponse(response); + bids = spec.interpretResponse(response, {bidderRequest}); expect(bids).to.deep.equal([]); }); it('should set netRevenue', function () { - let response = JSON.parse(JSON.stringify(serverResponse)); + const response = JSON.parse(JSON.stringify(serverResponse)); response.body.bid[0].isNet = true; - const bids = spec.interpretResponse(response); + const bids = spec.interpretResponse(response, {bidderRequest}); expect(bids[0].netRevenue).to.equal(true); }); // Native ads it('should return a well-formed native ad bid', function () { - let bids = spec.interpretResponse(serverResponseNative); + let bids = spec.interpretResponse(serverResponseNative, {bidderRequest}); expect(bids[0].ortbNative).to.deep.equal(serverResponseNative.body.bid[0].native); delete bids[0].ortbNative; expect(bids).to.deep.equal(expectedBidNative); @@ -751,19 +860,33 @@ 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 = ''; - bids = spec.interpretResponse(response); + expectedBids[0].native.javascriptTrackers = ''; + bids = spec.interpretResponse(response, {bidderRequest}); delete bids[0].ortbNative; expect(bids).to.deep.equal(expectedBids); }); // Video - it('should return a well-formed video bid', function () { - const bids = spec.interpretResponse(serverResponseVideo); - expect(bids).to.deep.equal(expectedBidVideo); + it('should return a well-formed instream video bid', function () { + const bids = spec.interpretResponse(serverResponseVideo, {bidderRequest: instreamBidderRequest}); + expect(bids).to.deep.equal(expectedBidInstreamVideo); + }); + + it('should return a well-formed outstream video bid', function () { + const bids = spec.interpretResponse(serverResponseVideo, {bidderRequest: outstreamBidderRequest}); + expect(bids[0].renderer).to.exist; + delete (bids[0].renderer); + expect(bids).to.deep.equal(expectedBidOutstreamVideo); + }); + + it('should return a well-formed outstream video bid for multi-format ad unit', function () { + const bids = spec.interpretResponse(serverResponseVideo, {bidderRequest: multiFormatBidderRequest}); + expect(bids[0].renderer).to.exist; + delete (bids[0].renderer); + expect(bids).to.deep.equal(expectedBidOutstreamVideo); }); }); @@ -778,9 +901,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 index 0132f093ca1..80c00252632 100644 --- a/test/spec/modules/innityBidAdapter_spec.js +++ b/test/spec/modules/innityBidAdapter_spec.js @@ -1,9 +1,9 @@ import { expect } from 'chai'; -import { spec } from 'modules/innityBidAdapter'; +import { spec } from 'modules/innityBidAdapter.js'; -describe('innityAdapterTest', function () { - describe('bidRequestValidity', function () { - it('bidRequest with pub ID and zone ID param', function () { +describe('innityAdapterTest', () => { + describe('bidRequestValidity', () => { + it('bidRequest with pub ID and zone ID param', () => { expect(spec.isBidRequestValid({ bidder: 'innity', params: { @@ -13,7 +13,7 @@ describe('innityAdapterTest', function () { })).to.equal(true); }); - it('bidRequest with no required params', function () { + it('bidRequest with no required params', () => { expect(spec.isBidRequestValid({ bidder: 'innity', params: { @@ -22,14 +22,14 @@ describe('innityAdapterTest', function () { }); }); - describe('bidRequest', function () { + describe('bidRequest', () => { const bidRequests = [{ 'bidder': 'innity', 'params': { 'pub': 267, 'zone': 62546 }, - 'adUnitCode': 'div-gpt-ad-1460505748561-0', + 'adUnitCode': '/19968336/header-bid-tag-0', 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', 'sizes': [300, 250], 'bidId': '51ef8751f9aead', @@ -37,15 +37,21 @@ describe('innityAdapterTest', function () { 'auctionId': '18fd8b8b0bd757' }]; - it('bidRequest HTTP method', function () { - const requests = spec.buildRequests(bidRequests); + const bidderRequest = { + refererInfo: { + referer: 'https://example.com' + } + }; + + it('bidRequest HTTP method', () => { + const requests = spec.buildRequests(bidRequests, bidderRequest); requests.forEach(function(requestItem) { expect(requestItem.method).to.equal('GET'); }); }); - it('bidRequest data', function () { - const requests = spec.buildRequests(bidRequests); + it('bidRequest data', () => { + const requests = spec.buildRequests(bidRequests, bidderRequest); expect(requests[0].data.pub).to.equal(267); expect(requests[0].data.zone).to.equal(62546); expect(requests[0].data.width).to.equal('300'); @@ -54,7 +60,7 @@ describe('innityAdapterTest', function () { }); }); - describe('interpretResponse', function () { + describe('interpretResponse', () => { const bidRequest = { 'method': 'GET', 'url': 'https://as.innity.com/synd/?', @@ -85,7 +91,7 @@ describe('innityAdapterTest', function () { headers: {} }; - it('result is correct', function () { + it('result is correct', () => { const result = spec.interpretResponse(bidResponse, bidRequest); expect(result[0].requestId).to.equal('51ef8751f9aead'); expect(result[0].cpm).to.equal(1); @@ -94,7 +100,7 @@ describe('innityAdapterTest', function () { 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(''); + expect(result[0].ad).to.equal(''); }); }); }); diff --git a/test/spec/modules/inskinBidAdapter_spec.js b/test/spec/modules/inskinBidAdapter_spec.js index 896fe36d443..1be79a5a963 100644 --- a/test/spec/modules/inskinBidAdapter_spec.js +++ b/test/spec/modules/inskinBidAdapter_spec.js @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import { spec } from 'modules/inskinBidAdapter'; -import { createBid } from 'src/bidfactory'; +import { spec } from 'modules/inskinBidAdapter.js'; +import { createBid } from 'src/bidfactory.js'; const ENDPOINT = 'https://mfad.inskinad.com/api/v2'; @@ -101,6 +101,18 @@ const RESPONSE = { } }; +const consentString = 'BOJ8RZsOJ8RZsABAB8AAAAAZ+A=='; +const bidderRequest = { + bidderCode: 'inskin', + gdprConsent: { + consentString: consentString, + gdprApplies: true + }, + refererInfo: { + referer: 'https://www.inskinmedia.com' + } +}; + describe('InSkin BidAdapter', function () { let bidRequests; let adapter = spec; @@ -170,37 +182,29 @@ describe('InSkin BidAdapter', function () { describe('buildRequests validation', function () { it('creates request data', function () { - let request = spec.buildRequests(bidRequests); + let request = spec.buildRequests(bidRequests, bidderRequest); expect(request).to.exist.and.to.be.a('object'); }); it('request to inskin should contain a url', function () { - let request = spec.buildRequests(bidRequests); + let request = spec.buildRequests(bidRequests, bidderRequest); expect(request.url).to.have.string('inskinad.com'); }); it('requires valid bids to make request', function () { - let request = spec.buildRequests([]); + let request = spec.buildRequests([], bidderRequest); expect(request.bidRequest).to.be.empty; }); it('sends bid request to ENDPOINT via POST', function () { - let request = spec.buildRequests(bidRequests); + let request = spec.buildRequests(bidRequests, bidderRequest); 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); @@ -214,7 +218,7 @@ describe('InSkin BidAdapter', function () { }); describe('interpretResponse validation', function () { it('response should have valid bidderCode', function () { - let bidRequest = spec.buildRequests(REQUEST.bidRequest); + let bidRequest = spec.buildRequests(REQUEST.bidRequest, bidderRequest); let bid = createBid(1, bidRequest.bidRequest[0]); expect(bid.bidderCode).to.equal('inskin'); @@ -240,7 +244,6 @@ describe('InSkin BidAdapter', function () { 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'); }); }); diff --git a/test/spec/modules/interactiveOffersBidAdapter_spec.js b/test/spec/modules/interactiveOffersBidAdapter_spec.js deleted file mode 100644 index 8921a302738..00000000000 --- 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 57ca35e2b28..d21405a8b9d 100644 --- a/test/spec/modules/invibesBidAdapter_spec.js +++ b/test/spec/modules/invibesBidAdapter_spec.js @@ -1,11 +1,11 @@ import { expect } from 'chai'; -import { spec, resetInvibes, stubDomainOptions } from 'modules/invibesBidAdapter'; +import { spec, resetInvibes, stubDomainOptions } from 'modules/invibesBidAdapter.js'; 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/invisiblyAnalyticsAdapter_spec.js b/test/spec/modules/invisiblyAnalyticsAdapter_spec.js index 6ee989907b5..e13b16661b0 100644 --- a/test/spec/modules/invisiblyAnalyticsAdapter_spec.js +++ b/test/spec/modules/invisiblyAnalyticsAdapter_spec.js @@ -1,9 +1,9 @@ -import invisiblyAdapter from 'modules/invisiblyAnalyticsAdapter'; +import invisiblyAdapter from 'modules/invisiblyAnalyticsAdapter.js'; import { expect } from 'chai'; let events = require('src/events'); let constants = require('src/constants.json'); -describe('Invisibly Analytics Adapter test suite', function() { +describe('Invisibly Analytics Adapter test suite', function () { let xhr; let requests = []; const BID1 = { @@ -21,11 +21,11 @@ describe('Invisibly Analytics Adapter test suite', function() { hb_adid: '2ecff0db240757', hb_pb: 1.2, hb_size: '640x480', - hb_source: 'client' + hb_source: 'client', }, getStatusCode() { return CONSTANTS.STATUS.GOOD; - } + }, }; const BID2 = Object.assign({}, BID1, { @@ -35,7 +35,7 @@ describe('Invisibly Analytics Adapter test suite', function() { timeToRespond: 300, bidId: '3ecff0db240757', requestId: '3ecff0db240757', - adId: '3ecff0db240757' + adId: '3ecff0db240757', }); const BID3 = { @@ -49,11 +49,11 @@ describe('Invisibly Analytics Adapter test suite', function() { hb_adid: '3bd4ebb1c900e2', hb_pb: '1.500', hb_size: '728x90', - hb_source: 'server' + hb_source: 'server', }, getStatusCode() { return CONSTANTS.STATUS.NO_BID; - } + }, }; const MOCK = { @@ -61,11 +61,11 @@ describe('Invisibly Analytics Adapter test suite', function() { provider: 'invisiblyAnalytics', options: { bundleId: '', - account: 'invisibly' - } + account: 'invisibly', + }, }, AUCTION_INIT: { - auctionId: '25c6d7f5-699a-4bfc-87c9-996f915341fa' + auctionId: '25c6d7f5-699a-4bfc-87c9-996f915341fa', }, BID_REQUESTED: { bidder: 'mockBidder', @@ -75,27 +75,27 @@ describe('Invisibly Analytics Adapter test suite', function() { { bidder: 'mockBidder', adUnitCode: 'panorama_d_1', - bidId: '2ecff0db240757' + bidId: '2ecff0db240757', }, { bidder: 'mockBidder', adUnitCode: 'box_d_1', - bidId: '3ecff0db240757' + bidId: '3ecff0db240757', }, { bidder: 'mockBidder', adUnitCode: 'box_d_2', - bidId: '4ecff0db240757' - } + bidId: '4ecff0db240757', + }, ], - start: 1519149562216 + start: 1519149562216, }, BID_RESPONSE: [BID1, BID2], AUCTION_END: { auctionId: 'test_timeout_auction_id', timestamp: 1234567890, timeout: 3000, - auctionEnd: 1234567990 + auctionEnd: 1234567990, }, BID_WON: { bidderCode: 'appnexus', @@ -120,17 +120,17 @@ describe('Invisibly Analytics Adapter test suite', function() { status: 'rendered', eventType: 'bidWon', ad: 'some ad', - adUrl: 'ad url' + adUrl: 'ad url', }, BIDDER_DONE: { bidderCode: 'mockBidder', - bids: [BID1, BID2, BID3] + bids: [BID1, BID2, BID3], }, BID_TIMEOUT: [ { bidId: '2ecff0db240757', - auctionId: '25c6d7f5-699a-4bfc-87c9-996f915341fa' - } + auctionId: '25c6d7f5-699a-4bfc-87c9-996f915341fa', + }, ], BID_ADJUSTMENT: { ad: 'html', @@ -147,350 +147,437 @@ describe('Invisibly Analytics Adapter test suite', function() { statusMessage: 'Bid available', timeToRespond: 421, ttl: 300, - width: 300 + width: 300, }, NO_BID: { - testKey: false + testKey: false, }, SET_TARGETING: { [BID1.adUnitCode]: BID1.adserverTargeting, - [BID3.adUnitCode]: BID3.adserverTargeting + [BID3.adUnitCode]: BID3.adserverTargeting, }, REQUEST_BIDS: { - call: 'request' + call: 'request', }, ADD_AD_UNITS: { call: 'addAdUnits' }, AD_RENDER_FAILED: { call: 'adRenderFailed' }, INVALID_EVENT: { - mockKey: 'this event should not emit' - } + mockKey: 'this event should not emit', + }, }; - describe('Invisibly Analytic tests specs', function() { - beforeEach(function() { + describe('Invisibly Analytic tests specs', function () { + beforeEach(function () { xhr = sinon.useFakeXMLHttpRequest(); requests = []; - xhr.onCreate = request => requests.push(request); + xhr.onCreate = (xhr) => { + requests.push(xhr); + }; sinon.stub(events, 'getEvents').returns([]); sinon.spy(invisiblyAdapter, 'track'); }); - afterEach(function() { + afterEach(function () { invisiblyAdapter.disableAnalytics(); events.getEvents.restore(); invisiblyAdapter.track.restore(); xhr.restore(); }); - // specs to test invisibly account input to enableAnaylitcs - describe('monitor enableAnalytics method', function() { - it('should catch all events triggered with invisibly account config', function() { - invisiblyAdapter.enableAnalytics({ - provider: 'invisiblyAnalytics', - options: { - account: 'invisibly' - } + describe('Send all events as & when they are captured', function () { + beforeEach(function () { + invisiblyAdapter.weightedFilter.filter = true; + }); + // specs to test invisibly account input to enableAnaylitcs + describe('monitor enableAnalytics method', function () { + it('should catch all events triggered with invisibly account config', function () { + invisiblyAdapter.enableAnalytics({ + provider: 'invisiblyAnalytics', + options: { + account: 'invisibly', + }, + }); + events.emit(constants.EVENTS.AUCTION_INIT, MOCK.AUCTION_INIT); + events.emit(constants.EVENTS.AUCTION_END, MOCK.AUCTION_END); + events.emit(constants.EVENTS.BID_REQUESTED, MOCK.BID_REQUESTED); + events.emit(constants.EVENTS.BID_RESPONSE, MOCK.BID_RESPONSE); + events.emit(constants.EVENTS.BID_WON, MOCK.BID_WON); + sinon.assert.callCount(invisiblyAdapter.track, 5); + }); + + it('should not catch events triggered without invisibly account config', function () { + invisiblyAdapter.enableAnalytics({ + provider: 'invisiblyAnalytics', + options: {}, + }); + + events.emit(constants.EVENTS.AUCTION_INIT, MOCK.AUCTION_INIT); + events.emit(constants.EVENTS.AUCTION_END, MOCK.AUCTION_END); + events.emit(constants.EVENTS.BID_REQUESTED, MOCK.BID_REQUESTED); + events.emit(constants.EVENTS.BID_RESPONSE, MOCK.BID_RESPONSE); + events.emit(constants.EVENTS.BID_WON, MOCK.BID_WON); + invisiblyAdapter.flush(); + sinon.assert.callCount(invisiblyAdapter.track, 0); + }); + // spec to test custom api endpoint + it('support custom endpoint', function () { + let custom_url = 'custom url'; + invisiblyAdapter.enableAnalytics({ + provider: 'invisiblyAnalytics', + options: { + url: custom_url, + bundleId: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', + account: 'invisibly', + }, + }); + expect(invisiblyAdapter.getOptions().url).to.equal(custom_url); }); + }); + // spec for auction init event + it('auction init event', function () { + invisiblyAdapter.enableAnalytics(MOCK.config); events.emit(constants.EVENTS.AUCTION_INIT, MOCK.AUCTION_INIT); - events.emit(constants.EVENTS.AUCTION_END, MOCK.AUCTION_END); - events.emit(constants.EVENTS.BID_REQUESTED, MOCK.BID_REQUESTED); - events.emit(constants.EVENTS.BID_RESPONSE, MOCK.BID_RESPONSE); - events.emit(constants.EVENTS.BID_WON, MOCK.BID_WON); - sinon.assert.callCount(invisiblyAdapter.track, 5); + invisiblyAdapter.flush(); + + const invisiblyEvents = JSON.parse( + requests[1].requestBody.substring(0) + ); + // pageView is default event initially hence expecting 2 requests + expect(requests.length).to.equal(2); + expect(requests[1].url).to.equal( + 'https://api.pymx5.com/v1/sites/events' + ); + expect(invisiblyEvents.event_data.auctionId).to.equal( + MOCK.AUCTION_INIT.auctionId + ); + expect(invisiblyEvents.event_data.pageViewId).to.exist; + expect(invisiblyEvents.event_type).to.equal('PREBID_auctionInit'); + expect(invisiblyEvents.event_data.ver).to.equal(1); }); - it('should not catch events triggered without invisibly account config', function() { - invisiblyAdapter.enableAnalytics({ - provider: 'invisiblyAnalytics', - options: {} - }); + // spec for bid adjustment event + it('bid adjustment event', function () { + invisiblyAdapter.enableAnalytics(MOCK.config); + events.emit(constants.EVENTS.BID_ADJUSTMENT, MOCK.BID_ADJUSTMENT); + invisiblyAdapter.flush(); - events.emit(constants.EVENTS.AUCTION_INIT, MOCK.AUCTION_INIT); - events.emit(constants.EVENTS.AUCTION_END, MOCK.AUCTION_END); + const invisiblyEvents = JSON.parse( + requests[0].requestBody.substring(0) + ); + expect(requests.length).to.equal(1); + expect(requests[0].url).to.equal( + 'https://api.pymx5.com/v1/sites/events' + ); + expect(invisiblyEvents.event_data.pageViewId).to.exist; + expect(invisiblyEvents.event_data.ver).to.equal(1); + expect(invisiblyEvents.event_type).to.equal('PREBID_bidAdjustment'); + expect(invisiblyEvents.event_data.bidders.cpm).to.equal( + MOCK.BID_ADJUSTMENT.cpm + ); + sinon.assert.callCount(invisiblyAdapter.track, 1); + }); + + // spec for bid timeout event + it('bid timeout event', function () { + invisiblyAdapter.enableAnalytics(MOCK.config); + events.emit(constants.EVENTS.BID_TIMEOUT, MOCK.BID_TIMEOUT); + invisiblyAdapter.flush(); + + const invisiblyEvents = JSON.parse( + requests[0].requestBody.substring(0) + ); + expect(requests.length).to.equal(1); + expect(requests[0].url).to.equal( + 'https://api.pymx5.com/v1/sites/events' + ); + expect(invisiblyEvents.event_data.pageViewId).to.exist; + expect(invisiblyEvents.event_data.ver).to.equal(1); + expect(invisiblyEvents.event_type).to.equal('PREBID_bidTimeout'); + expect(invisiblyEvents.event_data.bidders.bidId).to.equal( + MOCK.BID_TIMEOUT.bidId + ); + sinon.assert.callCount(invisiblyAdapter.track, 1); + }); + + // spec for bid requested event + it('bid requested event', function () { + invisiblyAdapter.enableAnalytics(MOCK.config); events.emit(constants.EVENTS.BID_REQUESTED, MOCK.BID_REQUESTED); + invisiblyAdapter.flush(); + + const invisiblyEvents = JSON.parse( + requests[0].requestBody.substring(0) + ); + expect(requests.length).to.equal(1); + expect(requests[0].url).to.equal( + 'https://api.pymx5.com/v1/sites/events' + ); + expect(invisiblyEvents.event_data.pageViewId).to.exist; + expect(invisiblyEvents.event_data.ver).to.equal(1); + expect(invisiblyEvents.event_type).to.equal('PREBID_bidRequested'); + expect(invisiblyEvents.event_data.auctionId).to.equal( + MOCK.BID_REQUESTED.auctionId + ); + sinon.assert.callCount(invisiblyAdapter.track, 1); + }); + + // spec for bid response event + it('bid response event', function () { + invisiblyAdapter.enableAnalytics(MOCK.config); events.emit(constants.EVENTS.BID_RESPONSE, MOCK.BID_RESPONSE); + invisiblyAdapter.flush(); + + const invisiblyEvents = JSON.parse( + requests[0].requestBody.substring(0) + ); + expect(requests.length).to.equal(1); + expect(requests[0].url).to.equal( + 'https://api.pymx5.com/v1/sites/events' + ); + expect(invisiblyEvents.event_data.pageViewId).to.exist; + expect(invisiblyEvents.event_data.ver).to.equal(1); + expect(invisiblyEvents.event_type).to.equal('PREBID_bidResponse'); + expect(invisiblyEvents.event_data.cpm).to.equal(MOCK.BID_REQUESTED.cpm); + sinon.assert.callCount(invisiblyAdapter.track, 1); + }); + + // spec for no bid event + it('no bid event', function () { + invisiblyAdapter.enableAnalytics(MOCK.config); + events.emit(constants.EVENTS.NO_BID, MOCK.NO_BID); + invisiblyAdapter.flush(); + + const invisiblyEvents = JSON.parse( + requests[0].requestBody.substring(0) + ); + expect(requests.length).to.equal(1); + expect(requests[0].url).to.equal( + 'https://api.pymx5.com/v1/sites/events' + ); + expect(invisiblyEvents.event_data.pageViewId).to.exist; + expect(invisiblyEvents.event_data.ver).to.equal(1); + expect(invisiblyEvents.event_type).to.equal('PREBID_noBid'); + expect(invisiblyEvents.event_data.noBid.testKey).to.equal( + MOCK.NO_BID.testKey + ); + sinon.assert.callCount(invisiblyAdapter.track, 1); + }); + + // spec for bid won event + it('bid won event', function () { + invisiblyAdapter.enableAnalytics(MOCK.config); events.emit(constants.EVENTS.BID_WON, MOCK.BID_WON); invisiblyAdapter.flush(); - sinon.assert.callCount(invisiblyAdapter.track, 0); + + const invisiblyEvents = JSON.parse( + requests[0].requestBody.substring(0) + ); + expect(requests.length).to.equal(1); + expect(requests[0].url).to.equal( + 'https://api.pymx5.com/v1/sites/events' + ); + expect(invisiblyEvents.event_data.pageViewId).to.exist; + expect(invisiblyEvents.event_data.ver).to.equal(1); + expect(invisiblyEvents.event_type).to.equal('PREBID_bidWon'); + sinon.assert.callCount(invisiblyAdapter.track, 1); }); - // spec to test custom api endpoint - it('support custom endpoint', function() { - let custom_url = 'custom url'; - invisiblyAdapter.enableAnalytics({ - provider: 'invisiblyAnalytics', - options: { - url: custom_url, - bundleId: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', - account: 'invisibly' - } - }); - expect(invisiblyAdapter.getOptions().url).to.equal(custom_url); + + // spec for bidder done event + it('bidder done event', function () { + invisiblyAdapter.enableAnalytics(MOCK.config); + events.emit(constants.EVENTS.BIDDER_DONE, MOCK.BIDDER_DONE); + invisiblyAdapter.flush(); + + const invisiblyEvents = JSON.parse( + requests[0].requestBody.substring(0) + ); + expect(requests.length).to.equal(1); + expect(requests[0].url).to.equal( + 'https://api.pymx5.com/v1/sites/events' + ); + expect(invisiblyEvents.event_data.pageViewId).to.exist; + expect(invisiblyEvents.event_data.ver).to.equal(1); + expect(invisiblyEvents.event_type).to.equal('PREBID_bidderDone'); + expect(invisiblyEvents.event_data.bidderCode).to.equal( + MOCK.BIDDER_DONE.bidderCode + ); + expect(invisiblyEvents.event_data.bids.length).to.equal( + MOCK.BIDDER_DONE.bids.length + ); + sinon.assert.callCount(invisiblyAdapter.track, 1); }); - }); - // spec for auction init event - it('auction init event', function() { - invisiblyAdapter.enableAnalytics(MOCK.config); - events.emit(constants.EVENTS.AUCTION_INIT, MOCK.AUCTION_INIT); - invisiblyAdapter.flush(); - - const invisiblyEvents = JSON.parse(requests[1].requestBody.substring(0)); - // pageView is default event initially hence expecting 2 requests - expect(requests.length).to.equal(2); - expect(requests[1].url).to.equal('https://api.pymx5.com/v1/sites/events'); - expect(invisiblyEvents.event_data.auctionId).to.equal( - MOCK.AUCTION_INIT.auctionId - ); - expect(invisiblyEvents.event_data.pageViewId).to.exist; - expect(invisiblyEvents.event_type).to.equal('PREBID_auctionInit'); - expect(invisiblyEvents.event_data.ver).to.equal(1); - }); + // spec for set targeting event + it('set targeting event', function () { + invisiblyAdapter.enableAnalytics(MOCK.config); + events.emit(constants.EVENTS.SET_TARGETING, MOCK.SET_TARGETING); + invisiblyAdapter.flush(); - // spec for bid adjustment event - it('bid adjustment event', function() { - invisiblyAdapter.enableAnalytics(MOCK.config); - events.emit(constants.EVENTS.BID_ADJUSTMENT, MOCK.BID_ADJUSTMENT); - invisiblyAdapter.flush(); - - const invisiblyEvents = JSON.parse(requests[0].requestBody.substring(0)); - expect(requests.length).to.equal(1); - expect(requests[0].url).to.equal('https://api.pymx5.com/v1/sites/events'); - expect(invisiblyEvents.event_data.pageViewId).to.exist; - expect(invisiblyEvents.event_data.ver).to.equal(1); - expect(invisiblyEvents.event_type).to.equal('PREBID_bidAdjustment'); - expect(invisiblyEvents.event_data.bidders.cpm).to.equal( - MOCK.BID_ADJUSTMENT.cpm - ); - sinon.assert.callCount(invisiblyAdapter.track, 1); - }); + const invisiblyEvents = JSON.parse( + requests[0].requestBody.substring(0) + ); + expect(requests.length).to.equal(1); + expect(requests[0].url).to.equal( + 'https://api.pymx5.com/v1/sites/events' + ); + expect(invisiblyEvents.event_data.pageViewId).to.exist; + expect(invisiblyEvents.event_data.ver).to.equal(1); + expect(invisiblyEvents.event_type).to.equal('PREBID_setTargeting'); + expect( + invisiblyEvents.event_data.targetings[BID1.adUnitCode] + ).to.deep.equal(BID1.adserverTargeting); + expect( + invisiblyEvents.event_data.targetings[BID3.adUnitCode] + ).to.deep.equal(BID3.adserverTargeting); + sinon.assert.callCount(invisiblyAdapter.track, 1); + }); - // spec for bid timeout event - it('bid timeout event', function() { - invisiblyAdapter.enableAnalytics(MOCK.config); - events.emit(constants.EVENTS.BID_TIMEOUT, MOCK.BID_TIMEOUT); - invisiblyAdapter.flush(); - - const invisiblyEvents = JSON.parse(requests[0].requestBody.substring(0)); - expect(requests.length).to.equal(1); - expect(requests[0].url).to.equal('https://api.pymx5.com/v1/sites/events'); - expect(invisiblyEvents.event_data.pageViewId).to.exist; - expect(invisiblyEvents.event_data.ver).to.equal(1); - expect(invisiblyEvents.event_type).to.equal('PREBID_bidTimeout'); - expect(invisiblyEvents.event_data.bidders.bidId).to.equal( - MOCK.BID_TIMEOUT.bidId - ); - sinon.assert.callCount(invisiblyAdapter.track, 1); - }); + // spec for request bids event + it('request bids event', function () { + invisiblyAdapter.enableAnalytics(MOCK.config); + events.emit(constants.EVENTS.REQUEST_BIDS, MOCK.REQUEST_BIDS); + invisiblyAdapter.flush(); - // spec for bid requested event - it('bid requested event', function() { - invisiblyAdapter.enableAnalytics(MOCK.config); - events.emit(constants.EVENTS.BID_REQUESTED, MOCK.BID_REQUESTED); - invisiblyAdapter.flush(); - - const invisiblyEvents = JSON.parse(requests[0].requestBody.substring(0)); - expect(requests.length).to.equal(1); - expect(requests[0].url).to.equal('https://api.pymx5.com/v1/sites/events'); - expect(invisiblyEvents.event_data.pageViewId).to.exist; - expect(invisiblyEvents.event_data.ver).to.equal(1); - expect(invisiblyEvents.event_type).to.equal('PREBID_bidRequested'); - expect(invisiblyEvents.event_data.auctionId).to.equal( - MOCK.BID_REQUESTED.auctionId - ); - sinon.assert.callCount(invisiblyAdapter.track, 1); - }); + const invisiblyEvents = JSON.parse( + requests[0].requestBody.substring(0) + ); + expect(requests.length).to.equal(1); + expect(requests[0].url).to.equal( + 'https://api.pymx5.com/v1/sites/events' + ); + expect(invisiblyEvents.event_data.pageViewId).to.exist; + expect(invisiblyEvents.event_data.ver).to.equal(1); + expect(invisiblyEvents.event_type).to.equal('PREBID_requestBids'); + expect(invisiblyEvents.event_data.call).to.equal( + MOCK.REQUEST_BIDS.call + ); + sinon.assert.callCount(invisiblyAdapter.track, 1); + }); - // spec for bid response event - it('bid response event', function() { - invisiblyAdapter.enableAnalytics(MOCK.config); - events.emit(constants.EVENTS.BID_RESPONSE, MOCK.BID_RESPONSE); - invisiblyAdapter.flush(); - - const invisiblyEvents = JSON.parse(requests[0].requestBody.substring(0)); - expect(requests.length).to.equal(1); - expect(requests[0].url).to.equal('https://api.pymx5.com/v1/sites/events'); - expect(invisiblyEvents.event_data.pageViewId).to.exist; - expect(invisiblyEvents.event_data.ver).to.equal(1); - expect(invisiblyEvents.event_type).to.equal('PREBID_bidResponse'); - expect(invisiblyEvents.event_data.cpm).to.equal(MOCK.BID_REQUESTED.cpm); - sinon.assert.callCount(invisiblyAdapter.track, 1); - }); + // spec for add ad units event + it('add ad units event', function () { + invisiblyAdapter.enableAnalytics(MOCK.config); + events.emit(constants.EVENTS.ADD_AD_UNITS, MOCK.ADD_AD_UNITS); + invisiblyAdapter.flush(); - // spec for no bid event - it('no bid event', function() { - invisiblyAdapter.enableAnalytics(MOCK.config); - events.emit(constants.EVENTS.NO_BID, MOCK.NO_BID); - invisiblyAdapter.flush(); - - const invisiblyEvents = JSON.parse(requests[0].requestBody.substring(0)); - expect(requests.length).to.equal(1); - expect(requests[0].url).to.equal('https://api.pymx5.com/v1/sites/events'); - expect(invisiblyEvents.event_data.pageViewId).to.exist; - expect(invisiblyEvents.event_data.ver).to.equal(1); - expect(invisiblyEvents.event_type).to.equal('PREBID_noBid'); - expect(invisiblyEvents.event_data.noBid.testKey).to.equal( - MOCK.NO_BID.testKey - ); - sinon.assert.callCount(invisiblyAdapter.track, 1); - }); + const invisiblyEvents = JSON.parse( + requests[0].requestBody.substring(0) + ); + expect(requests.length).to.equal(1); + expect(requests[0].url).to.equal( + 'https://api.pymx5.com/v1/sites/events' + ); + expect(invisiblyEvents.event_data.pageViewId).to.exist; + expect(invisiblyEvents.event_data.ver).to.equal(1); + expect(invisiblyEvents.event_type).to.equal('PREBID_addAdUnits'); + expect(invisiblyEvents.event_data.call).to.equal( + MOCK.ADD_AD_UNITS.call + ); + sinon.assert.callCount(invisiblyAdapter.track, 1); + }); - // spec for bid won event - it('bid won event', function() { - invisiblyAdapter.enableAnalytics(MOCK.config); - events.emit(constants.EVENTS.BID_WON, MOCK.BID_WON); - invisiblyAdapter.flush(); - - const invisiblyEvents = JSON.parse(requests[0].requestBody.substring(0)); - expect(requests.length).to.equal(1); - expect(requests[0].url).to.equal('https://api.pymx5.com/v1/sites/events'); - expect(invisiblyEvents.event_data.pageViewId).to.exist; - expect(invisiblyEvents.event_data.ver).to.equal(1); - expect(invisiblyEvents.event_type).to.equal('PREBID_bidWon'); - sinon.assert.callCount(invisiblyAdapter.track, 1); - }); + // spec for ad render failed event + it('ad render failed event', function () { + invisiblyAdapter.enableAnalytics(MOCK.config); + events.emit(constants.EVENTS.AD_RENDER_FAILED, MOCK.AD_RENDER_FAILED); + invisiblyAdapter.flush(); - // spec for bidder done event - it('bidder done event', function() { - invisiblyAdapter.enableAnalytics(MOCK.config); - events.emit(constants.EVENTS.BIDDER_DONE, MOCK.BIDDER_DONE); - invisiblyAdapter.flush(); - - const invisiblyEvents = JSON.parse(requests[0].requestBody.substring(0)); - expect(requests.length).to.equal(1); - expect(requests[0].url).to.equal('https://api.pymx5.com/v1/sites/events'); - expect(invisiblyEvents.event_data.pageViewId).to.exist; - expect(invisiblyEvents.event_data.ver).to.equal(1); - expect(invisiblyEvents.event_type).to.equal('PREBID_bidderDone'); - expect(invisiblyEvents.event_data.bidderCode).to.equal( - MOCK.BIDDER_DONE.bidderCode - ); - expect(invisiblyEvents.event_data.bids.length).to.equal( - MOCK.BIDDER_DONE.bids.length - ); - sinon.assert.callCount(invisiblyAdapter.track, 1); - }); + const invisiblyEvents = JSON.parse( + requests[0].requestBody.substring(0) + ); + expect(requests.length).to.equal(1); + expect(requests[0].url).to.equal( + 'https://api.pymx5.com/v1/sites/events' + ); + expect(invisiblyEvents.event_data.pageViewId).to.exist; + expect(invisiblyEvents.event_data.ver).to.equal(1); + expect(invisiblyEvents.event_type).to.equal('PREBID_adRenderFailed'); + expect(invisiblyEvents.event_data.call).to.equal( + MOCK.AD_RENDER_FAILED.call + ); + sinon.assert.callCount(invisiblyAdapter.track, 1); + }); - // spec for set targeting event - it('set targeting event', function() { - invisiblyAdapter.enableAnalytics(MOCK.config); - events.emit(constants.EVENTS.SET_TARGETING, MOCK.SET_TARGETING); - invisiblyAdapter.flush(); - - const invisiblyEvents = JSON.parse(requests[0].requestBody.substring(0)); - expect(requests.length).to.equal(1); - expect(requests[0].url).to.equal('https://api.pymx5.com/v1/sites/events'); - expect(invisiblyEvents.event_data.pageViewId).to.exist; - expect(invisiblyEvents.event_data.ver).to.equal(1); - expect(invisiblyEvents.event_type).to.equal('PREBID_setTargeting'); - expect( - invisiblyEvents.event_data.targetings[BID1.adUnitCode] - ).to.deep.equal(BID1.adserverTargeting); - expect( - invisiblyEvents.event_data.targetings[BID3.adUnitCode] - ).to.deep.equal(BID3.adserverTargeting); - sinon.assert.callCount(invisiblyAdapter.track, 1); - }); + // spec for auction end event + it('auction end event', function () { + invisiblyAdapter.enableAnalytics(MOCK.config); + events.emit(constants.EVENTS.AUCTION_END, MOCK.AUCTION_END); + invisiblyAdapter.flush(); - // spec for request bids event - it('request bids event', function() { - invisiblyAdapter.enableAnalytics(MOCK.config); - events.emit(constants.EVENTS.REQUEST_BIDS, MOCK.REQUEST_BIDS); - invisiblyAdapter.flush(); - - const invisiblyEvents = JSON.parse(requests[0].requestBody.substring(0)); - expect(requests.length).to.equal(1); - expect(requests[0].url).to.equal('https://api.pymx5.com/v1/sites/events'); - expect(invisiblyEvents.event_data.pageViewId).to.exist; - expect(invisiblyEvents.event_data.ver).to.equal(1); - expect(invisiblyEvents.event_type).to.equal('PREBID_requestBids'); - expect(invisiblyEvents.event_data.call).to.equal(MOCK.REQUEST_BIDS.call); - sinon.assert.callCount(invisiblyAdapter.track, 1); - }); + const invisiblyEvents = JSON.parse( + requests[0].requestBody.substring(0) + ); + expect(requests.length).to.equal(1); + expect(requests[0].url).to.equal( + 'https://api.pymx5.com/v1/sites/events' + ); + expect(invisiblyEvents.event_data.pageViewId).to.exist; + expect(invisiblyEvents.event_data.ver).to.equal(1); + expect(invisiblyEvents.event_type).to.equal('PREBID_auctionEnd'); + expect(invisiblyEvents.event_data.auctionId).to.equal( + MOCK.AUCTION_END.auctionId + ); + sinon.assert.callCount(invisiblyAdapter.track, 1); + }); - // spec for add ad units event - it('add ad units event', function() { - invisiblyAdapter.enableAnalytics(MOCK.config); - events.emit(constants.EVENTS.ADD_AD_UNITS, MOCK.ADD_AD_UNITS); - invisiblyAdapter.flush(); - - const invisiblyEvents = JSON.parse(requests[0].requestBody.substring(0)); - expect(requests.length).to.equal(1); - expect(requests[0].url).to.equal('https://api.pymx5.com/v1/sites/events'); - expect(invisiblyEvents.event_data.pageViewId).to.exist; - expect(invisiblyEvents.event_data.ver).to.equal(1); - expect(invisiblyEvents.event_type).to.equal('PREBID_addAdUnits'); - expect(invisiblyEvents.event_data.call).to.equal(MOCK.ADD_AD_UNITS.call); - sinon.assert.callCount(invisiblyAdapter.track, 1); - }); + // should not call sendEvent for events not supported by the adapter + it('it should not call sendEvent for this event emit', function () { + sinon.spy(invisiblyAdapter, 'sendEvent'); + invisiblyAdapter.enableAnalytics(MOCK.config); + events.emit(constants.EVENTS.INVALID_EVENT, MOCK.INVALID_EVENT); + invisiblyAdapter.flush(); - // spec for ad render failed event - it('ad render failed event', function() { - invisiblyAdapter.enableAnalytics(MOCK.config); - events.emit(constants.EVENTS.AD_RENDER_FAILED, MOCK.AD_RENDER_FAILED); - invisiblyAdapter.flush(); - - const invisiblyEvents = JSON.parse(requests[0].requestBody.substring(0)); - expect(requests.length).to.equal(1); - expect(requests[0].url).to.equal('https://api.pymx5.com/v1/sites/events'); - expect(invisiblyEvents.event_data.pageViewId).to.exist; - expect(invisiblyEvents.event_data.ver).to.equal(1); - expect(invisiblyEvents.event_type).to.equal('PREBID_adRenderFailed'); - expect(invisiblyEvents.event_data.call).to.equal( - MOCK.AD_RENDER_FAILED.call - ); - sinon.assert.callCount(invisiblyAdapter.track, 1); - }); + expect(requests.length).to.equal(0); + sinon.assert.callCount(invisiblyAdapter.track, 0); + sinon.assert.callCount(invisiblyAdapter.sendEvent, 0); + }); - // spec for auction end event - it('auction end event', function() { - invisiblyAdapter.enableAnalytics(MOCK.config); - events.emit(constants.EVENTS.AUCTION_END, MOCK.AUCTION_END); - invisiblyAdapter.flush(); - - const invisiblyEvents = JSON.parse(requests[0].requestBody.substring(0)); - expect(requests.length).to.equal(1); - expect(requests[0].url).to.equal('https://api.pymx5.com/v1/sites/events'); - expect(invisiblyEvents.event_data.pageViewId).to.exist; - expect(invisiblyEvents.event_data.ver).to.equal(1); - expect(invisiblyEvents.event_type).to.equal('PREBID_auctionEnd'); - expect(invisiblyEvents.event_data.auctionId).to.equal( - MOCK.AUCTION_END.auctionId - ); - sinon.assert.callCount(invisiblyAdapter.track, 1); - }); + // spec to emit all events + it('track all event without errors', function () { + invisiblyAdapter.enableAnalytics(MOCK.config); - // should not call sendEvent for events not supported by the adapter - it('it should not call sendEvent for this event emit', function() { - sinon.spy(invisiblyAdapter, 'sendEvent'); - invisiblyAdapter.enableAnalytics(MOCK.config); - events.emit(constants.EVENTS.INVALID_EVENT, MOCK.INVALID_EVENT); - invisiblyAdapter.flush(); + events.emit(constants.EVENTS.AUCTION_INIT, MOCK.AUCTION_INIT); + events.emit(constants.EVENTS.AUCTION_END, MOCK.AUCTION_END); + events.emit(constants.EVENTS.BID_ADJUSTMENT, MOCK.BID_ADJUSTMENT); + events.emit(constants.EVENTS.BID_TIMEOUT, MOCK.BID_TIMEOUT); + events.emit(constants.EVENTS.BID_REQUESTED, MOCK.BID_REQUESTED); + events.emit(constants.EVENTS.BID_RESPONSE, MOCK.BID_RESPONSE); + events.emit(constants.EVENTS.NO_BID, MOCK.NO_BID); + events.emit(constants.EVENTS.BID_WON, MOCK.BID_WON); + events.emit(constants.EVENTS.BIDDER_DONE, MOCK.BIDDER_DONE); + events.emit(constants.EVENTS.SET_TARGETING, MOCK.SET_TARGETING); + events.emit(constants.EVENTS.REQUEST_BIDS, MOCK.REQUEST_BIDS); + events.emit(constants.EVENTS.ADD_AD_UNITS, MOCK.ADD_AD_UNITS); + events.emit(constants.EVENTS.AD_RENDER_FAILED, MOCK.AD_RENDER_FAILED); - expect(requests.length).to.equal(0); - sinon.assert.callCount(invisiblyAdapter.track, 0); - sinon.assert.callCount(invisiblyAdapter.sendEvent, 0); + sinon.assert.callCount(invisiblyAdapter.track, 13); + }); }); - // spec to emit all events - it('track all event without errors', function() { - invisiblyAdapter.enableAnalytics(MOCK.config); - - events.emit(constants.EVENTS.AUCTION_INIT, MOCK.AUCTION_INIT); - events.emit(constants.EVENTS.AUCTION_END, MOCK.AUCTION_END); - events.emit(constants.EVENTS.BID_ADJUSTMENT, MOCK.BID_ADJUSTMENT); - events.emit(constants.EVENTS.BID_TIMEOUT, MOCK.BID_TIMEOUT); - events.emit(constants.EVENTS.BID_REQUESTED, MOCK.BID_REQUESTED); - events.emit(constants.EVENTS.BID_RESPONSE, MOCK.BID_RESPONSE); - events.emit(constants.EVENTS.NO_BID, MOCK.NO_BID); - events.emit(constants.EVENTS.BID_WON, MOCK.BID_WON); - events.emit(constants.EVENTS.BIDDER_DONE, MOCK.BIDDER_DONE); - events.emit(constants.EVENTS.SET_TARGETING, MOCK.SET_TARGETING); - events.emit(constants.EVENTS.REQUEST_BIDS, MOCK.REQUEST_BIDS); - events.emit(constants.EVENTS.ADD_AD_UNITS, MOCK.ADD_AD_UNITS); - events.emit(constants.EVENTS.AD_RENDER_FAILED, MOCK.AD_RENDER_FAILED); - - sinon.assert.callCount(invisiblyAdapter.track, 13); + describe('Should not send any event even if they are caputured', function () { + beforeEach(function () { + invisiblyAdapter.weightedFilter.filter = false; + }); + it('it should not send any event', function () { + invisiblyAdapter.enableAnalytics({ + provider: 'invisiblyAnalytics', + options: { + account: 'invisibly', + }, + }); + + events.emit(constants.EVENTS.AUCTION_INIT, MOCK.AUCTION_INIT); + events.emit(constants.EVENTS.AUCTION_END, MOCK.AUCTION_END); + events.emit(constants.EVENTS.BID_REQUESTED, MOCK.BID_REQUESTED); + events.emit(constants.EVENTS.BID_RESPONSE, MOCK.BID_RESPONSE); + events.emit(constants.EVENTS.BID_WON, MOCK.BID_WON); + invisiblyAdapter.flush(); + + sinon.assert.callCount(invisiblyAdapter.sendEvent, 0); + sinon.assert.callCount(invisiblyAdapter.track, 0); + expect(requests.length).to.equal(0); + }); }); }); }); diff --git a/test/spec/modules/iqmBidAdapter_spec.js b/test/spec/modules/iqmBidAdapter_spec.js deleted file mode 100644 index 5535c52af9b..00000000000 --- 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 53b6ee1166a..114a2226770 100644 --- a/test/spec/modules/ixBidAdapter_spec.js +++ b/test/spec/modules/ixBidAdapter_spec.js @@ -1,14 +1,32 @@ -import * as utils from 'src/utils'; -import { config } from 'src/config'; +import * as utils from 'src/utils.js'; +import { config } from 'src/config.js'; import { expect } from 'chai'; -import { newBidder } from 'src/adapters/bidderFactory'; -import { spec } from 'modules/ixBidAdapter'; +import { newBidder } from 'src/adapters/bidderFactory.js'; +import { spec } from 'modules/ixBidAdapter.js'; describe('IndexexchangeAdapter', function () { const IX_SECURE_ENDPOINT = 'https://as-sec.casalemedia.com/cygnus'; const VIDEO_ENDPOINT_VERSION = 8.1; const BANNER_ENDPOINT_VERSION = 7.2; + const SAMPLE_SCHAIN = { + 'ver': '1.0', + 'complete': 1, + 'nodes': [ + { + 'asi': 'indirectseller.com', + 'sid': '00001', + 'hp': 1 + }, + + { + 'asi': 'indirectseller-2.com', + 'sid': '00002', + 'hp': 2 + } + ] + }; + const DEFAULT_BANNER_VALID_BID = [ { bidder: 'ix', @@ -26,7 +44,8 @@ describe('IndexexchangeAdapter', function () { transactionId: '173f49a8-7549-4218-a23c-e7ba59b47229', bidId: '1a2b3c4d', bidderRequestId: '11a22b33c44d', - auctionId: '1aa2bb3cc4dd' + auctionId: '1aa2bb3cc4dd', + schain: SAMPLE_SCHAIN } ]; @@ -56,7 +75,8 @@ describe('IndexexchangeAdapter', function () { transactionId: '173f49a8-7549-4218-a23c-e7ba59b47230', bidId: '1a2b3c4e', bidderRequestId: '11a22b33c44e', - auctionId: '1aa2bb3cc4de' + auctionId: '1aa2bb3cc4de', + schain: SAMPLE_SCHAIN } ]; @@ -82,7 +102,7 @@ describe('IndexexchangeAdapter', function () { advbrandid: 303325, advbrand: 'OECTA' }, - adm: '
' + adm: '' } ], seat: '3970' @@ -126,8 +146,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 +180,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', @@ -177,6 +197,26 @@ describe('IndexexchangeAdapter', function () { }); }); + describe('getUserSync tests', function () { + it('UserSync test : check type = iframe, check usermatch URL', function () { + const syncOptions = { + 'iframeEnabled': true + } + let userSync = spec.getUserSyncs(syncOptions); + expect(userSync[0].type).to.equal('iframe'); + const USER_SYNC_URL = 'https://js-sec.indexww.com/um/ixmatch.html'; + expect(userSync[0].url).to.equal(USER_SYNC_URL); + }); + + it('When iframeEnabled is false, no userSync should be returned', function () { + const syncOptions = { + 'iframeEnabled': false + } + let userSync = spec.getUserSyncs(syncOptions); + expect(userSync).to.be.an('array').that.is.empty; + }); + }); + describe('isBidRequestValid', function () { it('should return true when required params found for a banner or video ad', function () { expect(spec.isBidRequestValid(DEFAULT_BANNER_VALID_BID[0])).to.equal(true); @@ -317,19 +357,19 @@ describe('IndexexchangeAdapter', function () { let query; let testCopy; - beforeEach(function() { + beforeEach(function () { window.headertag = {}; - window.headertag.getIdentityInfo = function() { + window.headertag.getIdentityInfo = function () { return testCopy; }; request = spec.buildRequests(DEFAULT_BANNER_VALID_BID, DEFAULT_OPTION)[0]; query = request.data; }); - afterEach(function() { + afterEach(function () { delete window.headertag; }); - describe('buildRequestSingleRTI', function() { - before(function() { + describe('buildRequestSingleRTI', function () { + before(function () { testCopy = JSON.parse(JSON.stringify(DEFAULT_IDENTITY_RESPONSE)); }); it('payload should have correct format and value (single identity partner)', function () { @@ -348,15 +388,17 @@ describe('IndexexchangeAdapter', function () { }); }); - describe('buildRequestMultipleIds', function() { - before(function() { + describe('buildRequestMultipleIds', function () { + before(function () { testCopy = JSON.parse(JSON.stringify(DEFAULT_IDENTITY_RESPONSE)); - testCopy.IdentityIp.data.uids.push({ - id: '1234567' - }, - { - id: '2019-04-01TF2:34:41' - }); + testCopy.IdentityIp.data.uids.push( + { + id: '1234567' + }, + { + id: '2019-04-01TF2:34:41' + } + ); }); it('payload should have correct format and value (single identity w/ multi ids)', function () { const payload = JSON.parse(query.r); @@ -375,8 +417,8 @@ describe('IndexexchangeAdapter', function () { }); }); - describe('buildRequestMultipleRTI', function() { - before(function() { + describe('buildRequestMultipleRTI', function () { + before(function () { testCopy = JSON.parse(JSON.stringify(DEFAULT_IDENTITY_RESPONSE)); testCopy.JackIp = { responsePending: false, @@ -424,13 +466,13 @@ describe('IndexexchangeAdapter', function () { }); }); - describe('buildRequestNoData', function() { - beforeEach(function() { + describe('buildRequestNoData', function () { + beforeEach(function () { testCopy = JSON.parse(JSON.stringify(DEFAULT_IDENTITY_RESPONSE)); }); it('payload should not have any user eids with an undefined identity data response', function () { - window.headertag.getIdentityInfo = function() { + window.headertag.getIdentityInfo = function () { return undefined; }; request = spec.buildRequests(DEFAULT_BANNER_VALID_BID, DEFAULT_OPTION)[0]; @@ -483,6 +525,11 @@ describe('IndexexchangeAdapter', function () { const requestMethod = request.method; const query = request.data; + const bidWithoutSchain = utils.deepClone(DEFAULT_BANNER_VALID_BID); + delete bidWithoutSchain[0].schain; + const requestWithoutSchain = spec.buildRequests(bidWithoutSchain, DEFAULT_OPTION)[0]; + const queryWithoutSchain = requestWithoutSchain.data; + const bidWithoutMediaType = utils.deepClone(DEFAULT_BANNER_VALID_BID); delete bidWithoutMediaType[0].mediaTypes; bidWithoutMediaType[0].sizes = [[300, 250], [300, 600]]; @@ -505,18 +552,23 @@ describe('IndexexchangeAdapter', function () { it('payload should have correct format and value', function () { const payload = JSON.parse(query.r); - expect(payload.id).to.equal(DEFAULT_BANNER_VALID_BID[0].bidderRequestId); expect(payload.site).to.exist; expect(payload.site.page).to.equal(DEFAULT_OPTION.refererInfo.referer); expect(payload.site.ref).to.equal(document.referrer); expect(payload.ext).to.exist; expect(payload.ext.source).to.equal('prebid'); + expect(payload.source.ext.schain).to.deep.equal(SAMPLE_SCHAIN); expect(payload.imp).to.exist; expect(payload.imp).to.be.an('array'); expect(payload.imp).to.have.lengthOf(1); }); + it('payload should not include schain when not provided', function () { + const payload = JSON.parse(queryWithoutSchain.r); + expect(payload.source).to.not.exist; // source object currently only written for schain + }); + it('impression should have correct format and value', function () { const impression = JSON.parse(query.r).imp[0]; const sidValue = `${DEFAULT_BANNER_VALID_BID[0].params.size[0].toString()}x${DEFAULT_BANNER_VALID_BID[0].params.size[1].toString()}`; @@ -775,9 +827,9 @@ describe('IndexexchangeAdapter', function () { width: 300, height: 250, mediaType: 'banner', - ad: '', + ad: '', currency: 'USD', - ttl: 35, + ttl: 300, netRevenue: true, dealId: undefined, meta: { @@ -802,9 +854,9 @@ describe('IndexexchangeAdapter', function () { width: 300, height: 250, mediaType: 'banner', - ad: '', + ad: '', currency: 'USD', - ttl: 35, + ttl: 300, netRevenue: true, dealId: undefined, meta: { @@ -828,9 +880,9 @@ describe('IndexexchangeAdapter', function () { width: 300, height: 250, mediaType: 'banner', - ad: '', + ad: '', currency: 'JPY', - ttl: 35, + ttl: 300, netRevenue: true, dealId: undefined, meta: { @@ -855,9 +907,9 @@ describe('IndexexchangeAdapter', function () { width: 300, height: 250, mediaType: 'banner', - ad: '', + ad: '', currency: 'USD', - ttl: 35, + ttl: 300, netRevenue: true, dealId: 'deal', meta: { @@ -930,7 +982,7 @@ describe('IndexexchangeAdapter', function () { }); }); - describe('bidrequest consent', function() { + describe('bidrequest consent', function () { it('should have consent info if gdprApplies and consentString exist', function () { const validBidWithConsent = spec.buildRequests(DEFAULT_BANNER_VALID_BID, DEFAULT_OPTION); const requestWithConsent = JSON.parse(validBidWithConsent[0].data.r); @@ -976,7 +1028,7 @@ describe('IndexexchangeAdapter', function () { expect(requestWithConsent.user).to.be.undefined; }); - it('should have us_privacy if uspConsent is defined', function() { + it('should have us_privacy if uspConsent is defined', function () { const options = { uspConsent: '1YYN' }; @@ -986,7 +1038,7 @@ describe('IndexexchangeAdapter', function () { expect(requestWithUspConsent.regs.ext.us_privacy).to.equal('1YYN'); }); - it('should not have us_privacy if uspConsent undefined', function() { + it('should not have us_privacy if uspConsent undefined', function () { const options = {}; const validBidWithUspConsent = spec.buildRequests(DEFAULT_BANNER_VALID_BID, options); const requestWithUspConsent = JSON.parse(validBidWithUspConsent[0].data.r); @@ -994,7 +1046,7 @@ describe('IndexexchangeAdapter', function () { expect(requestWithUspConsent.regs).to.be.undefined; }); - it('should have both gdpr and us_privacy if both are defined', function() { + it('should have both gdpr and us_privacy if both are defined', function () { const options = { gdprConsent: { gdprApplies: true, diff --git a/test/spec/modules/jcmBidAdapter_spec.js b/test/spec/modules/jcmBidAdapter_spec.js index 0b467e1ecfb..9d84bca5513 100644 --- a/test/spec/modules/jcmBidAdapter_spec.js +++ b/test/spec/modules/jcmBidAdapter_spec.js @@ -1,8 +1,8 @@ import { expect } from 'chai'; -import { spec } from 'modules/jcmBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; +import { spec } from 'modules/jcmBidAdapter.js'; +import { newBidder } from 'src/adapters/bidderFactory.js'; -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/justpremiumBidAdapter_spec.js b/test/spec/modules/justpremiumBidAdapter_spec.js index 3b34799f36d..c162b785aed 100644 --- a/test/spec/modules/justpremiumBidAdapter_spec.js +++ b/test/spec/modules/justpremiumBidAdapter_spec.js @@ -1,5 +1,5 @@ import { expect } from 'chai' -import { spec } from 'modules/justpremiumBidAdapter' +import { spec } from 'modules/justpremiumBidAdapter.js' describe('justpremium adapter', function () { let sandbox; diff --git a/test/spec/modules/kargoBidAdapter_spec.js b/test/spec/modules/kargoBidAdapter_spec.js index fd0e22b91b9..be73e140839 100644 --- a/test/spec/modules/kargoBidAdapter_spec.js +++ b/test/spec/modules/kargoBidAdapter_spec.js @@ -1,6 +1,6 @@ import {expect, assert} from 'chai'; -import {spec} from 'modules/kargoBidAdapter'; -import {config} from 'src/config'; +import {spec} from 'modules/kargoBidAdapter.js'; +import {config} from 'src/config.js'; describe('kargo adapter tests', function () { var sandbox, clock, frozenNow = new Date(); @@ -49,6 +49,8 @@ describe('kargo adapter tests', function () { } return {adServerCurrency: 'USD'}; } + if (key === 'debug') return true; + if (key === 'deviceAccess') return true; throw new Error(`Config stub incomplete! Missing key "${key}"`) }); @@ -253,7 +255,8 @@ describe('kargo adapter tests', function () { '2_80': 'd2a855a5-1b1c-4300-940e-a708fa1f1bde', '2_93': '5ee24138-5e03-4b9d-a953-38e833f2849f' }, - optOut: false + optOut: false, + usp: '1---' }, krux: { userID: 'rsgr9pnij', @@ -298,7 +301,8 @@ describe('kargo adapter tests', function () { if (excludeUserIds === true) { base.userIDs = { - crbIDs: {} + crbIDs: {}, + usp: '1---' }; delete base.prebidRawBidRequests[0].userId.tdid; } @@ -318,7 +322,7 @@ describe('kargo adapter tests', function () { if (excludeTdid) { delete clonedBids[0].userId.tdid; } - var request = spec.buildRequests(clonedBids, {timeout: 200, foo: 'bar'}); + var request = spec.buildRequests(clonedBids, {timeout: 200, uspConsent: '1---', foo: 'bar'}); expected.sessionId = getSessionId(); sessionIds.push(expected.sessionId); var krakenParams = JSON.parse(decodeURIComponent(request.data.slice(5))); @@ -437,7 +441,8 @@ describe('kargo adapter tests', function () { cpm: 3, adm: '
', width: 320, - height: 50 + height: 50, + metadata: {} }, 2: { id: 'bar', @@ -445,7 +450,10 @@ describe('kargo adapter tests', function () { adm: '
', width: 300, height: 250, - targetingCustom: 'dmpmptest1234' + targetingCustom: 'dmpmptest1234', + metadata: { + landingPageDomain: 'https://foobar.com' + } }, 3: { id: 'bar', @@ -483,7 +491,8 @@ describe('kargo adapter tests', function () { creativeId: 'foo', dealId: undefined, netRevenue: true, - currency: 'USD' + currency: 'USD', + meta: undefined }, { requestId: '2', cpm: 2.5, @@ -494,7 +503,10 @@ describe('kargo adapter tests', function () { creativeId: 'bar', dealId: 'dmpmptest1234', netRevenue: true, - currency: 'USD' + currency: 'USD', + meta: { + clickUrl: 'https://foobar.com' + } }, { requestId: '3', cpm: 2.5, @@ -505,7 +517,8 @@ describe('kargo adapter tests', function () { creativeId: 'bar', dealId: undefined, netRevenue: true, - currency: 'USD' + currency: 'USD', + meta: undefined }]; expect(resp).to.deep.equal(expectation); }); diff --git a/test/spec/modules/komoonaBidAdapter_spec.js b/test/spec/modules/komoonaBidAdapter_spec.js index b6d17c7b20c..3d62f91cae6 100644 --- a/test/spec/modules/komoonaBidAdapter_spec.js +++ b/test/spec/modules/komoonaBidAdapter_spec.js @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import { spec } from 'modules/komoonaBidAdapter'; +import { spec } from 'modules/komoonaBidAdapter.js'; describe('Komoona.com Adapter Tests', function () { const bidsRequest = [ @@ -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/konduitWrapper_spec.js b/test/spec/modules/konduitWrapper_spec.js index bcc65ddd683..4a0c627e885 100644 --- a/test/spec/modules/konduitWrapper_spec.js +++ b/test/spec/modules/konduitWrapper_spec.js @@ -1,9 +1,9 @@ import { expect } from 'chai'; import parse from 'url-parse'; -import { buildVastUrl } from 'modules/konduitWrapper'; -import { parseQS } from 'src/url'; -import { config } from 'src/config'; +import { buildVastUrl } from 'modules/konduitWrapper.js'; +import { parseQS } from 'src/utils.js'; +import { config } from 'src/config.js'; describe('The Konduit vast wrapper module', function () { it('should make a wrapped request url when `bid` passed', function () { diff --git a/test/spec/modules/lemmaBidAdapter_spec.js b/test/spec/modules/lemmaBidAdapter_spec.js index 624e763ebe1..a236ac17d71 100644 --- a/test/spec/modules/lemmaBidAdapter_spec.js +++ b/test/spec/modules/lemmaBidAdapter_spec.js @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import { spec } from 'modules/lemmaBidAdapter'; -import * as utils from 'src/utils'; +import { spec } from 'modules/lemmaBidAdapter.js'; +import * as utils from 'src/utils.js'; const constants = require('src/constants.json'); describe('lemmaBidAdapter', function() { @@ -151,7 +151,7 @@ describe('lemmaBidAdapter', function() { }); 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.url).to.equal('https://ads.lemmatechnologies.com/lemma/servad?pid=1001&aid=1'); expect(request.method).to.equal('POST'); }); it('Request params check', function() { diff --git a/test/spec/modules/lifestreetBidAdapter_spec.js b/test/spec/modules/lifestreetBidAdapter_spec.js index 7f8c5f6c44d..d66727da644 100644 --- a/test/spec/modules/lifestreetBidAdapter_spec.js +++ b/test/spec/modules/lifestreetBidAdapter_spec.js @@ -1,222 +1,232 @@ -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); - }); +import { expect } from 'chai'; +import { BANNER, VIDEO } from 'src/mediaTypes.js'; +import { spec } from 'modules/lifestreetBidAdapter.js'; - it('should use json adapter', function () { - expect(request.url).to.contain('/prebid/'); - }); +describe('lifestreetBidAdapter', function() { + let bidRequests; + let videoBidRequests; + let bidResponses; + let videoBidResponses; + beforeEach(function() { + bidRequests = [ + { + bidder: 'lifestreet', + params: { + slot: 'slot166704', + adkey: '78c', + ad_size: '160x600' + }, + mediaTypes: { + banner: { + sizes: [ + [160, 600], + [300, 600] + ] + } + }, + sizes: [ + [160, 600], + [300, 600] + ] + } + ]; - 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', + bidResponses = { + body: { + cpm: 0.1, 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, + content_type: 'display_flash', 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, + content: '', + 'adid': '56380110', + 'cid': '44724710', + 'crid': '443801010', + 'w': 300, + 'h': 250, + 'ext': { + 'prebid': { + 'targeting': { + 'hb_bidder': 'luponmedia', + 'hb_pb': '0.40', + 'hb_size': '300x250' + }, + 'type': 'banner' + } + } + } + ], + 'seat': 'luponmedia' + } + ], + 'cur': 'USD', + 'ext': { + 'responsetimemillis': { + 'luponmedia': 233 + }, + 'tmaxrequest': 1500, + 'usersyncs': { + 'status': 'ok', + 'bidder_status': [] + } + } + }; + + let expectedResponse = [ + { + 'requestId': '2a122246ef72ea', + 'cpm': '0.43', + 'width': 300, + 'height': 250, + 'creativeId': '443801010', + 'currency': 'USD', + 'dealId': '23425', + 'netRevenue': false, + 'ttl': 300, + 'referrer': '', + 'ad': ' ' + } + ]; + + let bidderRequest = { + 'data': '{"site":{"page":"https://novi.ba/clanak/176067/fast-car-beginner-s-guide-to-tuning-turbo-engines"}}' + }; + + 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 noBidResponse = []; + + let noBidBidderRequest = { + 'data': '{"site":{"page":""}}' + } + let noBidResult = spec.interpretResponse({ body: noBidResponse }, noBidBidderRequest); + expect(noBidResult.length).to.equal(0); + }); + }); + + describe('getUserSyncs', function () { + const bidResponse1 = { + 'body': { + 'ext': { + 'responsetimemillis': { + 'luponmedia': 233 + }, + 'tmaxrequest': 1500, + 'usersyncs': { + 'status': 'ok', + 'bidder_status': [ + { + 'bidder': 'luponmedia', + 'no_cookie': true, + 'usersync': { + 'url': 'https://adxpremium.services/api/usersync', + 'type': 'redirect' + } + }, + { + 'bidder': 'luponmedia', + 'no_cookie': true, + 'usersync': { + 'url': 'https://adxpremium.services/api/iframeusersync', + 'type': 'iframe' + } + } + ] + } + } + } + }; + + const bidResponse2 = { + 'body': { + 'ext': { + 'responsetimemillis': { + 'luponmedia': 233 + }, + 'tmaxrequest': 1500, + 'usersyncs': { + 'status': 'no_cookie', + 'bidder_status': [] + } + } + } + }; + + it('should use a sync url from first response (pixel and iframe)', function () { + const syncs = spec.getUserSyncs({ pixelEnabled: true, iframeEnabled: true }, [bidResponse1, bidResponse2]); + expect(syncs).to.deep.equal([ + { + type: 'image', + url: 'https://adxpremium.services/api/usersync' + }, + { + type: 'iframe', + url: 'https://adxpremium.services/api/iframeusersync' + } + ]); + }); + + it('handle empty response (e.g. timeout)', function () { + const syncs = spec.getUserSyncs({ pixelEnabled: true, iframeEnabled: true }, []); + expect(syncs).to.deep.equal([]); + }); + + it('returns empty syncs when not pixel enabled and not iframe enabled', function () { + const syncs = spec.getUserSyncs({ pixelEnabled: false, iframeEnabled: false }, [bidResponse1]); + expect(syncs).to.deep.equal([]); + }); + + it('returns pixel syncs when pixel enabled and not iframe enabled', function() { + resetUserSync(); + + const syncs = spec.getUserSyncs({ pixelEnabled: true, iframeEnabled: false }, [bidResponse1]); + expect(syncs).to.deep.equal([ + { + type: 'image', + url: 'https://adxpremium.services/api/usersync' + } + ]); + }); + + it('returns iframe syncs when not pixel enabled and iframe enabled', function() { + resetUserSync(); + + const syncs = spec.getUserSyncs({ pixelEnabled: false, iframeEnabled: true }, [bidResponse1]); + expect(syncs).to.deep.equal([ + { + type: 'iframe', + url: 'https://adxpremium.services/api/iframeusersync' + } + ]); + }); + }); + + describe('hasValidSupplyChainParams', function () { + it('returns true if schain is valid', function () { + const schain = { + 'ver': '1.0', + 'complete': 1, + 'nodes': [ + { + 'asi': 'novi.ba', + 'sid': '199424', + 'hp': 1 + } + ] + }; + + const checkSchain = hasValidSupplyChainParams(schain); + expect(checkSchain).to.equal(true); + }); + + it('returns false if schain is invalid', function () { + const schain = { + 'ver': '1.0', + 'complete': 1, + 'nodes': [ + { + 'invalid': 'novi.ba' + } + ] + }; + + const checkSchain = hasValidSupplyChainParams(schain); + expect(checkSchain).to.equal(false); + }); + }); +}); diff --git a/test/spec/modules/madvertiseBidAdapter_spec.js b/test/spec/modules/madvertiseBidAdapter_spec.js index b2a08410532..041b49ef69e 100644 --- a/test/spec/modules/madvertiseBidAdapter_spec.js +++ b/test/spec/modules/madvertiseBidAdapter_spec.js @@ -1,7 +1,7 @@ import {expect} from 'chai'; -import {config} from 'src/config'; -import * as utils from 'src/utils'; -import {spec} from 'modules/madvertiseBidAdapter'; +import {config} from 'src/config.js'; +import * as utils from 'src/utils.js'; +import {spec} from 'modules/madvertiseBidAdapter.js'; describe('madvertise adapater', function () { describe('Test validate req', function () { @@ -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 df2c6bb9a13..1dad60f5d98 100644 --- a/test/spec/modules/mantisBidAdapter_spec.js +++ b/test/spec/modules/mantisBidAdapter_spec.js @@ -1,6 +1,6 @@ import {expect} from 'chai'; -import {spec} from 'modules/mantisBidAdapter'; -import {newBidder} from 'src/adapters/bidderFactory'; +import {spec} from 'modules/mantisBidAdapter.js'; +import {newBidder} from 'src/adapters/bidderFactory.js'; describe('MantisAdapter', function () { const adapter = newBidder(spec); @@ -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/marsmediaBidAdapter_spec.js b/test/spec/modules/marsmediaBidAdapter_spec.js index a58857e0f3f..c0399e5d0a2 100644 --- a/test/spec/modules/marsmediaBidAdapter_spec.js +++ b/test/spec/modules/marsmediaBidAdapter_spec.js @@ -1,122 +1,607 @@ -import { expect } from 'chai' -import { spec, _getPlatform } from 'modules/marsmediaBidAdapter' -import { newBidder } from 'src/adapters/bidderFactory' - -describe('marsmediaBidAdapter', function () { - const adapter = newBidder(spec) - - let bidRequest = { - 'bidId': '123', - 'sizes': [[ 300, 250 ]], - 'params': { - 'publisherID': 9999, - 'floor': 0.1 - } - } - - describe('codes', function () { - it('should return a bidder code of marsmedia', function () { - expect(spec.code).to.equal('marsmedia') - }) - it('should alias mars', function () { - expect(spec.aliases.length > 0 && spec.aliases[0] === 'mars').to.be.true - }) - }) +import {spec} from '../../../modules/marsmediaBidAdapter.js'; +import * as utils from '../../../src/utils.js'; +import * as sinon from 'sinon'; - describe('isBidRequestValid', function () { - it('should return true if all params present', function () { - expect(spec.isBidRequestValid(bidRequest)).to.be.true - }) - - it('should return false if any parameter missing', function () { - expect(spec.isBidRequestValid(Object.assign(bidRequest, { params: { publisherID: null } }))).to.be.false - }) - }) - - describe('buildRequests', function () { - let req = spec.buildRequests([ bidRequest ], { refererInfo: { } }) - let rdata - - it('should return request object', function () { - expect(req).to.not.be.null - }) - - it('should build request data', function () { - expect(req.data).to.not.be.null - }) - - it('should include one request', function () { - rdata = JSON.parse(req.data) - expect(rdata.imp.length).to.equal(1) - }) - - it('should include all publisher params', function () { - let r = rdata.imp[0] - expect(r.publisherID !== null).to.be.true - }) - }) - - describe('interpretResponse', function () { - let response; - beforeEach(function () { - response = { - body: { - 'id': '37386aade21a71', - 'seatbid': [{ - 'bid': [{ - 'id': '1', - 'impid': '1', - 'cid': '1', - 'price': 0.1, - 'nurl': '', - 'adm': '', - 'w': 320, - 'h': 250 - }] - }] +var r1adapter = spec; + +describe('marsmedia adapter tests', function () { + beforeEach(function() { + this.defaultBidderRequest = { + 'refererInfo': { + 'referer': 'Reference Page', + 'stack': [ + 'aodomain.dvl', + 'page.dvl' + ] + } + }; + }); + + describe('Verify 1.0 POST Banner Bid Request', function () { + it('buildRequests works', function () { + var bidRequestList = [ + { + 'bidder': 'marsmedia', + 'params': { + 'zoneId': 9999 + }, + 'mediaType': 'banner', + 'adUnitCode': 'div-gpt-ad-1438287399331-0', + 'sizes': [[300, 250]], + 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', + 'bidderRequestId': '418b37f85e772c', + 'auctionId': '18fd8b8b0bd757', + 'bidRequestsCount': 1, + 'bidId': '51ef8751f9aead' } + ]; + + var bidRequest = r1adapter.buildRequests(bidRequestList, this.defaultBidderRequest); + + expect(bidRequest.url).to.have.string('https://hb.go2speed.media/bidder/?bid=3mhdom&zoneId=9999&hbv='); + expect(bidRequest.method).to.equal('POST'); + const openrtbRequest = JSON.parse(bidRequest.data); + expect(openrtbRequest.site).to.not.equal(null); + expect(openrtbRequest.site.ref).to.equal('Reference Page'); + expect(openrtbRequest.device).to.not.equal(null); + expect(openrtbRequest.device.ua).to.equal(navigator.userAgent); + expect(openrtbRequest.device.dnt).to.equal(0); + expect(openrtbRequest.imp[0].banner).to.not.equal(null); + expect(openrtbRequest.imp[0].banner.format[0].w).to.equal(300); + expect(openrtbRequest.imp[0].banner.format[0].h).to.equal(250); + expect(openrtbRequest.imp[0].ext.bidder.zoneId).to.equal(9999); + }); + + it('interpretResponse works', function() { + var bidList = { + 'body': [ + { + 'impid': 'div-gpt-ad-1438287399331-0', + 'w': 300, + 'h': 250, + 'adm': '
My Compelling Ad
', + 'price': 1, + 'crid': 'cr-cfy24' + } + ] }; + + var bannerBids = r1adapter.interpretResponse(bidList); + + expect(bannerBids.length).to.equal(1); + const bid = bannerBids[0]; + expect(bid.width).to.equal(300); + expect(bid.height).to.equal(250); + expect(bid.creativeId).to.equal('cr-cfy24'); + expect(bid.currency).to.equal('USD'); + expect(bid.netRevenue).to.equal(true); + expect(bid.cpm).to.equal(1.0); + expect(bid.ttl).to.equal(350); }); + }); + + describe('Verify POST Video Bid Request', function() { + it('buildRequests works', function () { + var bidRequestList = [ + { + 'bidder': 'marsmedia', + 'params': { + 'zoneId': 9999 + }, + 'mediaTypes': { + 'video': { + 'playerSize': [640, 480], + 'context': 'instream' + } + }, + 'adUnitCode': 'div-gpt-ad-1438287399331-1', + 'sizes': [ + [300, 250] + ], + 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', + 'bidderRequestId': '418b37f85e772c', + 'auctionId': '18fd8b8b0bd757', + 'bidRequestsCount': 1, + 'bidId': '51ef8751f9aead' + } + ]; - it('should get the correct bid response', function () { - let expectedResponse = [{ - 'requestId': '37386aade21a71', - 'cpm': 0.1, - 'width': 320, - 'height': 250, - 'creativeId': '1', - 'currency': 'USD', - 'netRevenue': true, - 'ad': ``, - 'ttl': 60 - }]; + var bidRequest = r1adapter.buildRequests(bidRequestList, this.defaultBidderRequest); - let result = spec.interpretResponse(response); - expect(result[0]).to.deep.equal(expectedResponse[0]); + expect(bidRequest.url).to.have.string('https://hb.go2speed.media/bidder/?bid=3mhdom&zoneId=9999&hbv='); + expect(bidRequest.method).to.equal('POST'); + const openrtbRequest = JSON.parse(bidRequest.data); + expect(openrtbRequest.site).to.not.equal(null); + expect(openrtbRequest.device).to.not.equal(null); + expect(openrtbRequest.device.ua).to.equal(navigator.userAgent); + expect(openrtbRequest.device).to.have.property('dnt'); + expect(openrtbRequest.imp[0].video).to.not.equal(null); + expect(openrtbRequest.imp[0].video.w).to.equal(640); + expect(openrtbRequest.imp[0].video.h).to.equal(480); + expect(openrtbRequest.imp[0].video.mimes[0]).to.equal('video/mp4'); + expect(openrtbRequest.imp[0].video.protocols).to.eql([2, 3, 5, 6]); + expect(openrtbRequest.imp[0].video.startdelay).to.equal(0); + expect(openrtbRequest.imp[0].video.skip).to.equal(0); + expect(openrtbRequest.imp[0].video.playbackmethod).to.eql([1, 2, 3, 4]); + expect(openrtbRequest.imp[0].video.delivery[0]).to.equal(1); + expect(openrtbRequest.imp[0].video.api).to.eql([1, 2, 5]); }); - it('handles empty bid response', function () { - let response = { - body: '' + it('interpretResponse with vast url works', function() { + var bidList = { + 'body': [ + { + 'impid': 'div-gpt-ad-1438287399331-1', + 'price': 1, + 'adm': 'https://example.com/', + 'adomain': [ + 'test.com' + ], + 'cid': '467415', + 'crid': 'cr-vid', + 'w': 800, + 'h': 600 + } + ] }; - let result = spec.interpretResponse(response); - expect(result.length).to.equal(0); + + var videoBids = r1adapter.interpretResponse(bidList); + + expect(videoBids.length).to.equal(1); + const bid = videoBids[0]; + expect(bid.width).to.equal(800); + expect(bid.height).to.equal(600); + expect(bid.vastUrl).to.equal('https://example.com/'); + expect(bid.mediaType).to.equal('video'); + expect(bid.creativeId).to.equal('cr-vid'); + expect(bid.currency).to.equal('USD'); + expect(bid.netRevenue).to.equal(true); + expect(bid.cpm).to.equal(1.0); + expect(bid.ttl).to.equal(600); + }); + + it('interpretResponse with xml works', function() { + var bidList = { + 'body': [ + { + 'impid': 'div-gpt-ad-1438287399331-1', + 'price': 1, + 'adm': '', + 'adomain': [ + 'test.com' + ], + 'cid': '467415', + 'crid': 'cr-vid', + 'w': 800, + 'h': 600 + } + ] + }; + + var videoBids = r1adapter.interpretResponse(bidList); + + expect(videoBids.length).to.equal(1); + const bid = videoBids[0]; + expect(bid.width).to.equal(800); + expect(bid.height).to.equal(600); + expect(bid.vastXml).to.equal(''); + expect(bid.mediaType).to.equal('video'); + expect(bid.creativeId).to.equal('cr-vid'); + expect(bid.currency).to.equal('USD'); + expect(bid.netRevenue).to.equal(true); + expect(bid.cpm).to.equal(1.0); + expect(bid.ttl).to.equal(600); + }); + }); + + describe('misc buildRequests', function() { + it('should send GDPR Consent data to Marsmedia tag', function () { + var bidRequestList = [ + { + 'bidder': 'marsmedia', + 'params': { + 'zoneId': 9999 + }, + 'mediaTypes': { + 'banner': { + 'sizes': [[300, 250]] + } + }, + 'adUnitCode': 'div-gpt-ad-1438287399331-3', + 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', + 'bidderRequestId': '418b37f85e772c', + 'auctionId': '18fd8b8b0bd757', + 'bidRequestsCount': 1, + 'bidId': '51ef8751f9aead' + } + ]; + + var consentString = 'testConsentString'; + var gdprBidderRequest = this.defaultBidderRequest; + gdprBidderRequest.gdprConsent = { + 'gdprApplies': true, + 'consentString': consentString + }; + + var bidRequest = r1adapter.buildRequests(bidRequestList, gdprBidderRequest); + + const openrtbRequest = JSON.parse(bidRequest.data); + expect(openrtbRequest.user.ext.consent).to.equal(consentString); + expect(openrtbRequest.regs.ext.gdpr).to.equal(true); + }); + + it('prefer 2.0 sizes', function () { + var bidRequestList = [ + { + 'bidder': 'marsmedia', + 'params': { + 'zoneId': 9999 + }, + 'mediaTypes': { + 'banner': { + 'sizes': [[300, 600]] + } + }, + 'adUnitCode': 'div-gpt-ad-1438287399331-0', + 'sizes': [[300, 250]], + 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', + 'bidderRequestId': '418b37f85e772c', + 'auctionId': '18fd8b8b0bd757', + 'bidRequestsCount': 1, + 'bidId': '51ef8751f9aead' + } + ]; + + var bidRequest = r1adapter.buildRequests(bidRequestList, this.defaultBidderRequest); + + const openrtbRequest = JSON.parse(bidRequest.data); + expect(openrtbRequest.imp[0].banner.format[0].w).to.equal(300); + expect(openrtbRequest.imp[0].banner.format[0].h).to.equal(600); + }); + + it('does not return request for invalid banner size configuration', function () { + var bidRequestList = [ + { + 'bidder': 'marsmedia', + 'params': { + 'zoneId': 9999 + }, + 'mediaTypes': { + 'banner': { + 'sizes': [[300]] + } + }, + 'adUnitCode': 'div-gpt-ad-1438287399331-0', + 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', + 'bidderRequestId': '418b37f85e772c', + 'auctionId': '18fd8b8b0bd757', + 'bidRequestsCount': 1, + 'bidId': '51ef8751f9aead' + } + ]; + + var bidRequest = r1adapter.buildRequests(bidRequestList, this.defaultBidderRequest); + expect(bidRequest.method).to.be.undefined; + }); + + it('does not return request for missing banner size configuration', function () { + var bidRequestList = [ + { + 'bidder': 'marsmedia', + 'params': { + 'zoneId': 9999 + }, + 'mediaTypes': { + 'banner': {} + }, + 'adUnitCode': 'div-gpt-ad-1438287399331-0', + 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', + 'bidderRequestId': '418b37f85e772c', + 'auctionId': '18fd8b8b0bd757', + 'bidRequestsCount': 1, + 'bidId': '51ef8751f9aead' + } + ]; + + var bidRequest = r1adapter.buildRequests(bidRequestList, this.defaultBidderRequest); + expect(bidRequest.method).to.be.undefined; + }); + + it('reject bad sizes', function () { + var bidRequestList = [ + { + 'bidder': 'marsmedia', + 'params': { + 'zoneId': 9999 + }, + 'mediaTypes': { + 'banner': {'sizes': [['400', '500'], ['4n0', '5g0']]} + }, + 'adUnitCode': 'div-gpt-ad-1438287399331-0', + 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', + 'bidderRequestId': '418b37f85e772c', + 'auctionId': '18fd8b8b0bd757', + 'bidRequestsCount': 1, + 'bidId': '51ef8751f9aead' + } + ]; + + var bidRequest = r1adapter.buildRequests(bidRequestList, this.defaultBidderRequest); + const openrtbRequest = JSON.parse(bidRequest.data); + expect(openrtbRequest.imp[0].banner.format.length).to.equal(1); + }); + + it('dnt is correctly set to 1', function () { + var bidRequestList = [ + { + 'bidder': 'marsmedia', + 'params': { + 'zoneId': 9999 + }, + 'mediaTypes': { + 'banner': { + 'sizes': [[300, 600]] + } + }, + 'adUnitCode': 'div-gpt-ad-1438287399331-0', + 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', + 'bidderRequestId': '418b37f85e772c', + 'auctionId': '18fd8b8b0bd757', + 'bidRequestsCount': 1, + 'bidId': '51ef8751f9aead' + } + ]; + + var dntStub = sinon.stub(utils, 'getDNT').returns(1); + + var bidRequest = r1adapter.buildRequests(bidRequestList, this.defaultBidderRequest); + + dntStub.restore(); + + const openrtbRequest = JSON.parse(bidRequest.data); + expect(openrtbRequest.device.dnt).to.equal(1); + }); + + it('supports string video sizes', function () { + var bidRequestList = [ + { + 'bidder': 'marsmedia', + 'params': { + 'zoneId': 9999 + }, + 'mediaTypes': { + 'video': { + 'context': 'instream', + 'playerSize': ['600', '300'] + } + }, + 'adUnitCode': 'div-gpt-ad-1438287399331-1', + 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', + 'bidderRequestId': '418b37f85e772c', + 'auctionId': '18fd8b8b0bd757', + 'bidRequestsCount': 1, + 'bidId': '51ef8751f9aead' + } + ]; + + var bidRequest = r1adapter.buildRequests(bidRequestList, this.defaultBidderRequest); + + const openrtbRequest = JSON.parse(bidRequest.data); + expect(openrtbRequest.imp[0].video.w).to.equal(600); + expect(openrtbRequest.imp[0].video.h).to.equal(300); + }); + + it('rejects bad video sizes', function () { + var bidRequestList = [ + { + 'bidder': 'marsmedia', + 'params': { + 'zoneId': 9999 + }, + 'mediaTypes': { + 'video': { + 'context': 'instream', + 'playerSize': ['badWidth', 'badHeight'] + } + }, + 'adUnitCode': 'div-gpt-ad-1438287399331-1', + 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', + 'bidderRequestId': '418b37f85e772c', + 'auctionId': '18fd8b8b0bd757', + 'bidRequestsCount': 1, + 'bidId': '51ef8751f9aead' + } + ]; + + var bidRequest = r1adapter.buildRequests(bidRequestList, this.defaultBidderRequest); + + const openrtbRequest = JSON.parse(bidRequest.data); + expect(openrtbRequest.imp[0].video.w).to.be.undefined; + expect(openrtbRequest.imp[0].video.h).to.be.undefined; + }); + + it('supports missing video size', function () { + var bidRequestList = [ + { + 'bidder': 'marsmedia', + 'params': { + 'zoneId': 9999 + }, + 'mediaTypes': { + 'video': { + 'context': 'instream' + } + }, + 'adUnitCode': 'div-gpt-ad-1438287399331-1', + 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', + 'bidderRequestId': '418b37f85e772c', + 'auctionId': '18fd8b8b0bd757', + 'bidRequestsCount': 1, + 'bidId': '51ef8751f9aead' + } + ]; + + var bidRequest = r1adapter.buildRequests(bidRequestList, this.defaultBidderRequest); + + const openrtbRequest = JSON.parse(bidRequest.data); + expect(openrtbRequest.imp[0].video.w).to.be.undefined; + expect(openrtbRequest.imp[0].video.h).to.be.undefined; + }); + + it('should return empty site data when refererInfo is missing', function() { + delete this.defaultBidderRequest.refererInfo; + var bidRequestList = [ + { + 'bidder': 'marsmedia', + 'params': { + 'zoneId': 9999 + }, + 'mediaType': 'banner', + 'adUnitCode': 'div-gpt-ad-1438287399331-0', + 'sizes': [[300, 250]], + 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', + 'bidderRequestId': '418b37f85e772c', + 'auctionId': '18fd8b8b0bd757', + 'bidRequestsCount': 1, + 'bidId': '51ef8751f9aead' + } + ]; + + var bidRequest = r1adapter.buildRequests(bidRequestList, this.defaultBidderRequest); + const openrtbRequest = JSON.parse(bidRequest.data); + + expect(openrtbRequest.site.domain).to.equal(''); + expect(openrtbRequest.site.page).to.equal(''); + expect(openrtbRequest.site.ref).to.equal(''); + }); + }); + + it('should return empty site.domain and site.page when refererInfo.stack is empty', function() { + this.defaultBidderRequest.refererInfo.stack = []; + var bidRequestList = [ + { + 'bidder': 'marsmedia', + 'params': { + 'zoneId': 9999 + }, + 'mediaType': 'banner', + 'adUnitCode': 'div-gpt-ad-1438287399331-0', + 'sizes': [[300, 250]], + 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', + 'bidderRequestId': '418b37f85e772c', + 'auctionId': '18fd8b8b0bd757', + 'bidRequestsCount': 1, + 'bidId': '51ef8751f9aead' + } + ]; + + var bidRequest = r1adapter.buildRequests(bidRequestList, this.defaultBidderRequest); + const openrtbRequest = JSON.parse(bidRequest.data); + + expect(openrtbRequest.site.domain).to.equal(''); + expect(openrtbRequest.site.page).to.equal(''); + expect(openrtbRequest.site.ref).to.equal('Reference Page'); + }); + + it('should secure correctly', function() { + this.defaultBidderRequest.refererInfo.stack[0] = ['https://securesite.dvl']; + var bidRequestList = [ + { + 'bidder': 'marsmedia', + 'params': { + 'zoneId': 9999 + }, + 'mediaType': 'banner', + 'adUnitCode': 'div-gpt-ad-1438287399331-0', + 'sizes': [[300, 250]], + 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', + 'bidderRequestId': '418b37f85e772c', + 'auctionId': '18fd8b8b0bd757', + 'bidRequestsCount': 1, + 'bidId': '51ef8751f9aead' + } + ]; + + var bidRequest = r1adapter.buildRequests(bidRequestList, this.defaultBidderRequest); + const openrtbRequest = JSON.parse(bidRequest.data); + + expect(openrtbRequest.imp[0].secure).to.equal(1); + }); + + it('should pass schain', function() { + var schain = { + 'ver': '1.0', + 'complete': 1, + 'nodes': [{ + 'asi': 'indirectseller.com', + 'sid': '00001', + 'hp': 1 + }, { + 'asi': 'indirectseller-2.com', + 'sid': '00002', + 'hp': 1 + }] + }; + var bidRequestList = [ + { + 'bidder': 'marsmedia', + 'params': { + 'zoneId': 9999 + }, + 'mediaType': 'banner', + 'adUnitCode': 'div-gpt-ad-1438287399331-0', + 'sizes': [[300, 250]], + 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', + 'bidderRequestId': '418b37f85e772c', + 'auctionId': '18fd8b8b0bd757', + 'bidRequestsCount': 1, + 'bidId': '51ef8751f9aead', + 'schain': schain + } + ]; + + var bidRequest = r1adapter.buildRequests(bidRequestList, this.defaultBidderRequest); + const openrtbRequest = JSON.parse(bidRequest.data); + + expect(openrtbRequest.source.ext.schain).to.deep.equal(schain); + }); + + describe('misc interpretResponse', function () { + it('No bid response', function() { + var noBidResponse = r1adapter.interpretResponse({ + 'body': '' + }); + expect(noBidResponse.length).to.equal(0); + }); + }); + + describe('isBidRequestValid', function () { + var bid = { + 'bidder': 'marsmedia', + 'params': { + 'zoneId': 9999 + }, + 'mediaTypes': { + 'banner': { + 'sizes': [[300, 250]] + } + }, + 'adUnitCode': 'bannerDiv' + }; + + it('should return true when required params found', function () { + expect(r1adapter.isBidRequestValid(bid)).to.equal(true); + }); + + it('should return false when placementId missing', function () { + delete bid.params.zoneId; + expect(r1adapter.isBidRequestValid(bid)).to.equal(false); }); }); describe('getUserSyncs', function () { - /* it('should return iframe sync', function () { - let sync = spec.getUserSyncs({ iframeEnabled: true }) - expect(sync.length).to.equal(1) - expect(sync[0].type === 'iframe') - expect(typeof sync[0].url === 'string') - }) - - it('should return pixel sync', function () { - let sync = spec.getUserSyncs({ pixelEnabled: true }) - expect(sync.length).to.equal(1) - expect(sync[0].type === 'image') - expect(typeof sync[0].url === 'string') - }) */ - }) -}) + it('returns an empty string', function () { + expect(r1adapter.getUserSyncs()).to.deep.equal([]); + }); + }); +}); diff --git a/test/spec/modules/meazyBidAdapter_spec.js b/test/spec/modules/meazyBidAdapter_spec.js index 9abe37ece62..2c24791f515 100644 --- a/test/spec/modules/meazyBidAdapter_spec.js +++ b/test/spec/modules/meazyBidAdapter_spec.js @@ -1,10 +1,10 @@ -import * as utils from 'src/utils'; +import * as utils from 'src/utils.js'; import { expect } from 'chai'; -import { spec } from 'modules/meazyBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; +import { spec } from 'modules/meazyBidAdapter.js'; +import { newBidder } from 'src/adapters/bidderFactory.js'; 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/mediaforceBidAdapter_spec.js b/test/spec/modules/mediaforceBidAdapter_spec.js new file mode 100644 index 00000000000..09d997e9349 --- /dev/null +++ b/test/spec/modules/mediaforceBidAdapter_spec.js @@ -0,0 +1,240 @@ +import {assert} from 'chai'; +import {spec} from 'modules/mediaforceBidAdapter.js'; +import * as utils from '../../../src/utils.js'; + +describe('mediaforce bid adapter', function () { + let sandbox; + + beforeEach(function () { + sandbox = sinon.sandbox.create(); + }); + + afterEach(function () { + sandbox.restore(); + }); + + function getLanguage() { + let language = navigator.language ? 'language' : 'userLanguage'; + return navigator[language].split('-')[0]; + } + + const language = getLanguage(); + const baseUrl = 'https://rtb.mfadsrvr.com' + + describe('isBidRequestValid()', function () { + const defaultBid = { + bidder: 'mediaforce', + params: { + property: '10433394', + bidfloor: 0.3, + }, + }; + + it('should not accept bid without required params', function () { + assert.equal(spec.isBidRequestValid(defaultBid), false); + }); + + it('should return false when params are not passed', function () { + let bid = utils.deepClone(defaultBid); + delete bid.params; + assert.equal(spec.isBidRequestValid(bid), false); + }); + + it('should return false when valid params are not passed', function () { + let bid = utils.deepClone(defaultBid); + bid.params = {placement_id: '', publisher_id: ''}; + assert.equal(spec.isBidRequestValid(bid), false); + }); + + it('should return true when valid params are passed', function () { + let bid = utils.deepClone(defaultBid); + bid.mediaTypes = { + banner: { + sizes: [[300, 250]] + } + }; + bid.params = {publisher_id: 2, placement_id: '123'}; + assert.equal(spec.isBidRequestValid(bid), true); + }); + + it('should return false when mediaTypes == native passed (native is not supported yet)', function () { + let bid = utils.deepClone(defaultBid); + bid.mediaTypes = { + native: { + sizes: [[300, 250]] + } + }; + bid.params = {publisher_id: 2, placement_id: '123'}; + assert.equal(spec.isBidRequestValid(bid), true); + }); + }); + + describe('buildRequests()', function () { + const defaultBid = { + bidder: 'mediaforce', + params: { + publisher_id: 'pub123', + placement_id: '202', + }, + mediaTypes: { + banner: { + sizes: [[300, 250]] + } + }, + transactionId: 'd45dd707-a418-42ec-b8a7-b70a6c6fab0b', + }; + + const refererInfo = { + referer: 'https://www.prebid.org', + reachedTop: true, + stack: [ + 'https://www.prebid.org/page.html', + 'https://www.prebid.org/iframe1.html', + ] + }; + + const requestUrl = `${baseUrl}/header_bid`; + const dnt = utils.getDNT() ? 1 : 0; + const secure = 1 + + it('should return undefined if no validBidRequests passed', function () { + assert.equal(spec.buildRequests([]), undefined); + }); + + it('should return proper request url: no refererInfo', function () { + let [request] = spec.buildRequests([defaultBid]); + assert.equal(request.url, requestUrl); + }); + + it('should return proper banner imp', function () { + let bid = utils.deepClone(defaultBid); + bid.params.bidfloor = 0.5; + + let bidRequests = [bid]; + let bidderRequest = {bids: bidRequests, refererInfo: refererInfo}; + + let [request] = spec.buildRequests(bidRequests, bidderRequest); + + let data = JSON.parse(request.data); + assert.deepEqual(data, { + id: bid.transactionId, + site: { + id: bid.params.publisher_id, + publisher: {id: bid.params.publisher_id}, + ref: encodeURIComponent(refererInfo.referer), + page: encodeURIComponent(refererInfo.referer), + }, + device: { + ua: navigator.userAgent, + dnt: dnt, + js: 1, + language: language, + }, + imp: [{ + tagid: bid.params.placement_id, + secure: secure, + bidfloor: bid.params.bidfloor, + banner: {w: 300, h: 250}, + }], + }); + + assert.deepEqual(request, { + method: 'POST', + url: requestUrl, + data: '{"id":"d45dd707-a418-42ec-b8a7-b70a6c6fab0b","site":{"page":"https%3A%2F%2Fwww.prebid.org","ref":"https%3A%2F%2Fwww.prebid.org","id":"pub123","publisher":{"id":"pub123"}},"device":{"ua":"' + navigator.userAgent + '","js":1,"dnt":' + dnt + ',"language":"' + language + '"},"imp":[{"tagid":"202","secure":1,"bidfloor":0.5,"banner":{"w":300,"h":250}}]}', + }); + }); + + it('multiple sizes', function () { + let bid = utils.deepClone(defaultBid); + bid.mediaTypes = { + banner: { + sizes: [[300, 600], [300, 250]], + } + }; + + let [request] = spec.buildRequests([bid]); + let data = JSON.parse(request.data); + assert.deepEqual(data.imp[0].banner, {w: 300, h: 600, format: [{w: 300, h: 250}]}); + }); + }); + + describe('interpretResponse() banner', function () { + it('not successfull response', function () { + assert.deepEqual(spec.interpretResponse(), []); + }); + + it('successfull response', function () { + let bid = { + price: 3, + w: 100, + id: '65599d0a-42d2-446a-9d39-6086c1433ffe', + burl: `${baseUrl}/burl/\${AUCTION_PRICE}`, + cid: '2_ssl', + h: 100, + cat: ['IAB1-1'], + crid: '2_ssl', + impid: '2b3c9d103723a7', + adid: '2_ssl', + adm: `` + }; + + let response = { + body: { + seatbid: [{ + bid: [bid] + }], + cur: 'USD', + id: '620190c2-7eef-42fa-91e2-f5c7fbc2bdd3' + } + }; + + let bids = spec.interpretResponse(response); + assert.deepEqual(bids, ([{ + ad: bid.adm, + cpm: bid.price, + creativeId: bid.adid, + currency: response.body.cur, + height: bid.h, + netRevenue: true, + burl: bid.burl, + requestId: bid.impid, + ttl: 300, + width: bid.w, + }])); + }); + }); + + describe('onBidWon()', function () { + beforeEach(function() { + sinon.stub(utils, 'triggerPixel'); + }); + afterEach(function() { + utils.triggerPixel.restore(); + }); + it('should expand price macros in burl', function () { + let burl = 'burl&s=${AUCTION_PRICE}'; + let bid = { + bidder: 'mediaforce', + width: 300, + height: 250, + adId: '330a22bdea4cac', + mediaType: 'banner', + cpm: 0.28, + ad: '...', + requestId: '418b37f85e772c', + adUnitCode: 'div-gpt-ad-1460505748561-0', + size: '350x250', + burl: burl, + adserverTargeting: { + hb_bidder: 'mediaforce', + hb_adid: '330a22bdea4cac', + hb_pb: '0.20', + hb_size: '350x250' + } + } + spec.onBidWon(bid); + assert.equal(bid.burl, 'burl&s=0.20'); + }); + }); +}); diff --git a/test/spec/modules/medianetAnalyticsAdapter_spec.js b/test/spec/modules/medianetAnalyticsAdapter_spec.js new file mode 100644 index 00000000000..dcec1050652 --- /dev/null +++ b/test/spec/modules/medianetAnalyticsAdapter_spec.js @@ -0,0 +1,185 @@ +import { expect } from 'chai'; +import medianetAnalytics from 'modules/medianetAnalyticsAdapter.js'; +import * as utils from 'src/utils.js'; +import CONSTANTS from 'src/constants.json'; +import events from 'src/events.js'; + +const { + EVENTS: { AUCTION_INIT, BID_REQUESTED, BID_RESPONSE, NO_BID, BID_TIMEOUT, AUCTION_END, SET_TARGETING, BID_WON } +} = CONSTANTS; + +const MOCK = { + AUCTION_INIT: {'auctionId': '8e0d5245-deb3-406c-96ca-9b609e077ff7', 'timestamp': 1584563605739}, + BID_REQUESTED: {'bidderCode': 'medianet', 'auctionId': '8e0d5245-deb3-406c-96ca-9b609e077ff7', 'bids': [{'bidder': 'medianet', 'params': {'cid': 'TEST_CID', 'crid': '451466393'}, 'mediaTypes': {'banner': {'sizes': [[300, 250]], 'ext': ['asdads']}}, 'adUnitCode': 'div-gpt-ad-1460505748561-0', 'sizes': [[300, 250]], 'bidId': '28248b0e6aece2', 'auctionId': '8e0d5245-deb3-406c-96ca-9b609e077ff7', 'src': 'client'}], 'auctionStart': 1584563605739, 'timeout': 6000, 'uspConsent': '1YY', 'start': 1584563605743}, + BID_RESPONSE: {'bidderCode': 'medianet', 'width': 300, 'height': 250, 'adId': '3e6e4bce5c8fb3', 'requestId': '28248b0e6aece2', 'mediaType': 'banner', 'source': 'client', 'ext': {'pvid': 123, 'crid': '321'}, 'no_bid': false, 'cpm': 2.299, 'ad': 'AD_CODE', 'ttl': 180, 'creativeId': 'Test1', 'netRevenue': true, 'currency': 'USD', 'dfp_id': 'div-gpt-ad-1460505748561-0', 'originalCpm': 1.1495, 'originalCurrency': 'USD', 'auctionId': '8e0d5245-deb3-406c-96ca-9b609e077ff7', 'responseTimestamp': 1584563606009, 'requestTimestamp': 1584563605743, 'bidder': 'medianet', 'adUnitCode': 'div-gpt-ad-1460505748561-0', 'timeToRespond': 266, 'pbLg': '2.00', 'pbMg': '2.20', 'pbHg': '2.29', 'pbAg': '2.25', 'pbDg': '2.29', 'pbCg': '2.00', 'size': '300x250', 'adserverTargeting': {'hb_bidder': 'medianet', 'hb_adid': '3e6e4bce5c8fb3', 'hb_pb': '2.00', 'hb_size': '300x250', 'hb_source': 'client', 'hb_format': 'banner', 'prebid_test': 1}, 'status': 'rendered', 'params': [{'cid': 'test123', 'crid': '451466393'}]}, + AUCTION_END: {'auctionId': '8e0d5245-deb3-406c-96ca-9b609e077ff7', 'auctionEnd': 1584563605739}, + SET_TARGETING: {'div-gpt-ad-1460505748561-0': {'prebid_test': '1', 'hb_format': 'banner', 'hb_source': 'client', 'hb_size': '300x250', 'hb_pb': '2.00', 'hb_adid': '3e6e4bce5c8fb3', 'hb_bidder': 'medianet', 'hb_format_medianet': 'banner', 'hb_source_medianet': 'client', 'hb_size_medianet': '300x250', 'hb_pb_medianet': '2.00', 'hb_adid_medianet': '3e6e4bce5c8fb3', 'hb_bidder_medianet': 'medianet'}}, + BID_WON: {'bidderCode': 'medianet', 'width': 300, 'height': 250, 'statusMessage': 'Bid available', 'adId': '3e6e4bce5c8fb3', 'requestId': '28248b0e6aece2', 'mediaType': 'banner', 'source': 'client', 'no_bid': false, 'cpm': 2.299, 'ad': 'AD_CODE', 'ttl': 180, 'creativeId': 'Test1', 'netRevenue': true, 'currency': 'USD', 'dfp_id': 'div-gpt-ad-1460505748561-0', 'originalCpm': 1.1495, 'originalCurrency': 'USD', 'auctionId': '8e0d5245-deb3-406c-96ca-9b609e077ff7', 'responseTimestamp': 1584563606009, 'requestTimestamp': 1584563605743, 'bidder': 'medianet', 'adUnitCode': 'div-gpt-ad-1460505748561-0', 'timeToRespond': 266, 'pbLg': '2.00', 'pbMg': '2.20', 'pbHg': '2.29', 'pbAg': '2.25', 'pbDg': '2.29', 'pbCg': '2.00', 'size': '300x250', 'adserverTargeting': {'hb_bidder': 'medianet', 'hb_adid': '3e6e4bce5c8fb3', 'hb_pb': '2.00', 'hb_size': '300x250', 'hb_source': 'client', 'hb_format': 'banner', 'prebid_test': 1}, 'status': 'rendered', 'params': [{'cid': 'test123', 'crid': '451466393'}]}, + NO_BID: {'bidder': 'medianet', 'params': {'cid': 'test123', 'crid': '451466393', 'site': {}}, 'mediaTypes': {'banner': {'sizes': [[300, 250]], 'ext': ['asdads']}}, 'adUnitCode': 'div-gpt-ad-1460505748561-0', 'transactionId': '303fa0c6-682f-4aea-8e4a-dc68f0d5c7d5', 'sizes': [[300, 250], [300, 600]], 'bidId': '28248b0e6aece2', 'bidderRequestId': '13fccf3809fe43', 'auctionId': '8e0d5245-deb3-406c-96ca-9b609e077ff7', 'src': 'client'}, + BID_TIMEOUT: [{'bidId': '28248b0e6aece2', 'bidder': 'medianet', 'adUnitCode': 'div-gpt-ad-1460505748561-0', 'auctionId': '8e0d5245-deb3-406c-96ca-9b609e077ff7', 'params': [{'cid': 'test123', 'crid': '451466393', 'site': {}}, {'cid': '8CUX0H51P', 'crid': '451466393', 'site': {}}], 'timeout': 6}] +} + +function performStandardAuctionWithWinner() { + events.emit(AUCTION_INIT, MOCK.AUCTION_INIT); + events.emit(BID_REQUESTED, MOCK.BID_REQUESTED); + events.emit(BID_RESPONSE, MOCK.BID_RESPONSE); + events.emit(AUCTION_END, MOCK.AUCTION_END); + events.emit(SET_TARGETING, MOCK.SET_TARGETING); + events.emit(BID_WON, MOCK.BID_WON); +} + +function performStandardAuctionWithNoBid() { + events.emit(AUCTION_INIT, MOCK.AUCTION_INIT); + events.emit(BID_REQUESTED, MOCK.BID_REQUESTED); + events.emit(NO_BID, MOCK.NO_BID); + events.emit(AUCTION_END, MOCK.AUCTION_END); + events.emit(SET_TARGETING, MOCK.SET_TARGETING); +} + +function performStandardAuctionWithTimeout() { + 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); + events.emit(SET_TARGETING, MOCK.SET_TARGETING); +} + +function getQueryData(url) { + const queryArgs = url.split('?')[1].split('&'); + return queryArgs.reduce((data, arg) => { + const [key, val] = arg.split('='); + if (data[key] !== undefined) { + if (!Array.isArray(data[key])) { + data[key] = [data[key]]; + } + data[key].push(val); + } else { + data[key] = val; + } + return data; + }, {}); +} + +describe('Media.net Analytics Adapter', function() { + let sandbox; + let CUSTOMER_ID = 'test123'; + let VALID_CONFIGURATION = { + options: { + cid: CUSTOMER_ID + } + } + beforeEach(function () { + sandbox = sinon.sandbox.create(); + }); + + afterEach(function () { + sandbox.restore(); + }); + + describe('Configuration', function() { + it('should log error if publisher id is not passed', function() { + sandbox.stub(utils, 'logError'); + + medianetAnalytics.enableAnalytics(); + expect( + utils.logError.calledWith( + 'Media.net Analytics adapter: cid is required.' + ) + ).to.be.true; + }); + + it('should not log error if valid config is passed', function() { + sandbox.stub(utils, 'logError'); + + medianetAnalytics.enableAnalytics(VALID_CONFIGURATION); + expect(utils.logError.called).to.equal(false); + medianetAnalytics.disableAnalytics(); + }); + }); + + describe('Events', function() { + beforeEach(function () { + medianetAnalytics.enableAnalytics({ + options: { + cid: 'test123' + } + }); + }); + afterEach(function () { + medianetAnalytics.disableAnalytics(); + }); + + it('should not log if only Auction Init', function() { + medianetAnalytics.clearlogsQueue(); + medianetAnalytics.track({ AUCTION_INIT }) + expect(medianetAnalytics.getlogsQueue().length).to.equal(0); + }); + + it('should have winner log in standard auction', function() { + medianetAnalytics.clearlogsQueue(); + performStandardAuctionWithWinner(); + let winnerLog = medianetAnalytics.getlogsQueue().map((log) => getQueryData(log)).filter((log) => log.winner); + medianetAnalytics.clearlogsQueue(); + + expect(winnerLog.length).to.equal(1); + }); + + it('should have correct values in winner log', function() { + medianetAnalytics.clearlogsQueue(); + performStandardAuctionWithWinner(); + let winnerLog = medianetAnalytics.getlogsQueue().map((log) => getQueryData(log)).filter((log) => log.winner); + medianetAnalytics.clearlogsQueue(); + + expect(winnerLog[0]).to.include({ + winner: '1', + pvnm: 'medianet', + curr: 'USD', + src: 'client', + size: '300x250', + mtype: 'banner', + cid: 'test123', + lper: '1', + ogbdp: '1.1495', + flt: '1', + supcrid: 'div-gpt-ad-1460505748561-0', + mpvid: '123' + }); + }); + + it('should have no bid status', function() { + medianetAnalytics.clearlogsQueue(); + performStandardAuctionWithNoBid(); + let noBidLog = medianetAnalytics.getlogsQueue().map((log) => getQueryData(log)); + noBidLog = noBidLog[0]; + + medianetAnalytics.clearlogsQueue(); + expect(noBidLog.pvnm).to.have.ordered.members(['-2', 'medianet']); + expect(noBidLog.iwb).to.have.ordered.members(['0', '0']); + expect(noBidLog.status).to.have.ordered.members(['1', '2']); + expect(noBidLog.src).to.have.ordered.members(['client', 'client']); + expect(noBidLog.curr).to.have.ordered.members(['', '']); + expect(noBidLog.mtype).to.have.ordered.members(['', '']); + expect(noBidLog.ogbdp).to.have.ordered.members(['', '']); + expect(noBidLog.mpvid).to.have.ordered.members(['', '']); + expect(noBidLog.crid).to.have.ordered.members(['', '451466393']); + }); + + it('should have timeout status', function() { + medianetAnalytics.clearlogsQueue(); + performStandardAuctionWithTimeout(); + let timeoutLog = medianetAnalytics.getlogsQueue().map((log) => getQueryData(log)); + timeoutLog = timeoutLog[0]; + + medianetAnalytics.clearlogsQueue(); + expect(timeoutLog.pvnm).to.have.ordered.members(['-2', 'medianet']); + expect(timeoutLog.iwb).to.have.ordered.members(['0', '0']); + expect(timeoutLog.status).to.have.ordered.members(['1', '3']); + expect(timeoutLog.src).to.have.ordered.members(['client', 'client']); + expect(timeoutLog.curr).to.have.ordered.members(['', '']); + expect(timeoutLog.mtype).to.have.ordered.members(['', '']); + expect(timeoutLog.ogbdp).to.have.ordered.members(['', '']); + expect(timeoutLog.mpvid).to.have.ordered.members(['', '']); + expect(timeoutLog.crid).to.have.ordered.members(['', '451466393']); + }); + }); +}); diff --git a/test/spec/modules/medianetBidAdapter_spec.js b/test/spec/modules/medianetBidAdapter_spec.js index afe91ce3166..22e2b1117d5 100644 --- a/test/spec/modules/medianetBidAdapter_spec.js +++ b/test/spec/modules/medianetBidAdapter_spec.js @@ -1,6 +1,6 @@ import {expect} from 'chai'; -import {spec} from 'modules/medianetBidAdapter'; -import { config } from 'src/config'; +import {spec} from 'modules/medianetBidAdapter.js'; +import { config } from 'src/config.js'; let VALID_BID_REQUEST = [{ 'bidder': 'medianet', @@ -87,6 +87,52 @@ let VALID_BID_REQUEST = [{ 'auctionId': 'aafabfd0-28c0-4ac0-aa09-99689e88b81d', 'bidRequestsCount': 1 }], + VALID_BID_REQUEST_WITH_USERID = [{ + 'bidder': 'medianet', + 'params': { + 'crid': 'crid', + 'cid': 'customer_id', + 'site': { + 'page': 'http://media.net/prebidtest', + 'domain': 'media.net', + 'ref': 'http://media.net/prebidtest', + 'isTop': true + } + }, + userId: { + britepoolid: '82efd5e1-816b-4f87-97f8-044f407e2911' + }, + 'adUnitCode': 'div-gpt-ad-1460505748561-0', + 'transactionId': '277b631f-92f5-4844-8b19-ea13c095d3f1', + 'mediaTypes': { + 'banner': { + 'sizes': [[300, 250]], + } + }, + 'bidId': '28f8f8130a583e', + 'bidderRequestId': '1e9b1f07797c1c', + 'auctionId': 'aafabfd0-28c0-4ac0-aa09-99689e88b81d', + 'bidRequestsCount': 1 + }, { + 'bidder': 'medianet', + 'params': { + 'crid': 'crid', + 'cid': 'customer_id', + 'site': { + 'page': 'http://media.net/prebidtest', + 'domain': 'media.net', + 'ref': 'http://media.net/prebidtest', + 'isTop': true + } + }, + 'adUnitCode': 'div-gpt-ad-1460505748561-123', + 'transactionId': 'c52a5c62-3c2b-4b90-9ff8-ec1487754822', + 'sizes': [[300, 251]], + 'bidId': '3f97ca71b1e5c2', + 'bidderRequestId': '1e9b1f07797c1c', + 'auctionId': 'aafabfd0-28c0-4ac0-aa09-99689e88b81d', + 'bidRequestsCount': 1 + }], VALID_BID_REQUEST_INVALID_BIDFLOOR = [{ 'bidder': 'medianet', @@ -503,6 +549,96 @@ let VALID_BID_REQUEST = [{ }], 'tmax': config.getConfig('bidderTimeout') }, + VALID_PAYLOAD_WITH_USERID = { + 'site': { + 'page': 'http://media.net/prebidtest', + 'domain': 'media.net', + 'ref': 'http://media.net/prebidtest', + 'isTop': true + }, + 'ext': { + 'customer_id': 'customer_id', + 'prebid_version': $$PREBID_GLOBAL$$.version, + 'gdpr_applies': false, + 'user_id': { + britepoolid: '82efd5e1-816b-4f87-97f8-044f407e2911' + }, + 'usp_applies': false, + 'screen': { + 'w': 1000, + 'h': 1000 + } + }, + 'id': 'aafabfd0-28c0-4ac0-aa09-99689e88b81d', + 'imp': [{ + 'id': '28f8f8130a583e', + 'tagid': 'crid', + 'ext': { + 'dfp_id': 'div-gpt-ad-1460505748561-0', + 'visibility': 1, + 'viewability': 1, + 'coordinates': { + 'top_left': { + x: 50, + y: 50 + }, + 'bottom_right': { + x: 100, + y: 100 + } + }, + 'display_count': 1 + }, + 'banner': [{ + 'w': 300, + 'h': 250 + }], + 'all': { + 'cid': 'customer_id', + 'crid': 'crid', + 'site': { + 'page': 'http://media.net/prebidtest', + 'domain': 'media.net', + 'ref': 'http://media.net/prebidtest', + 'isTop': true + } + } + }, { + 'id': '3f97ca71b1e5c2', + 'tagid': 'crid', + 'ext': { + 'dfp_id': 'div-gpt-ad-1460505748561-123', + 'visibility': 1, + 'viewability': 1, + 'coordinates': { + 'top_left': { + x: 50, + y: 50 + }, + 'bottom_right': { + x: 100, + y: 100 + } + }, + 'display_count': 1 + }, + 'banner': [{ + 'w': 300, + 'h': 251 + }], + 'all': { + 'cid': 'customer_id', + 'crid': 'crid', + 'site': { + 'page': 'http://media.net/prebidtest', + 'domain': 'media.net', + 'ref': 'http://media.net/prebidtest', + 'isTop': true + } + } + }], + 'tmax': config.getConfig('bidderTimeout') + }, VALID_PAYLOAD_WITH_CRID = { 'site': { 'page': 'http://media.net/prebidtest', @@ -1017,6 +1153,11 @@ describe('Media.net bid adapter', function () { expect(JSON.parse(bidreq.data)).to.deep.equal(VALID_PAYLOAD_WITH_CRID); }); + it('should have userid in bid request', function () { + let bidReq = spec.buildRequests(VALID_BID_REQUEST_WITH_USERID, VALID_AUCTIONDATA); + expect(JSON.parse(bidReq.data)).to.deep.equal(VALID_PAYLOAD_WITH_USERID); + }); + describe('build requests: when page meta-data is available', () => { beforeEach(() => { spec.clearMnData(); diff --git a/test/spec/modules/mgidBidAdapter_spec.js b/test/spec/modules/mgidBidAdapter_spec.js index 4a9f25a29a7..16f4f0b4607 100644 --- a/test/spec/modules/mgidBidAdapter_spec.js +++ b/test/spec/modules/mgidBidAdapter_spec.js @@ -1,7 +1,6 @@ import {assert, expect} from 'chai'; -import {spec} from 'modules/mgidBidAdapter'; -import * as utils from '../../../src/utils'; -import * as urlUtils from '../../../src/url'; +import {spec} from 'modules/mgidBidAdapter.js'; +import * as utils from '../../../src/utils.js'; describe('Mgid bid adapter', function () { let sandbox; @@ -256,7 +255,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 +266,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); @@ -361,7 +360,7 @@ describe('Mgid bid adapter', function () { }; let bidRequests = [bid]; const page = top.location.href; - const domain = urlUtils.parse(page).hostname; + const domain = utils.parseUrl(page).hostname; const request = spec.buildRequests(bidRequests); expect(request.url).deep.equal('https://prebid.mgid.com/prebid/1'); expect(request.method).deep.equal('POST'); @@ -409,7 +408,7 @@ describe('Mgid bid adapter', function () { let bidRequests = [bid]; const page = top.location.href; - const domain = urlUtils.parse(page).hostname; + const domain = utils.parseUrl(page).hostname; const request = spec.buildRequests(bidRequests); expect(request).to.be.a('object'); expect(request.url).deep.equal('https://prebid.mgid.com/prebid/1'); @@ -446,7 +445,7 @@ describe('Mgid bid adapter', function () { let bidRequests = [bid]; const page = top.location.href; - const domain = urlUtils.parse(page).hostname; + const domain = utils.parseUrl(page).hostname; const request = spec.buildRequests(bidRequests); expect(request).to.be.a('object'); expect(request.url).deep.equal('https://prebid.mgid.com/prebid/1'); @@ -482,7 +481,7 @@ describe('Mgid bid adapter', function () { let bidRequests = [bid]; const page = top.location.href; - const domain = urlUtils.parse(page).hostname; + const domain = utils.parseUrl(page).hostname; const request = spec.buildRequests(bidRequests); expect(request).to.be.a('object'); expect(request.url).deep.equal('https://prebid.mgid.com/prebid/1'); @@ -516,7 +515,7 @@ describe('Mgid bid adapter', function () { const request = spec.buildRequests(bidRequests); const page = top.location.href; - const domain = urlUtils.parse(page).hostname; + const domain = utils.parseUrl(page).hostname; expect(request.url).deep.equal('https://prebid.mgid.com/prebid/1'); expect(request.method).deep.equal('POST'); const data = JSON.parse(request.data); @@ -546,7 +545,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 +559,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 +571,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 +620,7 @@ describe('Mgid bid adapter', function () { 'title': 'title1' }, 'netRevenue': true, - 'nurl': 'http: nurl', + 'nurl': 'https nurl', 'requestId': '61e40632c53fc2', 'ttl': 300, 'width': 0 @@ -629,7 +628,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 +642,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, @@ -676,6 +675,12 @@ describe('Mgid bid adapter', function () { }); }); describe('on bidWon', function () { + beforeEach(function() { + sinon.stub(utils, 'triggerPixel'); + }); + afterEach(function() { + utils.triggerPixel.restore(); + }); it('should replace nurl and burl for native', function () { const burl = 'burl&s=${' + 'AUCTION_PRICE}'; const nurl = 'nurl&s=${' + 'AUCTION_PRICE}'; diff --git a/test/spec/modules/microadBidAdapter_spec.js b/test/spec/modules/microadBidAdapter_spec.js index 32bf15d53b9..8298e2bd559 100644 --- a/test/spec/modules/microadBidAdapter_spec.js +++ b/test/spec/modules/microadBidAdapter_spec.js @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import { spec } from 'modules/microadBidAdapter'; -import * as utils from 'src/utils'; +import { spec } from 'modules/microadBidAdapter.js'; +import * as utils from 'src/utils.js'; describe('microadBidAdapter', () => { const bidRequestTemplate = { @@ -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 90125f3e0d0..d3178d77a1a 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/mobsmartBidAdapter_spec.js b/test/spec/modules/mobsmartBidAdapter_spec.js index 7c1128276ab..b48878adff6 100644 --- a/test/spec/modules/mobsmartBidAdapter_spec.js +++ b/test/spec/modules/mobsmartBidAdapter_spec.js @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import { spec } from 'modules/mobsmartBidAdapter'; +import { spec } from 'modules/mobsmartBidAdapter.js'; describe('mobsmartBidAdapter', function () { describe('isBidRequestValid', function () { diff --git a/test/spec/modules/my6senseBidAdapter_spec.js b/test/spec/modules/my6senseBidAdapter_spec.js index d2c875dad07..5e51280d70b 100644 --- a/test/spec/modules/my6senseBidAdapter_spec.js +++ b/test/spec/modules/my6senseBidAdapter_spec.js @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import { spec } from 'modules/my6senseBidAdapter'; +import { spec } from 'modules/my6senseBidAdapter.js'; describe('My6sense Bid adapter test', function () { let bidRequests, serverResponses; diff --git a/test/spec/modules/mytargetBidAdapter_spec.js b/test/spec/modules/mytargetBidAdapter_spec.js index 4e478fee1f0..ea998303fe3 100644 --- a/test/spec/modules/mytargetBidAdapter_spec.js +++ b/test/spec/modules/mytargetBidAdapter_spec.js @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import { config } from 'src/config'; -import { spec } from 'modules/mytargetBidAdapter'; +import { config } from 'src/config.js'; +import { spec } from 'modules/mytargetBidAdapter.js'; describe('MyTarget Adapter', function() { describe('isBidRequestValid', function () { @@ -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/nafdigitalBidAdapter_spec.js b/test/spec/modules/nafdigitalBidAdapter_spec.js index ca486c632c7..c8ffb9fbbaf 100644 --- a/test/spec/modules/nafdigitalBidAdapter_spec.js +++ b/test/spec/modules/nafdigitalBidAdapter_spec.js @@ -1,7 +1,7 @@ import { expect } from 'chai'; -import * as utils from 'src/utils'; -import { spec } from 'modules/nafdigitalBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; +import * as utils from 'src/utils.js'; +import { spec } from 'modules/nafdigitalBidAdapter.js'; +import { newBidder } from 'src/adapters/bidderFactory.js'; const URL = 'https://nafdigitalbidder.com/hb'; diff --git a/test/spec/modules/nanointeractiveBidAdapter_spec.js b/test/spec/modules/nanointeractiveBidAdapter_spec.js index a357327fe96..715a26a4597 100644 --- a/test/spec/modules/nanointeractiveBidAdapter_spec.js +++ b/test/spec/modules/nanointeractiveBidAdapter_spec.js @@ -1,5 +1,5 @@ import {expect} from 'chai'; -import * as utils from 'src/utils'; +import * as utils from 'src/utils.js'; import * as sinon from 'sinon'; import { @@ -13,7 +13,7 @@ import { REF, spec, SUB_ID -} from '../../../modules/nanointeractiveBidAdapter'; +} from '../../../modules/nanointeractiveBidAdapter.js'; describe('nanointeractive adapter tests', function () { const SIZES_PARAM = 'sizes'; @@ -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 index dd6ed4686d1..4731b1a77d3 100644 --- a/test/spec/modules/nasmediaAdmixerBidAdapter_spec.js +++ b/test/spec/modules/nasmediaAdmixerBidAdapter_spec.js @@ -1,6 +1,6 @@ import {expect} from 'chai'; -import {spec} from 'modules/nasmediaAdmixerBidAdapter'; -import {newBidder} from 'src/adapters/bidderFactory'; +import {spec} from 'modules/nasmediaAdmixerBidAdapter.js'; +import {newBidder} from 'src/adapters/bidderFactory.js'; describe('nasmediaAdmixerBidAdapter', function () { const adapter = newBidder(spec); @@ -15,7 +15,8 @@ describe('nasmediaAdmixerBidAdapter', function () { const bid = { 'bidder': 'nasmediaAdmixer', 'params': { - 'ax_key': 'ax_key' + 'media_key': 'media_key', + 'adunit_id': 'adunit_id', }, 'adUnitCode': 'adunit-code', 'sizes': [[300, 250]], @@ -32,7 +33,8 @@ describe('nasmediaAdmixerBidAdapter', function () { const bid = Object.assign({}, bid); delete bid.params; bid.params = { - 'ax_key': 0 + 'media_key': '', + 'adunit_id': '', }; expect(spec.isBidRequestValid(bid)).to.equal(false); }); @@ -43,7 +45,8 @@ describe('nasmediaAdmixerBidAdapter', function () { { 'bidder': 'nasmediaAdmixer', 'params': { - 'ax_key': 'ajj7jba3' + 'media_key': '19038695', + 'adunit_id': '24190632', }, 'adUnitCode': 'adunit-code', 'sizes': [[300, 250]], @@ -52,9 +55,10 @@ describe('nasmediaAdmixerBidAdapter', function () { 'auctionId': '124cb070528662', } ]; + const bidderRequest = {refererInfo: {referer: 'https://example.com'}}; it('sends bid request to url via GET', function () { - const request = spec.buildRequests(bidRequests)[0]; + const request = spec.buildRequests(bidRequests, bidderRequest)[0]; expect(request.method).to.equal('GET'); expect(request.url).to.match(new RegExp(`https://adn.admixer.co.kr`)); }); @@ -63,7 +67,7 @@ describe('nasmediaAdmixerBidAdapter', function () { describe('interpretResponse', function () { const response = { 'body': { - 'bidder': 'nasmedia_admixer', + 'bidder': 'nasmediaAdmixer', 'req_id': '861a8e7952c82c', 'error_code': 0, 'error_msg': 'OK', @@ -85,7 +89,8 @@ describe('nasmediaAdmixerBidAdapter', function () { const bidRequest = { 'bidder': 'nasmediaAdmixer', 'params': { - 'ax_key': 'ajj7jba3', + 'media_key': '19038695', + 'adunit_id': '24190632', }, 'adUnitCode': 'adunit-code', 'sizes': [[300, 250], [320, 480]], @@ -124,7 +129,7 @@ describe('nasmediaAdmixerBidAdapter', function () { it('handles nobid responses', function () { response.body = { - 'bidder': 'nasmedia_admixer', + 'bidder': 'nasmediaAdmixer', 'req_id': '861a8e7952c82c', 'error_code': 0, 'error_msg': 'OK', diff --git a/test/spec/modules/newborntownWebBidAdapter_spec.js b/test/spec/modules/newborntownWebBidAdapter_spec.js index d7cf4a7dd95..3d3285328fe 100644 --- a/test/spec/modules/newborntownWebBidAdapter_spec.js +++ b/test/spec/modules/newborntownWebBidAdapter_spec.js @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import {spec} from 'modules/newborntownWebBidAdapter'; +import {spec} from 'modules/newborntownWebBidAdapter.js'; describe('NewborntownWebAdapter', function() { describe('isBidRequestValid', function () { let bid = { @@ -54,8 +54,8 @@ describe('NewborntownWebAdapter', function() { 'timeout': 9000, 'start': 1573123289383 } - const request = spec.buildRequests(bidderRequest['bids'], bidderRequest); it('Returns POST method', function () { + const request = spec.buildRequests(bidderRequest['bids'], bidderRequest); expect(request[0].method).to.equal('POST'); expect(request[0].url.indexOf('//us-west.solortb.com/adx/api/rtb?from=4') !== -1).to.equal(true); expect(request[0].data).to.exist; diff --git a/test/spec/modules/nextMillenniumBidAdapter_spec.js b/test/spec/modules/nextMillenniumBidAdapter_spec.js index 087f06d7e8e..f4d929b439c 100644 --- a/test/spec/modules/nextMillenniumBidAdapter_spec.js +++ b/test/spec/modules/nextMillenniumBidAdapter_spec.js @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import { spec } from 'modules/nextMillenniumBidAdapter'; +import { spec } from 'modules/nextMillenniumBidAdapter.js'; describe('nextMillenniumBidAdapterTests', function() { let bidRequestData = { diff --git a/test/spec/modules/nextrollBidAdapter_spec.js b/test/spec/modules/nextrollBidAdapter_spec.js new file mode 100644 index 00000000000..85cd45be1d0 --- /dev/null +++ b/test/spec/modules/nextrollBidAdapter_spec.js @@ -0,0 +1,183 @@ +import { expect } from 'chai'; +import { spec, tryGetPubtag, hasCCPAConsent } from 'modules/nextrollBidAdapter.js'; +import * as utils from 'src/utils.js'; + +describe('nextrollBidAdapter', function() { + let utilsMock; + beforeEach(function () { + utilsMock = sinon.mock(utils); + }); + + afterEach(function() { + global.NextRoll = undefined; + utilsMock.restore(); + }); + + let validBid = { + bidder: 'nextroll', + adUnitCode: 'adunit-code', + bidId: 'bid_id', + sizes: [[300, 200]], + params: { + bidfloor: 1, + zoneId: 'zone1', + publisherId: 'publisher_id' + } + }; + let bidWithoutValidId = { id: '' }; + let bidWithoutId = { params: { zoneId: 'zone1' } }; + + describe('isBidRequestValid', function() { + it('validates the bids correctly when the bid has an id', function() { + expect(spec.isBidRequestValid(validBid)).to.be.true; + }); + + it('validates the bids correcly when the bid does not have an id', function() { + expect(spec.isBidRequestValid(bidWithoutValidId)).to.be.false; + expect(spec.isBidRequestValid(bidWithoutId)).to.be.false; + }); + }); + + describe('buildRequests', function() { + it('builds the same amount of requests as valid requests it takes', function() { + expect(spec.buildRequests([validBid, validBid], {})).to.be.lengthOf(2); + }); + + it('doest not build a request when there is no valid requests', function () { + expect(spec.buildRequests([], {})).to.be.lengthOf(0); + }); + + it('builds a request with POST method', function () { + expect(spec.buildRequests([validBid], {})[0].method).to.equal('POST'); + }); + + it('builds a request with cookies method', function () { + expect(spec.buildRequests([validBid], {})[0].options.withCredentials).to.be.true; + }); + + it('builds a request with id, url and imp object', function () { + const request = spec.buildRequests([validBid], {})[0]; + expect(request.data.id).to.be.an('string').that.is.not.empty; + expect(request.url).to.equal('https://d.adroll.com/bid/prebid/'); + expect(request.data.imp).to.exist.and.to.be.a('object'); + }); + + it('builds a request with site and device information', function () { + const request = spec.buildRequests([validBid], {})[0]; + + expect(request.data.site).to.exist.and.to.be.a('object'); + expect(request.data.device).to.exist.and.to.be.a('object'); + }); + + it('builds a request with a complete imp object', function () { + const request = spec.buildRequests([validBid], {})[0]; + + expect(request.data.imp.id).to.equal('bid_id'); + expect(request.data.imp.bidfloor).to.be.equal(1); + expect(request.data.imp.banner).to.exist.and.to.be.a('object'); + expect(request.data.imp.ext.zone.id).to.be.equal('zone1'); + }); + + it('includes the sizes into the request correctly', function () { + const bannerObject = spec.buildRequests([validBid], {})[0].data.imp.banner; + + expect(bannerObject.format).to.exist; + expect(bannerObject.format).to.be.lengthOf(1); + expect(bannerObject.format[0].w).to.be.equal(300); + expect(bannerObject.format[0].h).to.be.equal(200); + }); + }); + + describe('interpretResponse', function () { + let responseBody = { + id: 'bidresponse_id', + dealId: 'deal_id', + seatbid: [ + { + bid: [ + { + price: 1.2, + w: 300, + h: 200, + crid: 'crid1', + adm: 'adm1' + } + ] + }, + { + bid: [ + { + price: 2.1, + w: 250, + h: 300, + crid: 'crid2', + adm: 'adm2' + } + ] + } + ] + }; + + it('returns an empty list when there is no response body', function () { + expect(spec.interpretResponse({}, {})).to.be.eql([]); + }); + + it('builds the same amount of responses as server responses it receives', function () { + expect(spec.interpretResponse({body: responseBody}, {})).to.be.lengthOf(2); + }); + + it('builds a response with the expected fields', function () { + const response = spec.interpretResponse({body: responseBody}, {})[0]; + + expect(response.requestId).to.be.equal('bidresponse_id'); + expect(response.cpm).to.be.equal(1.2); + expect(response.width).to.be.equal(300); + expect(response.height).to.be.equal(200); + expect(response.creativeId).to.be.equal('crid1'); + expect(response.dealId).to.be.equal('deal_id'); + expect(response.currency).to.be.equal('USD'); + expect(response.netRevenue).to.be.equal(true); + expect(response.ttl).to.be.equal(300); + expect(response.ad).to.be.equal('adm1'); + }); + }); + + describe('hasCCPAConsent', function() { + function ccpaRequest(consentString) { + return { + bidderCode: 'bidderX', + auctionId: 'e3a336ad-2222-4a1c-bbbb-ecc7c5554a34', + uspConsent: consentString + }; + } + + const noNoticeCases = ['1NYY', '1NNN', '1N--']; + noNoticeCases.forEach((ccpaString, index) => { + it(`No notice should indicate no consent (case ${index})`, function () { + const req = ccpaRequest(ccpaString); + expect(hasCCPAConsent(req)).to.be.false; + }); + }); + + const noConsentCases = ['1YYY', '1YYN', '1YY-']; + noConsentCases.forEach((ccpaString, index) => { + it(`Opt-Out should indicate no consent (case ${index})`, function () { + const req = ccpaRequest(ccpaString); + expect(hasCCPAConsent(req)).to.be.false; + }); + }); + + const consentCases = [undefined, '1YNY', '1YN-', '1Y--', '1---']; + consentCases.forEach((ccpaString, index) => { + it(`should indicate consent (case ${index})`, function() { + const req = ccpaRequest(ccpaString); + expect(hasCCPAConsent(req)).to.be.true; + }) + }); + + it('builds a request with no credentials', function () { + const noConsent = ccpaRequest('1YYY'); + expect(spec.buildRequests([validBid], noConsent)[0].options.withCredentials).to.be.false; + }); + }); +}); diff --git a/test/spec/modules/nobidBidAdapter_spec.js b/test/spec/modules/nobidBidAdapter_spec.js index 5134958d218..afbc46f862f 100644 --- a/test/spec/modules/nobidBidAdapter_spec.js +++ b/test/spec/modules/nobidBidAdapter_spec.js @@ -1,7 +1,8 @@ import { expect } from 'chai'; -import { spec } from 'modules/nobidBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; -import { deepClone } from 'src/utils'; +import * as utils from 'src/utils.js'; +import { spec } from 'modules/nobidBidAdapter.js'; +import { newBidder } from 'src/adapters/bidderFactory.js'; +import * as bidderFactory from 'src/adapters/bidderFactory.js'; describe('Nobid Adapter', function () { const adapter = newBidder(spec); @@ -49,6 +50,95 @@ describe('Nobid Adapter', function () { }); }); + describe('isVideoBidRequestValid', function () { + let bid = { + bidder: 'nobid', + params: { + siteId: 2, + video: { + skippable: true, + playback_methods: ['auto_play_sound_off'], + position: 'atf', + mimes: ['video/x-flv', 'video/mp4', 'video/x-ms-wmv', 'application/x-shockwave-flash', 'application/javascript'], + minduration: 1, + maxduration: 30, + frameworks: [1, 2, 3, 4, 5, 6] + } + }, + adUnitCode: 'adunit-code', + sizes: [[640, 480]], + bidId: '30b31c1838de1e', + bidderRequestId: '22edbae2733bf6', + auctionId: '1d1a030790a475', + mediaTypes: { + video: { + context: 'instream' + } + } + }; + const SITE_ID = 2; + const REFERER = 'https://www.examplereferer.com'; + let bidRequests = [ + { + bidder: 'nobid', + params: { + siteId: SITE_ID, + video: { + skippable: true, + playback_methods: ['auto_play_sound_off'], + position: 'atf', + mimes: ['video/x-flv', 'video/mp4', 'video/x-ms-wmv', 'application/x-shockwave-flash', 'application/javascript'], + minduration: 1, + maxduration: 30, + frameworks: [1, 2, 3, 4, 5, 6] + } + }, + adUnitCode: 'adunit-code', + bidId: '30b31c1838de1e', + bidderRequestId: '22edbae2733bf6', + auctionId: '1d1a030790a475', + mediaTypes: { + video: { + playerSize: [640, 480], + context: 'instream' + } + } + } + ]; + + let bidderRequest = { + refererInfo: {referer: REFERER} + } + + it('should add source and version to the tag', function () { + const request = spec.buildRequests(bidRequests, bidderRequest); + const payload = JSON.parse(request.data); + expect(payload.sid).to.equal(SITE_ID); + expect(payload.l).to.exist.and.to.equal(encodeURIComponent(REFERER)); + expect(payload.a).to.exist; + expect(payload.t).to.exist; + expect(payload.tz).to.exist; + expect(payload.r).to.exist; + expect(payload.lang).to.exist; + expect(payload.ref).to.exist; + expect(payload.a[0].d).to.exist.and.to.equal('adunit-code'); + expect(payload.a[0].at).to.exist.and.to.equal('video'); + expect(payload.a[0].params.video).to.exist; + expect(payload.a[0].params.video.skippable).to.exist.and.to.equal(true); + expect(payload.a[0].params.video.playback_methods).to.exist.and.to.contain('auto_play_sound_off'); + expect(payload.a[0].params.video.position).to.exist.and.to.equal('atf'); + expect(payload.a[0].params.video.mimes).to.exist.and.to.contain('video/x-flv'); + expect(payload.a[0].params.video.minduration).to.exist.and.to.equal(1); + expect(payload.a[0].params.video.maxduration).to.exist.and.to.equal(30); + expect(payload.a[0].params.video.frameworks[0]).to.exist.and.to.equal(1); + expect(payload.a[0].params.video.frameworks[1]).to.exist.and.to.equal(2); + expect(payload.a[0].params.video.frameworks[2]).to.exist.and.to.equal(3); + expect(payload.a[0].params.video.frameworks[3]).to.exist.and.to.equal(4); + expect(payload.a[0].params.video.frameworks[4]).to.exist.and.to.equal(5); + expect(payload.a[0].params.video.frameworks[5]).to.exist.and.to.equal(6); + }); + }); + describe('buildRequests', function () { const SITE_ID = 2; const REFERER = 'https://www.examplereferer.com'; @@ -70,7 +160,7 @@ describe('Nobid Adapter', function () { refererInfo: {referer: REFERER} } - it('should add source and verison to the tag', function () { + it('should add source and version to the tag', function () { const request = spec.buildRequests(bidRequests, bidderRequest); const payload = JSON.parse(request.data); expect(payload.sid).to.equal(SITE_ID); @@ -114,6 +204,39 @@ describe('Nobid Adapter', function () { }); }); + describe('buildRequestsRefreshCount', function () { + const SITE_ID = 2; + const REFERER = 'https://www.examplereferer.com'; + let bidRequests = [ + { + 'bidder': 'nobid', + 'params': { + 'siteId': SITE_ID + }, + 'adUnitCode': 'adunit-code', + 'sizes': [[300, 250]], + 'bidId': '30b31c1838de1e', + 'bidderRequestId': '22edbae2733bf6', + 'auctionId': '1d1a030790a475', + } + ]; + + let bidderRequest = { + refererInfo: {referer: REFERER} + } + + it('should refreshCount = 4', function () { + nobid.refreshLimit = 2; + nobid.refreshCount = 0; + spec.buildRequests(bidRequests, bidderRequest); + spec.buildRequests(bidRequests, bidderRequest); + spec.buildRequests(bidRequests, bidderRequest); + const request = spec.buildRequests(bidRequests, bidderRequest); + expect(nobid.refreshCount).to.equal(3); + expect(typeof request).to.equal('undefined'); + }); + }); + describe('interpretResponse', function () { const CREATIVE_ID_300x250 = 'CREATIVE-100'; const ADUNIT_300x250 = 'ADUNIT-1'; @@ -209,24 +332,166 @@ describe('Nobid Adapter', function () { }); }); + describe('interpretResponseWithRefreshLimit', function () { + const CREATIVE_ID_300x250 = 'CREATIVE-100'; + const ADUNIT_300x250 = 'ADUNIT-1'; + const ADMARKUP_300x250 = 'ADMARKUP-300x250'; + const PRICE_300x250 = 0.51; + const REQUEST_ID = '3db3773286ee59'; + const DEAL_ID = 'deal123'; + const REFRESH_LIMIT = 3; + let response = { + country: 'US', + ip: '68.83.15.75', + device: 'COMPUTER', + site: 2, + rlimit: REFRESH_LIMIT, + bids: [ + {id: 1, + bdrid: 101, + divid: ADUNIT_300x250, + dealid: DEAL_ID, + creativeid: CREATIVE_ID_300x250, + size: {'w': 300, 'h': 250}, + adm: ADMARKUP_300x250, + price: '' + PRICE_300x250 + } + ] + }; + + it('should refreshLimit be respected', function () { + let bidderRequest = { + bids: [{ + bidId: REQUEST_ID, + adUnitCode: ADUNIT_300x250 + }] + } + let result = spec.interpretResponse({ body: response }, {bidderRequest: bidderRequest}); + expect(nobid.refreshLimit).to.equal(REFRESH_LIMIT); + }); + }); + + describe('buildRequestsWithSupplyChain', function () { + const SITE_ID = 2; + let bidRequests = [ + { + bidder: 'nobid', + params: { + siteId: SITE_ID + }, + adUnitCode: 'adunit-code', + sizes: [[300, 250]], + bidId: '30b31c1838de1e', + bidderRequestId: '22edbae2733bf6', + auctionId: '1d1a030790a475', + coppa: true, + schain: { + validation: 'strict', + config: { + ver: '1.0', + complete: 1, + nodes: [ + { + asi: 'indirectseller.com', + sid: '00001', + name: 'name.com', + hp: 1 + } + ] + } + } + } + ]; + + it('schain exist', function () { + const request = spec.buildRequests(bidRequests); + const payload = JSON.parse(request.data); + expect(payload.schain).to.exist; + expect(payload.schain.validation).to.exist.and.to.equal('strict'); + expect(payload.schain.config.ver).to.exist.and.to.equal('1.0'); + expect(payload.schain.config.complete).to.exist.and.to.equal(1); + expect(payload.schain.config.nodes[0].asi).to.exist.and.to.equal('indirectseller.com'); + expect(payload.schain.config.nodes[0].sid).to.exist.and.to.equal('00001'); + expect(payload.schain.config.nodes[0].name).to.exist.and.to.equal('name.com'); + expect(payload.schain.config.nodes[0].hp).to.exist.and.to.equal(1); + expect(payload.coppa).to.exist; + expect(payload.coppa).to.exist.and.to.be.true; + expect(payload.a).to.be.lengthOf(1); + expect(request.method).to.equal('POST'); + }); + }); + + describe('interpretResponseWithUserLimit', function () { + const CREATIVE_ID_300x250 = 'CREATIVE-100'; + const ADUNIT_300x250 = 'ADUNIT-1'; + const ADMARKUP_300x250 = 'ADMARKUP-300x250'; + const PRICE_300x250 = 0.51; + const REQUEST_ID = '3db3773286ee59'; + const DEAL_ID = 'deal123'; + const ULIMIT = 1; + let response = { + country: 'US', + ip: '68.83.15.75', + device: 'COMPUTER', + site: 2, + ublock: ULIMIT, + bids: [ + {id: 1, + bdrid: 101, + divid: ADUNIT_300x250, + dealid: DEAL_ID, + creativeid: CREATIVE_ID_300x250, + size: {'w': 300, 'h': 250}, + adm: ADMARKUP_300x250, + price: '' + PRICE_300x250 + } + ] + }; + + it('should ULimit be respected', function () { + const bidderRequest = { + bids: [{ + bidId: REQUEST_ID, + adUnitCode: ADUNIT_300x250 + }] + } + const bidRequests = [ + { + 'bidder': 'nobid', + 'params': { + 'siteId': 2 + }, + 'adUnitCode': 'adunit-code', + 'sizes': [[300, 250]], + 'bidId': '30b31c1838de1e', + 'bidderRequestId': '22edbae2733bf6', + 'auctionId': '1d1a030790a475', + } + ]; + spec.interpretResponse({ body: response }, {bidderRequest: bidderRequest}); + let request = spec.buildRequests(bidRequests, bidderRequest); + expect(request).to.equal(undefined); + }); + }); + describe('getUserSyncs', function () { const GDPR_CONSENT_STRING = 'GDPR_CONSENT_STRING'; it('should get correct user sync when iframeEnabled', function () { let pixel = spec.getUserSyncs({iframeEnabled: true}) expect(pixel[0].type).to.equal('iframe'); - expect(pixel[0].url).to.equal('https://s3.amazonaws.com/nobid-public/sync.html'); + expect(pixel[0].url).to.equal('https://public.servenobid.com/sync.html'); }); it('should get correct user sync when iframeEnabled and pixelEnabled', function () { let pixel = spec.getUserSyncs({iframeEnabled: true, pixelEnabled: true}) expect(pixel[0].type).to.equal('iframe'); - expect(pixel[0].url).to.equal('https://s3.amazonaws.com/nobid-public/sync.html'); + expect(pixel[0].url).to.equal('https://public.servenobid.com/sync.html'); }); it('should get correct user sync when iframeEnabled', function () { let pixel = spec.getUserSyncs({iframeEnabled: true}, {}, {gdprApplies: true, consentString: GDPR_CONSENT_STRING}) expect(pixel[0].type).to.equal('iframe'); - expect(pixel[0].url).to.equal('https://s3.amazonaws.com/nobid-public/sync.html?gdpr=1&gdpr_consent=' + GDPR_CONSENT_STRING); + expect(pixel[0].url).to.equal('https://public.servenobid.com/sync.html?gdpr=1&gdpr_consent=' + GDPR_CONSENT_STRING); }); it('should get correct user sync when !iframeEnabled', function () { @@ -234,6 +499,13 @@ describe('Nobid Adapter', function () { expect(pixel.length).to.equal(0); }); + it('should get correct user sync when !iframeEnabled and pixelEnabled', function () { + let pixel = spec.getUserSyncs({iframeEnabled: false, pixelEnabled: true}, [{body: {syncs: ['sync_url']}}]) + expect(pixel.length).to.equal(1); + expect(pixel[0].type).to.equal('image'); + expect(pixel[0].url).to.equal('sync_url'); + }); + it('should get correct user sync when !iframeEnabled', function () { let pixel = spec.getUserSyncs({}) expect(pixel.length).to.equal(0); diff --git a/test/spec/modules/oneVideoBidAdapter_spec.js b/test/spec/modules/oneVideoBidAdapter_spec.js index a87bff33f4b..82546f2e96d 100644 --- a/test/spec/modules/oneVideoBidAdapter_spec.js +++ b/test/spec/modules/oneVideoBidAdapter_spec.js @@ -1,7 +1,7 @@ import { expect } from 'chai'; -import { spec } from 'modules/oneVideoBidAdapter'; -import * as utils from 'src/utils'; -import {config} from 'src/config'; +import { spec } from 'modules/oneVideoBidAdapter.js'; +import * as utils from 'src/utils.js'; +import {config} from 'src/config.js'; describe('OneVideoBidAdapter', function () { let bidRequest; @@ -136,12 +136,15 @@ describe('OneVideoBidAdapter', function () { const placement = bidRequest.params.video.placement; const rewarded = bidRequest.params.video.rewarded; const inventoryid = bidRequest.params.video.inventoryid; + const VERSION = '3.0.1'; 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); expect(data.imp[0].ext.rewarded).to.equal(rewarded); expect(data.imp[0].video.placement).to.equal(placement); expect(data.imp[0].ext.inventoryid).to.equal(inventoryid); + expect(data.imp[0].ext.prebidver).to.equal('$prebid.version$'); + expect(data.imp[0].ext.adapterver).to.equal(VERSION); }); it('must parse bid size from a nested array', function () { @@ -289,7 +292,9 @@ describe('OneVideoBidAdapter', function () { placement: 1, inventoryid: 123, sid: 134, - display: 1 + display: 1, + minduration: 10, + maxduration: 30 }, site: { id: 1, @@ -311,6 +316,8 @@ describe('OneVideoBidAdapter', function () { expect(data.imp[0].ext.inventoryid).to.equal(bidRequest.params.video.inventoryid); expect(data.imp[0].banner.mimes).to.equal(bidRequest.params.video.mimes); expect(data.imp[0].banner.placement).to.equal(bidRequest.params.video.placement); + expect(data.imp[0].banner.ext.minduration).to.equal(bidRequest.params.video.minduration); + expect(data.imp[0].banner.ext.maxduration).to.equal(bidRequest.params.video.maxduration); expect(data.site.id).to.equal(bidRequest.params.site.id); }); it('should send video object when display is other than 1', function () { @@ -381,7 +388,9 @@ describe('OneVideoBidAdapter', function () { delivery: [2], playbackmethod: [1, 5], placement: 123, - sid: 134 + sid: 134, + minduration: 10, + maxduration: 30 }, site: { id: 1, @@ -401,6 +410,24 @@ describe('OneVideoBidAdapter', function () { expect(data.imp[0].video.h).to.equal(height); expect(data.imp[0].video.pos).to.equal(position); expect(data.imp[0].video.mimes).to.equal(bidRequest.params.video.mimes); + expect(data.imp[0].video.protocols).to.equal(bidRequest.params.video.protocols); + expect(data.imp[0].video.linearity).to.equal(1); + expect(data.imp[0].video.maxduration).to.equal(bidRequest.params.video.maxduration); + expect(data.imp[0].video.minduration).to.equal(bidRequest.params.video.minduration); + }); + describe('getUserSyncs', function () { + const GDPR_CONSENT_STRING = 'GDPR_CONSENT_STRING'; + + it('should get correct user sync when iframeEnabled', function () { + let pixel = spec.getUserSyncs({pixelEnabled: true}, {}, {gdprApplies: true, consentString: GDPR_CONSENT_STRING}) + expect(pixel[2].type).to.equal('image'); + expect(pixel[2].url).to.equal('https://sync-tm.everesttech.net/upi/pid/m7y5t93k?gdpr=1&gdpr_consent=' + GDPR_CONSENT_STRING + '&redir=https%3A%2F%2Fpixel.advertising.com%2Fups%2F55986%2Fsync%3Fuid%3D%24%7BUSER_ID%7D%26_origin%3D0&gdpr=1&gdpr_consent=' + encodeURI(GDPR_CONSENT_STRING)); + }); + + it('should default to gdprApplies=0 when consentData is undefined', function () { + let pixel = spec.getUserSyncs({pixelEnabled: true}, {}, undefined); + expect(pixel[2].url).to.equal('https://sync-tm.everesttech.net/upi/pid/m7y5t93k?gdpr=0&gdpr_consent=&redir=https%3A%2F%2Fpixel.advertising.com%2Fups%2F55986%2Fsync%3Fuid%3D%24%7BUSER_ID%7D%26_origin%3D0&gdpr=0&gdpr_consent='); + }); }); }); }); diff --git a/test/spec/modules/oneplanetonlyBidAdapter_spec.js b/test/spec/modules/oneplanetonlyBidAdapter_spec.js deleted file mode 100644 index fbcec66ef51..00000000000 --- 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/onetagBidAdapter_spec.js b/test/spec/modules/onetagBidAdapter_spec.js index 93284566069..2b31c875502 100644 --- a/test/spec/modules/onetagBidAdapter_spec.js +++ b/test/spec/modules/onetagBidAdapter_spec.js @@ -1,40 +1,117 @@ -import { spec } from 'modules/onetagBidAdapter'; +import { spec, isValid, hasTypeVideo } from 'modules/onetagBidAdapter.js'; import { expect } from 'chai'; +import { BANNER, VIDEO } from 'src/mediaTypes.js'; describe('onetag', function () { - let bid = { - 'bidder': 'onetag', - 'params': { - 'pubId': '386276e072', - }, - 'adUnitCode': 'adunit-code', - 'sizes': [[300, 250]], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - 'transactionId': 'qwerty123' - }; + function createBid() { + return { + 'bidder': 'onetag', + 'params': { + 'pubId': '386276e072', + }, + 'adUnitCode': 'adunit-code', + 'bidId': '30b31c1838de1e', + 'bidderRequestId': '22edbae2733bf6', + 'auctionId': '1d1a030790a475', + 'transactionId': 'qwerty123' + }; + } + + function createBannerBid(bidRequest) { + const bid = bidRequest || createBid(); + bid.mediaTypes = bid.mediaTypes || {}; + bid.mediaTypes.banner = { + sizes: [[300, 250]] + }; + return bid; + } + + function createVideoBid(bidRequest) { + const bid = bidRequest || createBid(); + bid.mediaTypes = bid.mediaTypes || {}; + bid.mediaTypes.video = { + context: 'instream', + mimes: ['video/mp4', 'video/webm', 'application/javascript', 'video/ogg'], + playerSize: [640, 480] + }; + return bid; + } + + function createWrongVideoOutstreamBid(bidRequest) { + const bid = bidRequest || createBid(); + bid.mediaTypes = bid.mediaTypes || {}; + bid.mediaTypes.video = { + context: 'outstream', + mimes: ['video/mp4', 'video/webm', 'application/javascript', 'video/ogg'], + playerSize: [640, 480] + }; + return bid; + } + + function createMultiFormatBid() { + return createVideoBid(createBannerBid()); + } + + const bannerBid = createBannerBid(); + const videoBid = createVideoBid(); + const outstreamVideoBid = createWrongVideoOutstreamBid(); describe('isBidRequestValid', function () { it('Should return true when required params are found', function () { - expect(spec.isBidRequestValid(bid)).to.be.true; + expect(spec.isBidRequestValid(bannerBid)).to.be.true; }); it('Should return false when pubId is not a string', function () { - bid.params.pubId = 30; - expect(spec.isBidRequestValid(bid)).to.be.false; + bannerBid.params.pubId = 30; + expect(spec.isBidRequestValid(bannerBid)).to.be.false; }); it('Should return false when pubId is undefined', function () { - bid.params.pubId = undefined; - expect(spec.isBidRequestValid(bid)).to.be.false; + bannerBid.params.pubId = undefined; + expect(spec.isBidRequestValid(bannerBid)).to.be.false; }); - it('Should return false when the sizes array is empty', function () { - bid.sizes = []; - expect(spec.isBidRequestValid(bid)).to.be.false; + describe('banner bidRequest', function () { + it('Should return false when the sizes array is empty', function () { + bannerBid.sizes = []; + expect(spec.isBidRequestValid(bannerBid)).to.be.false; + }); + }); + describe('video bidRequest', function () { + it('Should return false when the context is undefined', function () { + videoBid.mediaTypes.video.context = undefined; + expect(spec.isBidRequestValid(videoBid)).to.be.false; + }); + it('Should return false when the context is not instream or outstream', function () { + videoBid.mediaTypes.video.context = 'wrong'; + expect(spec.isBidRequestValid(videoBid)).to.be.false; + }); + it('Should return false when playerSize is undefined', function () { + const videoBid = createVideoBid(); + videoBid.mediaTypes.video.playerSize = undefined; + expect(spec.isBidRequestValid(videoBid)).to.be.false; + }); + it('Should return false when playerSize is not an array', function () { + const videoBid = createVideoBid(); + videoBid.mediaTypes.video.playerSize = 30; + expect(spec.isBidRequestValid(videoBid)).to.be.false; + }); + it('Should return false when playerSize is an empty array', function () { + const videoBid = createVideoBid(); + videoBid.mediaTypes.video.playerSize = []; + expect(spec.isBidRequestValid(videoBid)).to.be.false; + }); + it('Should return false when context is outstream but no renderer object is defined', function () { + expect(spec.isBidRequestValid(outstreamVideoBid)).to.be.false; + }); + }); + describe('multi format bidRequest', function () { + const multiFormatBid = createMultiFormatBid(); + it('Should return true when correct multi format bid is passed', function () { + expect(spec.isBidRequestValid(multiFormatBid)).to.be.true; + }); }); }); describe('buildRequests', function () { - let serverRequest = spec.buildRequests([bid]); + let serverRequest = spec.buildRequests([bannerBid, videoBid]); it('Creates a ServerRequest object with method, URL and data', function () { expect(serverRequest).to.exist; expect(serverRequest.method).to.exist; @@ -53,7 +130,7 @@ describe('onetag', function () { const data = JSON.parse(d); it('Should contains all keys', function () { expect(data).to.be.an('object'); - expect(data).to.have.all.keys('location', 'masked', 'referrer', 'sHeight', 'sWidth', 'timeOffset', 'date', 'wHeight', 'wWidth', 'oHeight', 'oWidth', 'aWidth', 'aHeight', 'sLeft', 'sTop', 'hLength', 'bids'); + expect(data).to.have.all.keys('location', 'masked', 'referrer', 'sHeight', 'sWidth', 'timeOffset', 'date', 'wHeight', 'wWidth', 'oHeight', 'oWidth', 'aWidth', 'aHeight', 'sLeft', 'sTop', 'hLength', 'bids', 'docHidden', 'xOffset', 'yOffset'); expect(data.location).to.be.a('string'); expect(data.masked).to.be.a('number'); expect(data.referrer).to.be.a('string'); @@ -75,23 +152,23 @@ describe('onetag', function () { const bids = data['bids']; for (let i = 0; i < bids.length; i++) { const bid = bids[i]; - expect(bid).to.have.all.keys('adUnitCode', 'auctionId', 'bidId', 'bidderRequestId', 'pubId', 'transactionId', 'sizes'); + if (hasTypeVideo(bid)) { + expect(bid).to.have.all.keys('adUnitCode', 'auctionId', 'bidId', 'bidderRequestId', 'pubId', 'transactionId', 'context', 'mimes', 'playerSize', 'protocols', 'maxDuration', 'api', 'type'); + } else if (isValid(BANNER, bid)) { + expect(bid).to.have.all.keys('adUnitCode', 'auctionId', 'bidId', 'bidderRequestId', 'pubId', 'transactionId', 'sizes', 'type'); + } expect(bid.bidId).to.be.a('string'); expect(bid.pubId).to.be.a('string'); } }); - } catch (e) { - console.log('Error while parsing'); - } + } catch (e) {} it('Returns empty data if no valid requests are passed', function () { serverRequest = spec.buildRequests([]); let dataString = serverRequest.data; try { let dataObj = JSON.parse(dataString); expect(dataObj.bids).to.be.an('array').that.is.empty; - } catch (e) { - console.log('Error while parsing'); - } + } catch (e) {} }); it('should send GDPR consent data', function () { let consentString = 'consentString'; @@ -105,7 +182,7 @@ describe('onetag', function () { gdprApplies: true } }; - let serverRequest = spec.buildRequests([bid], bidderRequest); + let serverRequest = spec.buildRequests([bannerBid], bidderRequest); const payload = JSON.parse(serverRequest.data); expect(payload).to.exist; @@ -113,35 +190,78 @@ describe('onetag', function () { expect(payload.gdprConsent.consentString).to.exist.and.to.equal(consentString); expect(payload.gdprConsent.consentRequired).to.exist.and.to.be.true; }); + it('should send us privacy string', function () { + let consentString = 'us_foo'; + let bidderRequest = { + 'bidderCode': 'onetag', + 'auctionId': '1d1a030790a475', + 'bidderRequestId': '22edbae2733bf6', + 'timeout': 3000, + 'uspConsent': consentString + }; + let serverRequest = spec.buildRequests([bannerBid], bidderRequest); + const payload = JSON.parse(serverRequest.data); + + expect(payload.usPrivacy).to.exist; + expect(payload.usPrivacy).to.exist.and.to.equal(consentString); + }); }); describe('interpretResponse', function () { - const resObject = { - body: { - nobid: false, - bids: [{ - ad: '
Advertising
', - cpm: 13, - width: 300, - height: 250, - creativeId: '1820', - dealId: 'dishfo', - currency: 'USD', - requestId: 'sdiceobxcw' - }] + function getBannerRes() { + return { + ad: '
Advertising
', + cpm: 13, + width: 300, + height: 250, + creativeId: '1820', + dealId: 'dishfo', + currency: 'USD', + requestId: 'sdiceobxcw', + mediaType: BANNER } - }; + } + function getVideoRes() { + return { + ad: '', + cpm: 13, + width: 300, + height: 250, + creativeId: '1820', + dealId: 'dishfo', + currency: 'USD', + requestId: 'sdiceobxcw', + mediaType: VIDEO + } + } + function getBannerAdnVideoRes() { + return { + body: { + nobid: false, + bids: [getBannerRes(), getVideoRes()] + } + }; + } + const responseObj = getBannerAdnVideoRes(); it('Returns an array of valid server responses if response object is valid', function () { - const serverResponses = spec.interpretResponse(resObject); + const serverResponses = spec.interpretResponse(responseObj); 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', 'dealId'); + if (dataItem.mediaType === VIDEO) { + expect(dataItem).to.have.all.keys('requestId', 'cpm', 'width', 'height', 'vastXml', 'ttl', 'creativeId', 'netRevenue', 'currency', 'mediaType', 'dealId'); + } else if (dataItem.mediaType === BANNER) { + expect(dataItem).to.have.all.keys('requestId', 'cpm', 'width', 'height', 'ad', 'ttl', 'creativeId', 'netRevenue', 'currency', 'mediaType', 'dealId'); + } 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'); + if (dataItem.mediaType === VIDEO) { + expect(dataItem.vastXml).to.be.a('string'); + } else if (dataItem.mediaType === BANNER) { + 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'); @@ -204,5 +324,12 @@ describe('onetag', function () { expect(syncs[0].url).to.include(sync_endpoint); expect(syncs[0].url).to.not.match(/(?:[?&](?:gdpr_consent=([^&]*)|gdpr=([^&]*)))+$/); }); + it('Should send us privacy string', function () { + let usConsentString = 'us_foo'; + const syncs = spec.getUserSyncs({ iframeEnabled: true }, {}, {}, usConsentString); + expect(syncs[0].type).to.equal('iframe'); + expect(syncs[0].url).to.include(sync_endpoint); + expect(syncs[0].url).to.match(/(?:[?&](?:us_privacy=us_foo(?:[&][^&]*)*))+$/); + }); }); }); diff --git a/test/spec/modules/open8BidAdapter_spec.js b/test/spec/modules/open8BidAdapter_spec.js index e26811ed71c..506742bef9e 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'; +import { spec } from 'modules/open8BidAdapter.js'; +import { newBidder } from 'src/adapters/bidderFactory.js'; -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 88ab3c4c580..805435abf80 100644 --- a/test/spec/modules/openxAnalyticsAdapter_spec.js +++ b/test/spec/modules/openxAnalyticsAdapter_spec.js @@ -1,9 +1,10 @@ import { expect } from 'chai'; -import openxAdapter from 'modules/openxAnalyticsAdapter'; -import { config } from 'src/config'; -import events from 'src/events'; +import openxAdapter from 'modules/openxAnalyticsAdapter.js'; +import { config } from 'src/config.js'; +import events from 'src/events.js'; import CONSTANTS from 'src/constants.json'; -import * as utils from 'src/utils'; +import * as utils from 'src/utils.js'; +import { server } from 'test/mocks/xhr.js'; const { EVENTS: { AUCTION_INIT, BID_REQUESTED, BID_RESPONSE, BID_TIMEOUT, BID_WON } @@ -152,12 +153,7 @@ describe('openx analytics adapter', function() { }, {}); } - let xhr; - let requests; - before(function() { - xhr = sinon.useFakeXMLHttpRequest(); - xhr.onCreate = request => requests.push(request); sinon.stub(events, 'getEvents').returns([]); openxAdapter.enableAnalytics({ options: { @@ -167,13 +163,11 @@ describe('openx analytics adapter', function() { }); after(function() { - xhr.restore(); events.getEvents.restore(); openxAdapter.disableAnalytics(); }); beforeEach(function() { - requests = []; openxAdapter.reset(); }); @@ -185,7 +179,7 @@ describe('openx analytics adapter', function() { [BID_REQUESTED, bidRequestedOpenX] ]); - expect(requests.length).to.equal(0); + expect(server.requests.length).to.equal(0); }); it('should send 1 request to the right endpoint', function() { @@ -195,10 +189,11 @@ describe('openx analytics adapter', function() { [BID_RESPONSE, bidResponseOpenX] ]); - expect(requests.length).to.equal(1); + expect(server.requests.length).to.equal(1); - const endpoint = requests[0].url.split('?')[0]; - expect(endpoint).to.equal('http://ads.openx.net/w/1.0/pban'); + const endpoint = server.requests[0].url.split('?')[0]; + // note IE11 returns the default secure port, so we look for this alternate value as well in these tests + expect(endpoint).to.be.oneOf(['https://ads.openx.net/w/1.0/pban', 'https://ads.openx.net:443/w/1.0/pban']); }); describe('hb.ct, hb.rid, dddid, hb.asiid, hb.pubid', function() { @@ -209,7 +204,7 @@ describe('openx analytics adapter', function() { [BID_RESPONSE, bidResponseOpenX] ]); - const queryData = getQueryData(requests[0].url); + const queryData = getQueryData(server.requests[0].url); expect(queryData).to.include({ 'hb.ct': String(bidRequestedOpenX.auctionStart), 'hb.rid': auctionInit.auctionId, @@ -235,7 +230,7 @@ describe('openx analytics adapter', function() { config.getConfig.restore(); - const queryData = getQueryData(requests[0].url); + const queryData = getQueryData(server.requests[0].url); expect(queryData).to.include({ 'hb.cur': 'bitcoin' }); @@ -248,7 +243,7 @@ describe('openx analytics adapter', function() { [BID_RESPONSE, bidResponseOpenX] ]); - const queryData = getQueryData(requests[0].url); + const queryData = getQueryData(server.requests[0].url); expect(queryData).to.not.have.key('hb.cur'); }); }); @@ -275,7 +270,7 @@ describe('openx analytics adapter', function() { window.top.performance = originalPerf; Date.now.restore(); - const queryData = getQueryData(requests[0].url); + const queryData = getQueryData(server.requests[0].url); expect(queryData).to.include({ 'hb.dcl': String(timing.domContentLoadedEventEnd - timing.fetchStart), 'hb.dl': String(timing.loadEventEnd - timing.fetchStart), @@ -296,7 +291,7 @@ describe('openx analytics adapter', function() { window.top.performance = originalPerf; - const queryData = getQueryData(requests[0].url); + const queryData = getQueryData(server.requests[0].url); expect(queryData).to.not.have.keys( 'hb.dcl', 'hb.dl', @@ -316,7 +311,7 @@ describe('openx analytics adapter', function() { [BID_RESPONSE, bidResponseCloseX] ]); - const queryData = getQueryData(requests[0].url); + const queryData = getQueryData(server.requests[0].url); expect(queryData).to.include({ ts: bidResponseOpenX.ts, auid: bidRequestedOpenX.bids[0].params.unit @@ -331,7 +326,7 @@ describe('openx analytics adapter', function() { [BID_RESPONSE, bidResponseCloseX] ]); - const queryData = getQueryData(requests[0].url); + const queryData = getQueryData(server.requests[0].url); expect(queryData).to.include({ auid: bidRequestedOpenX.bids[0].params.unit }); @@ -345,7 +340,7 @@ describe('openx analytics adapter', function() { [BID_RESPONSE, bidResponseCloseX] ]); - const queryData = getQueryData(requests[0].url); + const queryData = getQueryData(server.requests[0].url); expect(queryData).to.not.have.keys('auid', 'ts'); }); }); @@ -360,7 +355,7 @@ describe('openx analytics adapter', function() { [BID_RESPONSE, bidResponseCloseX] ]); - const queryData = getQueryData(requests[0].url); + const queryData = getQueryData(server.requests[0].url); const auctionStart = bidRequestedOpenX.auctionStart; expect(queryData).to.include({ 'hb.exn': [ @@ -393,7 +388,7 @@ describe('openx analytics adapter', function() { [BID_TIMEOUT, bidTimeoutOpenX] ]); - const queryData = getQueryData(requests[0].url); + const queryData = getQueryData(server.requests[0].url); const auctionStart = bidRequestedOpenX.auctionStart; expect(queryData).to.include({ 'hb.exn': [ @@ -424,7 +419,7 @@ describe('openx analytics adapter', function() { [BID_WON, bidWonOpenX] ]); - const queryData = getQueryData(requests[0].url); + const queryData = getQueryData(server.requests[0].url); expect(queryData).to.include({ 'hb.we': '0', 'hb.g1': 'false' @@ -438,7 +433,7 @@ describe('openx analytics adapter', function() { [BID_RESPONSE, bidResponseOpenX] ]); - const queryData = getQueryData(requests[0].url); + const queryData = getQueryData(server.requests[0].url); expect(queryData).to.include({ 'hb.we': '-1', 'hb.g1': 'true' diff --git a/test/spec/modules/openxBidAdapter_spec.js b/test/spec/modules/openxBidAdapter_spec.js index 353c3342627..49584ea8b43 100644 --- a/test/spec/modules/openxBidAdapter_spec.js +++ b/test/spec/modules/openxBidAdapter_spec.js @@ -1,9 +1,9 @@ import {expect} from 'chai'; -import {spec, resetBoPixel} from 'modules/openxBidAdapter'; -import {newBidder} from 'src/adapters/bidderFactory'; -import {userSync} from 'src/userSync'; -import {config} from 'src/config'; -import * as utils from 'src/utils'; +import {spec, USER_ID_CODE_TO_QUERY_ARG} from 'modules/openxBidAdapter.js'; +import {newBidder} from 'src/adapters/bidderFactory.js'; +import {userSync} from 'src/userSync.js'; +import {config} from 'src/config.js'; +import * as utils from 'src/utils.js'; const URLBASE = '/w/1.0/arj'; const URLBASEVIDEO = '/v/1.0/avjp'; @@ -599,6 +599,44 @@ describe('OpenxAdapter', function () { config.getConfig.restore(); }); + describe('when us_privacy applies', function () { + beforeEach(function () { + bidderRequest = { + uspConsent: '1YYN', + refererInfo: {} + }; + + sinon.stub(config, 'getConfig').callsFake((key) => { + return utils.deepAccess(mockConfig, key); + }); + }); + + it('should send a signal to specify that GDPR applies to this request', function () { + const request = spec.buildRequests(bidRequests, bidderRequest); + expect(request[0].data.us_privacy).to.equal('1YYN'); + expect(request[1].data.us_privacy).to.equal('1YYN'); + }); + }); + + describe('when us_privacy does not applies', function () { + beforeEach(function () { + bidderRequest = { + refererInfo: {} + }; + + sinon.stub(config, 'getConfig').callsFake((key) => { + return utils.deepAccess(mockConfig, key); + }); + }); + + it('should not send the consent string, when consent string is undefined', function () { + delete bidderRequest.uspConsent; + const request = spec.buildRequests(bidRequests, bidderRequest); + expect(request[0].data).to.not.have.property('us_privacy'); + expect(request[1].data).to.not.have.property('us_privacy'); + }); + }); + describe('when GDPR applies', function () { beforeEach(function () { bidderRequest = { @@ -988,120 +1026,66 @@ describe('OpenxAdapter', function () { }); describe('when there are userid providers', function () { - describe('with publisher common id', function () { - it('should not send a pubcid query param when there is no crumbs.pubcid and no userId.pubcid defined in the bid requests', function () { - const request = spec.buildRequests(bidRequestsWithMediaTypes, mockBidderRequest); - expect(request[0].data).to.not.have.any.keys('pubcid'); - }); - - it('should send a pubcid query param when crumbs.pubcid is defined in the bid requests', function () { - const bidRequestsWithPubcid = [{ - bidder: 'openx', - params: { - unit: '11', - delDomain: 'test-del-domain' - }, - crumbs: { - pubcid: 'c4a4c843-2368-4b5e-b3b1-6ee4702b9ad6' - }, - adUnitCode: 'adunit-code', - mediaTypes: { - banner: { - sizes: [[300, 250], [300, 600]] - } - }, - bidId: 'test-bid-id-1', - bidderRequestId: 'test-bid-request-1', - auctionId: 'test-auction-1' - }]; - const request = spec.buildRequests(bidRequestsWithPubcid, mockBidderRequest); - expect(request[0].data.pubcid).to.equal('c4a4c843-2368-4b5e-b3b1-6ee4702b9ad6'); - }); - - it('should send a pubcid query param when userId.pubcid is defined in the bid requests', function () { - const bidRequestsWithPubcid = [{ - bidder: 'openx', - params: { - unit: '11', - delDomain: 'test-del-domain' - }, - userId: { - pubcid: 'c1a4c843-2368-4b5e-b3b1-6ee4702b9ad6' - }, - adUnitCode: 'adunit-code', - mediaTypes: { - banner: { - sizes: [[300, 250], [300, 600]] - } - }, - bidId: 'test-bid-id-1', - bidderRequestId: 'test-bid-request-1', - auctionId: 'test-auction-1' - }]; - const request = spec.buildRequests(bidRequestsWithPubcid, mockBidderRequest); - expect(request[0].data.pubcid).to.equal('c1a4c843-2368-4b5e-b3b1-6ee4702b9ad6'); - }); - }); - - describe('with the trade desk unified id', function () { - it('should not send a tdid query param when there is no userId.tdid defined in the bid requests', function () { - const request = spec.buildRequests(bidRequestsWithMediaTypes, mockBidderRequest); - expect(request[0].data).to.not.have.any.keys('ttduuid'); - }); + const EXAMPLE_DATA_BY_ATTR = { + britepoolid: '1111-britepoolid', + criteoId: '1111-criteoId', + digitrustid: {data: {id: 'DTID', keyv: 4, privacy: {optout: false}, producer: 'ABC', version: 2}}, + id5id: '1111-id5id', + idl_env: '1111-idl_env', + lipb: {lipbid: '1111-lipb'}, + netId: 'fH5A3n2O8_CZZyPoJVD-eabc6ECb7jhxCicsds7qSg', + parrableid: 'eidVersion.encryptionKeyReference.encryptedValue', + pubcid: '1111-pubcid', + tdid: '1111-tdid', + }; - it('should send a tdid query param when userId.tdid is defined in the bid requests', function () { - const bidRequestsWithTdid = [{ - bidder: 'openx', - params: { - unit: '11', - delDomain: 'test-del-domain' - }, - userId: { - tdid: '00000000-aaaa-1111-bbbb-222222222222' - }, - adUnitCode: 'adunit-code', - mediaTypes: { - banner: { - sizes: [[300, 250], [300, 600]] - } - }, - bidId: 'test-bid-id-1', - bidderRequestId: 'test-bid-request-1', - auctionId: 'test-auction-1' - }]; - const request = spec.buildRequests(bidRequestsWithTdid, mockBidderRequest); - expect(request[0].data.ttduuid).to.equal('00000000-aaaa-1111-bbbb-222222222222'); - }); - }); + // generates the same set of tests for each id provider + utils._each(USER_ID_CODE_TO_QUERY_ARG, (userIdQueryArg, userIdProviderKey) => { + describe(`with userId attribute: ${userIdProviderKey}`, function () { + it(`should not send a ${userIdQueryArg} query param when there is no userId.${userIdProviderKey} defined in the bid requests`, function () { + const request = spec.buildRequests(bidRequestsWithMediaTypes, mockBidderRequest); + expect(request[0].data).to.not.have.any.keys(userIdQueryArg); + }); - describe('with the liveRamp identity link envelope', function () { - it('should not send a tdid query param when there is no userId.lre defined in the bid requests', function () { - const request = spec.buildRequests(bidRequestsWithMediaTypes, mockBidderRequest); - expect(request[0].data).to.not.have.any.keys('lre'); - }); + it(`should send a ${userIdQueryArg} query param when userId.${userIdProviderKey} is defined in the bid requests`, function () { + const bidRequestsWithUserId = [{ + bidder: 'openx', + params: { + unit: '11', + delDomain: 'test-del-domain' + }, + userId: { + }, + adUnitCode: 'adunit-code', + mediaTypes: { + banner: { + sizes: [[300, 250], [300, 600]] + } + }, + bidId: 'test-bid-id-1', + bidderRequestId: 'test-bid-request-1', + auctionId: 'test-auction-1' + }]; + // enrich bid request with userId key/value + bidRequestsWithUserId[0].userId[userIdProviderKey] = EXAMPLE_DATA_BY_ATTR[userIdProviderKey]; + + const request = spec.buildRequests(bidRequestsWithUserId, mockBidderRequest); + + let userIdValue; + // handle cases where userId key refers to an object + switch (userIdProviderKey) { + case 'digitrustid': + userIdValue = EXAMPLE_DATA_BY_ATTR.digitrustid.data.id; + break; + case 'lipb': + userIdValue = EXAMPLE_DATA_BY_ATTR.lipb.lipbid; + break; + default: + userIdValue = EXAMPLE_DATA_BY_ATTR[userIdProviderKey]; + } - it('should send a lre query param when userId.lre is defined in the bid requests', function () { - const bidRequestsWithLiveRampEnvelope = [{ - bidder: 'openx', - params: { - unit: '11', - delDomain: 'test-del-domain' - }, - userId: { - idl_env: '00000000-aaaa-1111-bbbb-222222222222' - }, - adUnitCode: 'adunit-code', - mediaTypes: { - banner: { - sizes: [[300, 250], [300, 600]] - } - }, - bidId: 'test-bid-id-1', - bidderRequestId: 'test-bid-request-1', - auctionId: 'test-auction-1' - }]; - const request = spec.buildRequests(bidRequestsWithLiveRampEnvelope, mockBidderRequest); - expect(request[0].data.lre).to.equal('00000000-aaaa-1111-bbbb-222222222222'); + expect(request[0].data[USER_ID_CODE_TO_QUERY_ARG[userIdProviderKey]]).to.equal(userIdValue); + }); }); }); }); @@ -1726,6 +1710,85 @@ describe('OpenxAdapter', function () { ); expect(syncs).to.deep.equal([{type: 'iframe', url: syncUrl}]); }); + + describe('when gdpr applies', function () { + let gdprConsent; + let gdprPixelUrl; + beforeEach(() => { + gdprConsent = { + consentString: 'test-gdpr-consent-string', + gdprApplies: true + }; + + gdprPixelUrl = 'https://testpixels.net?gdpr=1&gdpr_consent=gdpr-pixel-consent' + }); + + it('when there is a response, it should have the gdpr query params', () => { + let [{url}] = spec.getUserSyncs( + {iframeEnabled: true, pixelEnabled: true}, + [{body: {ads: {pixels: gdprPixelUrl}}}], + gdprConsent + ); + + expect(url).to.have.string('gdpr_consent=gdpr-pixel-consent'); + expect(url).to.have.string('gdpr=1'); + }); + + it('when there is no response, it should append gdpr query params', () => { + let [{url}] = spec.getUserSyncs( + {iframeEnabled: true, pixelEnabled: true}, + [], + gdprConsent + ); + expect(url).to.have.string('gdpr_consent=test-gdpr-consent-string'); + expect(url).to.have.string('gdpr=1'); + }); + + it('should not send signals if no consent object is available', function () { + let [{url}] = spec.getUserSyncs( + {iframeEnabled: true, pixelEnabled: true}, + [], + ); + expect(url).to.not.have.string('gdpr_consent='); + expect(url).to.not.have.string('gdpr='); + }); + }); + + describe('when ccpa applies', function () { + let usPrivacyConsent; + let uspPixelUrl; + beforeEach(() => { + usPrivacyConsent = 'TEST'; + uspPixelUrl = 'https://testpixels.net?us_privacy=AAAA' + }); + it('when there is a response, it should send the us privacy string from the response, ', () => { + let [{url}] = spec.getUserSyncs( + {iframeEnabled: true, pixelEnabled: true}, + [{body: {ads: {pixels: uspPixelUrl}}}], + undefined, + usPrivacyConsent + ); + + expect(url).to.have.string('us_privacy=AAAA'); + }); + it('when there is no response, it send have the us privacy string', () => { + let [{url}] = spec.getUserSyncs( + {iframeEnabled: true, pixelEnabled: true}, + [], + undefined, + usPrivacyConsent + ); + expect(url).to.have.string(`us_privacy=${usPrivacyConsent}`); + }); + + it('should not send signals if no consent string is available', function () { + let [{url}] = spec.getUserSyncs( + {iframeEnabled: true, pixelEnabled: true}, + [], + ); + expect(url).to.not.have.string('us_privacy='); + }); + }); }); /** diff --git a/test/spec/modules/openxoutstreamBidAdapter_spec.js b/test/spec/modules/openxoutstreamBidAdapter_spec.js deleted file mode 100644 index 9d2b7082a22..00000000000 --- a/test/spec/modules/openxoutstreamBidAdapter_spec.js +++ /dev/null @@ -1,237 +0,0 @@ -import {expect} from 'chai'; -import {spec} from 'modules/openxoutstreamBidAdapter'; -import {newBidder} from 'src/adapters/bidderFactory'; - -describe('OpenXOutstreamAdapter', function () { - const adapter = newBidder(spec); - const URLBASE = '/v/1.0/avjp'; - const BIDDER = 'openxoutstream'; - const div = document.createElement('div'); - const PLACEMENT_ID = '1986307928000988495'; - const YM_SCRIPT = `!function(e,t){if(void 0===t._ym){var a=Math.round(5*Math.random()/3)+'';t._ym='';var m=e.createElement('script');m.type='text/javascript',m.async=!0,m.src='//static.yieldmo.com/ym.'+a+'.js',(e.getElementsByTagName('head')[0]||e.getElementsByTagName('body')[0]).appendChild(m)}else t._ym instanceof String||void 0===t._ym.chkPls||t._ym.chkPls()}(document,window);`; - const PUBLISHER_ID = '1986307525700126029'; - const CR_ID = '2052941939925262540'; - const AD_ID = '1991358644725162800'; - - describe('isBidRequestValid', function () { - describe('when request is for a banner ad', function () { - let bannerBid; - beforeEach(function () { - bannerBid = { - bidder: BIDDER, - params: {}, - adUnitCode: 'adunit-code', - mediaTypes: {banner: {}}, - sizes: [[300, 250], [300, 600]], - bidId: '30b31c1838de1e', - bidderRequestId: '22edbae2733bf6', - auctionId: '1d1a030790a475' - }; - }); - it('should return false when there is no delivery domain', function () { - bannerBid.params = {'unit': '12345678'}; - expect(spec.isBidRequestValid(bannerBid)).to.equal(false); - }); - - describe('when there is a delivery domain', function () { - beforeEach(function () { - bannerBid.params = {delDomain: 'test-delivery-domain'} - }); - - it('should return false if there is no adunit id and sizes are defined', function () { - bannerBid.mediaTypes.banner.sizes = [720, 90]; - expect(spec.isBidRequestValid(bannerBid)).to.equal(false); - }); - - it('should return true if there is delivery domain and unit', function () { - bannerBid.params.unit = '12345678'; - expect(spec.isBidRequestValid(bannerBid)).to.equal(true); - }); - it('should return false if there is unit but no delivery domain', function () { - bannerBid.params = {unit: '12345678'}; - expect(spec.isBidRequestValid(bannerBid)).to.equal(false); - }); - it('shoud return false if there is no delivery domain and no unit', function () { - bannerBid.params = {}; - expect(spec.isBidRequestValid(bannerBid)).to.equal(false); - }) - }); - }); - }); - - describe('buildRequests for banner ads', function () { - const bidRequestsWithMediaType = [{ - 'bidder': BIDDER, - 'params': { - 'unit': '12345678', - 'delDomain': 'test-del-domain' - }, - 'adUnitCode': 'adunit-code', - 'mediaType': 'banner', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475' - }]; - - const mockBidderRequest = {refererInfo: {}}; - - it('should send bid request to openx url via GET, with mediaType specified as banner', function () { - const request = spec.buildRequests(bidRequestsWithMediaType, mockBidderRequest); - const params = bidRequestsWithMediaType[0].params; - expect(request[0].url).to.equal(`https://` + params.delDomain + URLBASE); - expect(request[0].method).to.equal('GET'); - }); - - it('should send ad unit ids, height, and width when any are defined', function () { - const bidRequestsWithUnitIds = [{ - 'bidder': BIDDER, - 'params': { - 'unit': '540141567', - 'height': '200', - 'width': '250', - 'delDomain': 'test-del-domain' - }, - 'adUnitCode': 'adunit-code', - mediaTypes: { - banner: { - sizes: [[728, 90]] - } - }, - 'bidId': 'test-bid-id-2', - 'bidderRequestId': 'test-bid-request-2', - 'auctionId': 'test-auction-2' - }, { - 'bidder': BIDDER, - 'params': { - 'delDomain': 'test-del-domain' - }, - 'adUnitCode': 'adunit-code', - mediaTypes: { - banner: { - sizes: [[300, 250], [300, 600]] - } - }, - 'bidId': 'test-bid-id-1', - 'bidderRequestId': 'test-bid-request-1', - 'auctionId': 'test-auction-1' - }]; - const request = spec.buildRequests(bidRequestsWithUnitIds, mockBidderRequest); - expect(request[0].data.auid).to.equal(`${bidRequestsWithUnitIds[0].params.unit}`); - expect(request[0].data.vht).to.not.equal(`${bidRequestsWithUnitIds[0].params.height}`); - expect(request[0].data.vwd).to.not.equal(`${bidRequestsWithUnitIds[0].params.width}`); - expect(request[0].data.vht).to.equal('184'); - expect(request[0].data.vwd).to.equal('414'); - expect(request[0].data.aus).to.equal('304x184%7C412x184%7C375x184%7C414x184'); - }); - - describe('interpretResponse', function () { - let serverResponse; - let serverRequest; - - beforeEach(function () { - serverResponse = { - body: { - width: 300, - height: 250, - pub_rev: 3000, - bidderCode: 'openxoutstream', - vastUrl: 'test.vast.url', - mediaType: 'banner', - adid: '9874652394875' - }, - header: 'header?', - }; - serverRequest = { - payload: { - bid: { - bidId: '2d36ac90d654af', - }, - } - }; - }); - - it('should correctly reorder the server response', function () { - const newResponse = spec.interpretResponse(serverResponse, serverRequest); - const openHtmlTag = ''; - const closeHtmlTag = ''; - const sdkScript = createSdkScript().outerHTML; - const placementDiv = createPlacementDiv(); - placementDiv.dataset.pId = PUBLISHER_ID; - const placementDivString = placementDiv.outerHTML; - const adResponse = getTemplateAdResponse(serverResponse.body.vastUrl, PLACEMENT_ID); - const adResponseString = JSON.stringify(adResponse); - const ymAdsScript = ''; - expect(newResponse.length).to.be.equal(1); - expect(newResponse[0]).to.deep.equal({ - requestId: '2d36ac90d654af', - bidderCode: 'openxoutstream', - vastUrl: 'test.vast.url', - mediaType: 'banner', - cpm: 3, - width: 300, - height: 250, - creativeId: '9874652394875', - currency: 'USD', - netRevenue: true, - ttl: 300, - ad: openHtmlTag + placementDivString + ymAdsScript + sdkScript + closeHtmlTag - }); - }); - - it('should not add responses if the cpm is 0 or null', function () { - serverResponse.body.pub_rev = 0; - let response = spec.interpretResponse(serverResponse, serverRequest); - expect(response).to.deep.equal([]); - - serverResponse.body.pub_rev = null; - response = spec.interpretResponse(serverResponse, serverRequest); - expect(response).to.deep.equal([]) - }); - }); - }) - - function createSdkScript() { - const script = document.createElement('script'); - script.innerHTML = YM_SCRIPT; - return script; - } - function createPlacementDiv() { - div.id = `ym_${PLACEMENT_ID}`; - div.classList.add('ym'); - div.dataset.lfId = CR_ID; - return div - } - const getTemplateAdResponse = (vastUrl) => { - return { - loader: 'openxoutstream', - availability_zone: '', - data: [ - { - ads: [ - { - actions: {}, - adv_id: AD_ID, - configurables: { - cta_button_copy: 'Learn More', - vast_click_tracking: 'true', - vast_url: vastUrl, - }, - cr_id: CR_ID, - } - ], - column_count: 1, - configs: { - allowable_height: '248', - header_copy: 'You May Like', - ping: 'true', - }, - creative_format_id: 40, - css: '', - placement_id: PLACEMENT_ID, - } - ], - nc: 0, - }; - }; -}); diff --git a/test/spec/modules/optimaticBidAdapter_spec.js b/test/spec/modules/optimaticBidAdapter_spec.js deleted file mode 100644 index 3dd7ca79cc7..00000000000 --- 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/optimeraBidAdapter_spec.js b/test/spec/modules/optimeraBidAdapter_spec.js index a0111ca9944..ada07fe25c2 100644 --- a/test/spec/modules/optimeraBidAdapter_spec.js +++ b/test/spec/modules/optimeraBidAdapter_spec.js @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import { spec } from 'modules/optimeraBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; +import { spec } from 'modules/optimeraBidAdapter.js'; +import { newBidder } from 'src/adapters/bidderFactory.js'; describe('OptimeraAdapter', function () { const adapter = newBidder(spec); diff --git a/test/spec/modules/orbidderBidAdapter_spec.js b/test/spec/modules/orbidderBidAdapter_spec.js index 1b76de9841a..c20f11da5b5 100644 --- a/test/spec/modules/orbidderBidAdapter_spec.js +++ b/test/spec/modules/orbidderBidAdapter_spec.js @@ -1,8 +1,8 @@ import {expect} from 'chai'; -import {spec} from 'modules/orbidderBidAdapter'; -import {newBidder} from 'src/adapters/bidderFactory'; -import openxAdapter from '../../../modules/openxAnalyticsAdapter'; -import {detectReferer} from 'src/refererDetection'; +import {spec} from 'modules/orbidderBidAdapter.js'; +import {newBidder} from 'src/adapters/bidderFactory.js'; +import openxAdapter from '../../../modules/openxAnalyticsAdapter.js'; +import {detectReferer} from 'src/refererDetection.js'; describe('orbidderBidAdapter', () => { const adapter = newBidder(spec); @@ -31,7 +31,7 @@ describe('orbidderBidAdapter', () => { return spec.buildRequests(buildRequest, { ...bidderRequest || {}, refererInfo: { - referer: 'http://localhost:9876/' + referer: 'https://localhost:9876/' } })[0]; }; @@ -96,10 +96,14 @@ describe('orbidderBidAdapter', () => { expect(request.url).to.equal(`${spec.orbidderHost}/bid`); }); + it('contains prebid version parameter', () => { + expect(request.data.v).to.equal($$PREBID_GLOBAL$$.version); + }); + 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/'); + // we add two, because we add referer information and version from bidderRequest object + expect(Object.keys(request.data).length).to.equal(Object.keys(defaultBidRequest).length + 2); + 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]); @@ -162,6 +166,7 @@ describe('orbidderBidAdapter', () => { spec.bidParams['123req456'] = {'accountId': '123acc456'}; let bidObjClone = deepClone(bidObj); + bidObjClone.v = $$PREBID_GLOBAL$$.version; bidObjClone.pageUrl = detectReferer(window)().referer; bidObjClone.params = [{'accountId': '123acc456'}]; diff --git a/test/spec/modules/orbitsoftBidAdapter_spec.js b/test/spec/modules/orbitsoftBidAdapter_spec.js deleted file mode 100644 index 18ba9a6e8f3..00000000000 --- 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/otmBidAdapter_spec.js b/test/spec/modules/otmBidAdapter_spec.js index f3a98d43e57..8ac01c1657e 100644 --- a/test/spec/modules/otmBidAdapter_spec.js +++ b/test/spec/modules/otmBidAdapter_spec.js @@ -1,5 +1,5 @@ import {expect} from 'chai'; -import {spec} from 'modules/otmBidAdapter'; +import {spec} from 'modules/otmBidAdapter.js'; describe('otmBidAdapterTests', function () { it('validate_pub_params', function () { diff --git a/test/spec/modules/outconBidAdapter_spec.js b/test/spec/modules/outconBidAdapter_spec.js index d9e763b9df9..81c3fdded62 100644 --- a/test/spec/modules/outconBidAdapter_spec.js +++ b/test/spec/modules/outconBidAdapter_spec.js @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import { spec } from '../../../modules/outconBidAdapter'; +import { spec } from '../../../modules/outconBidAdapter.js'; describe('outconBidAdapter', function () { describe('bidRequestValidity', function () { diff --git a/test/spec/modules/ozoneBidAdapter_spec.js b/test/spec/modules/ozoneBidAdapter_spec.js index a0b51ff7a9f..16ebb5c321b 100644 --- a/test/spec/modules/ozoneBidAdapter_spec.js +++ b/test/spec/modules/ozoneBidAdapter_spec.js @@ -1,7 +1,9 @@ import { expect } from 'chai'; -import { spec, getWidthAndHeightFromVideoObject, playerSizeIsNestedArray, defaultSize } from 'modules/ozoneBidAdapter'; -import { config } from 'src/config'; -import {Renderer} from '../../../src/Renderer'; +import { spec, getWidthAndHeightFromVideoObject, playerSizeIsNestedArray, defaultSize } from 'modules/ozoneBidAdapter.js'; +import { config } from 'src/config.js'; +import {Renderer} from '../../../src/Renderer.js'; +import {getGranularityKeyName, getGranularityObject} from '../../../modules/ozoneBidAdapter.js'; +import * as utils from '../../../src/utils.js'; const OZONEURI = 'https://elb.the-ozone-project.com/openrtb2/auction'; const BIDDER_CODE = 'ozone'; /* @@ -18,11 +20,26 @@ var validBidRequests = [ bidder: 'ozone', bidderRequestId: '1c1586b27a1b5c8', crumbs: {pubcid: '203a0692-f728-4856-87f6-9a25a6b63715'}, - params: { publisherId: '9876abcd12-3', customData: {'gender': 'bart', 'age': 'low'}, lotameData: {'Profile': {'tpid': 'c8ef27a0d4ba771a81159f0d2e792db4', 'Audiences': {'Audience': [{'id': '99999', 'abbr': 'sports'}, {'id': '88888', 'abbr': 'movie'}, {'id': '77777', 'abbr': 'blogger'}], 'ThirdPartyAudience': [{'id': '123', 'name': 'Automobiles'}, {'id': '456', 'name': 'Ages: 30-39'}]}}}, placementId: '1310000099', siteId: '1234567890', id: 'fea37168-78f1-4a23-a40e-88437a99377e', auctionId: '27dcb421-95c6-4024-a624-3c03816c5f99', imp: [ { id: '2899ec066a91ff8', tagid: 'undefined', secure: 1, banner: { format: [{ w: 300, h: 250 }, { w: 300, h: 600 }], h: 250, topframe: 1, w: 300 } } ] }, + params: { publisherId: '9876abcd12-3', customData: [{'settings': {}, 'targeting': {'gender': 'bart', 'age': 'low'}}], lotameData: {'Profile': {'tpid': 'c8ef27a0d4ba771a81159f0d2e792db4', 'Audiences': {'Audience': [{'id': '99999', 'abbr': 'sports'}, {'id': '88888', 'abbr': 'movie'}, {'id': '77777', 'abbr': 'blogger'}], 'ThirdPartyAudience': [{'id': '123', 'name': 'Automobiles'}, {'id': '456', 'name': 'Ages: 30-39'}]}}}, placementId: '1310000099', siteId: '1234567890', id: 'fea37168-78f1-4a23-a40e-88437a99377e', auctionId: '27dcb421-95c6-4024-a624-3c03816c5f99', imp: [ { id: '2899ec066a91ff8', tagid: 'undefined', secure: 1, banner: { format: [{ w: 300, h: 250 }, { w: 300, h: 600 }], h: 250, topframe: 1, w: 300 } } ] }, sizes: [[300, 250], [300, 600]], transactionId: '2e63c0ed-b10c-4008-aed5-84582cecfe87' } ]; +var validBidRequestsWithUserIdData = [ + { + adUnitCode: 'div-gpt-ad-1460505748561-0', + auctionId: '27dcb421-95c6-4024-a624-3c03816c5f99', + bidId: '2899ec066a91ff8', + bidRequestsCount: 1, + bidder: 'ozone', + bidderRequestId: '1c1586b27a1b5c8', + crumbs: {pubcid: '203a0692-f728-4856-87f6-9a25a6b63715'}, + params: { publisherId: '9876abcd12-3', customData: [{'settings': {}, 'targeting': {'gender': 'bart', 'age': 'low'}}], lotameData: {'Profile': {'tpid': 'c8ef27a0d4ba771a81159f0d2e792db4', 'Audiences': {'Audience': [{'id': '99999', 'abbr': 'sports'}, {'id': '88888', 'abbr': 'movie'}, {'id': '77777', 'abbr': 'blogger'}], 'ThirdPartyAudience': [{'id': '123', 'name': 'Automobiles'}, {'id': '456', 'name': 'Ages: 30-39'}]}}}, placementId: '1310000099', siteId: '1234567890', id: 'fea37168-78f1-4a23-a40e-88437a99377e', auctionId: '27dcb421-95c6-4024-a624-3c03816c5f99', imp: [ { id: '2899ec066a91ff8', tagid: 'undefined', secure: 1, banner: { format: [{ w: 300, h: 250 }, { w: 300, h: 600 }], h: 250, topframe: 1, w: 300 } } ] }, + sizes: [[300, 250], [300, 600]], + transactionId: '2e63c0ed-b10c-4008-aed5-84582cecfe87', + userId: {'pubcid': '12345678', 'id5id': 'ID5-someId', 'criteortus': {'ozone': {'userid': 'critId123'}}, 'idl_env': 'liverampId', 'lipb': {'lipbid': 'lipbidId123'}, 'parrableid': 'parrableid123'} + } +]; var validBidRequestsMinimal = [ { adUnitCode: 'div-gpt-ad-1460505748561-0', @@ -45,7 +62,7 @@ var validBidRequestsNoSizes = [ bidder: 'ozone', bidderRequestId: '1c1586b27a1b5c8', crumbs: {pubcid: '203a0692-f728-4856-87f6-9a25a6b63715'}, - params: { publisherId: '9876abcd12-3', customData: {'gender': 'bart', 'age': 'low'}, lotameData: {'Profile': {'tpid': 'c8ef27a0d4ba771a81159f0d2e792db4', 'Audiences': {'Audience': [{'id': '99999', 'abbr': 'sports'}, {'id': '88888', 'abbr': 'movie'}, {'id': '77777', 'abbr': 'blogger'}], 'ThirdPartyAudience': [{'id': '123', 'name': 'Automobiles'}, {'id': '456', 'name': 'Ages: 30-39'}]}}}, placementId: '1310000099', siteId: '1234567890', id: 'fea37168-78f1-4a23-a40e-88437a99377e', auctionId: '27dcb421-95c6-4024-a624-3c03816c5f99', imp: [ { id: '2899ec066a91ff8', tagid: 'undefined', secure: 1, banner: { format: [{ w: 300, h: 250 }, { w: 300, h: 600 }], h: 250, topframe: 1, w: 300 } } ] }, + params: { publisherId: '9876abcd12-3', customData: [{'settings': {}, 'targeting': {'gender': 'bart', 'age': 'low'}}], lotameData: {'Profile': {'tpid': 'c8ef27a0d4ba771a81159f0d2e792db4', 'Audiences': {'Audience': [{'id': '99999', 'abbr': 'sports'}, {'id': '88888', 'abbr': 'movie'}, {'id': '77777', 'abbr': 'blogger'}], 'ThirdPartyAudience': [{'id': '123', 'name': 'Automobiles'}, {'id': '456', 'name': 'Ages: 30-39'}]}}}, placementId: '1310000099', siteId: '1234567890', id: 'fea37168-78f1-4a23-a40e-88437a99377e', auctionId: '27dcb421-95c6-4024-a624-3c03816c5f99', imp: [ { id: '2899ec066a91ff8', tagid: 'undefined', secure: 1, banner: { format: [{ w: 300, h: 250 }, { w: 300, h: 600 }], h: 250, topframe: 1, w: 300 } } ] }, transactionId: '2e63c0ed-b10c-4008-aed5-84582cecfe87' } ]; @@ -59,7 +76,7 @@ var validBidRequestsWithBannerMediaType = [ bidder: 'ozone', bidderRequestId: '1c1586b27a1b5c8', crumbs: {pubcid: '203a0692-f728-4856-87f6-9a25a6b63715'}, - params: { publisherId: '9876abcd12-3', customData: {'gender': 'bart', 'age': 'low'}, lotameData: {'Profile': {'tpid': 'c8ef27a0d4ba771a81159f0d2e792db4', 'Audiences': {'Audience': [{'id': '99999', 'abbr': 'sports'}, {'id': '88888', 'abbr': 'movie'}, {'id': '77777', 'abbr': 'blogger'}], 'ThirdPartyAudience': [{'id': '123', 'name': 'Automobiles'}, {'id': '456', 'name': 'Ages: 30-39'}]}}}, placementId: '1310000099', siteId: '1234567890', id: 'fea37168-78f1-4a23-a40e-88437a99377e', auctionId: '27dcb421-95c6-4024-a624-3c03816c5f99', imp: [ { id: '2899ec066a91ff8', tagid: 'undefined', secure: 1, banner: { format: [{ w: 300, h: 250 }, { w: 300, h: 600 }], h: 250, topframe: 1, w: 300 } } ] }, + params: { publisherId: '9876abcd12-3', customData: [{'settings': {}, 'targeting': {'gender': 'bart', 'age': 'low'}}], lotameData: {'Profile': {'tpid': 'c8ef27a0d4ba771a81159f0d2e792db4', 'Audiences': {'Audience': [{'id': '99999', 'abbr': 'sports'}, {'id': '88888', 'abbr': 'movie'}, {'id': '77777', 'abbr': 'blogger'}], 'ThirdPartyAudience': [{'id': '123', 'name': 'Automobiles'}, {'id': '456', 'name': 'Ages: 30-39'}]}}}, placementId: '1310000099', siteId: '1234567890', id: 'fea37168-78f1-4a23-a40e-88437a99377e', auctionId: '27dcb421-95c6-4024-a624-3c03816c5f99', imp: [ { id: '2899ec066a91ff8', tagid: 'undefined', secure: 1, banner: { format: [{ w: 300, h: 250 }, { w: 300, h: 600 }], h: 250, topframe: 1, w: 300 } } ] }, mediaTypes: {banner: {sizes: [[300, 250], [300, 600]]}}, transactionId: '2e63c0ed-b10c-4008-aed5-84582cecfe87' } @@ -73,7 +90,7 @@ var validBidRequestsWithNonBannerMediaTypesAndValidOutstreamVideo = [ bidder: 'ozone', bidderRequestId: '1c1586b27a1b5c8', crumbs: {pubcid: '203a0692-f728-4856-87f6-9a25a6b63715'}, - params: { publisherId: '9876abcd12-3', customData: {'gender': 'bart', 'age': 'low'}, lotameData: {'Profile': {'tpid': 'c8ef27a0d4ba771a81159f0d2e792db4', 'Audiences': {'Audience': [{'id': '99999', 'abbr': 'sports'}, {'id': '88888', 'abbr': 'movie'}, {'id': '77777', 'abbr': 'blogger'}], 'ThirdPartyAudience': [{'id': '123', 'name': 'Automobiles'}, {'id': '456', 'name': 'Ages: 30-39'}]}}}, placementId: '1310000099', siteId: '1234567890', id: 'fea37168-78f1-4a23-a40e-88437a99377e', auctionId: '27dcb421-95c6-4024-a624-3c03816c5f99', imp: [ { id: '2899ec066a91ff8', tagid: 'undefined', secure: 1, video: {skippable: true, playback_method: ['auto_play_sound_off'], targetDiv: 'some-different-div-id-to-my-adunitcode'} } ] }, + params: { publisherId: '9876abcd12-3', customData: [{'settings': {}, 'targeting': {'gender': 'bart', 'age': 'low'}}], lotameData: {'Profile': {'tpid': 'c8ef27a0d4ba771a81159f0d2e792db4', 'Audiences': {'Audience': [{'id': '99999', 'abbr': 'sports'}, {'id': '88888', 'abbr': 'movie'}, {'id': '77777', 'abbr': 'blogger'}], 'ThirdPartyAudience': [{'id': '123', 'name': 'Automobiles'}, {'id': '456', 'name': 'Ages: 30-39'}]}}}, placementId: '1310000099', siteId: '1234567890', id: 'fea37168-78f1-4a23-a40e-88437a99377e', auctionId: '27dcb421-95c6-4024-a624-3c03816c5f99', imp: [ { id: '2899ec066a91ff8', tagid: 'undefined', secure: 1, video: {skippable: true, playback_method: ['auto_play_sound_off'], targetDiv: 'some-different-div-id-to-my-adunitcode'} } ] }, mediaTypes: {video: {mimes: ['video/mp4'], 'context': 'outstream', 'sizes': [640, 480]}, native: {info: 'dummy data'}}, transactionId: '2e63c0ed-b10c-4008-aed5-84582cecfe87' } @@ -92,7 +109,7 @@ var validBidderRequest = { bidder: 'ozone', bidderRequestId: '1c1586b27a1b5c8', crumbs: {pubcid: '203a0692-f728-4856-87f6-9a25a6b63715'}, - params: { publisherId: '9876abcd12-3', customData: {'gender': 'bart', 'age': 'low'}, lotameData: {'Profile': {'tpid': 'c8ef27a0d4ba771a81159f0d2e792db4', 'Audiences': {'Audience': [{'id': '99999', 'abbr': 'sports'}, {'id': '88888', 'abbr': 'movie'}, {'id': '77777', 'abbr': 'blogger'}], 'ThirdPartyAudience': [{'id': '123', 'name': 'Automobiles'}, {'id': '456', 'name': 'Ages: 30-39'}]}}}, placementId: '1310000099', siteId: '1234567890', id: 'fea37168-78f1-4a23-a40e-88437a99377e', auctionId: '27dcb421-95c6-4024-a624-3c03816c5f99', imp: [ { banner: { topframe: 1, w: 300, h: 250, format: [{ w: 300, h: 250 }, { w: 300, h: 600 }] }, id: '2899ec066a91ff8', secure: 1, tagid: 'undefined' } ] }, + params: { publisherId: '9876abcd12-3', customData: [{'settings': {}, 'targeting': {'gender': 'bart', 'age': 'low'}}], lotameData: {'Profile': {'tpid': 'c8ef27a0d4ba771a81159f0d2e792db4', 'Audiences': {'Audience': [{'id': '99999', 'abbr': 'sports'}, {'id': '88888', 'abbr': 'movie'}, {'id': '77777', 'abbr': 'blogger'}], 'ThirdPartyAudience': [{'id': '123', 'name': 'Automobiles'}, {'id': '456', 'name': 'Ages: 30-39'}]}}}, placementId: '1310000099', siteId: '1234567890', id: 'fea37168-78f1-4a23-a40e-88437a99377e', auctionId: '27dcb421-95c6-4024-a624-3c03816c5f99', imp: [ { banner: { topframe: 1, w: 300, h: 250, format: [{ w: 300, h: 250 }, { w: 300, h: 600 }] }, id: '2899ec066a91ff8', secure: 1, tagid: 'undefined' } ] }, sizes: [[300, 250], [300, 600]], transactionId: '2e63c0ed-b10c-4008-aed5-84582cecfe87' }], @@ -118,7 +135,7 @@ var bidderRequestWithFullGdpr = { bidder: 'ozone', bidderRequestId: '1c1586b27a1b5c8', crumbs: {pubcid: '203a0692-f728-4856-87f6-9a25a6b63715'}, - params: { publisherId: '9876abcd12-3', customData: {'gender': 'bart', 'age': 'low'}, lotameData: {'Profile': {'tpid': 'c8ef27a0d4ba771a81159f0d2e792db4', 'Audiences': {'Audience': [{'id': '99999', 'abbr': 'sports'}, {'id': '88888', 'abbr': 'movie'}, {'id': '77777', 'abbr': 'blogger'}], 'ThirdPartyAudience': [{'id': '123', 'name': 'Automobiles'}, {'id': '456', 'name': 'Ages: 30-39'}]}}}, placementId: '1310000099', siteId: '1234567890', id: 'fea37168-78f1-4a23-a40e-88437a99377e', auctionId: '27dcb421-95c6-4024-a624-3c03816c5f99', imp: [ { banner: { topframe: 1, w: 300, h: 250, format: [{ w: 300, h: 250 }, { w: 300, h: 600 }] }, id: '2899ec066a91ff8', secure: 1, tagid: 'undefined' } ] }, + params: { publisherId: '9876abcd12-3', customData: [{'settings': {}, 'targeting': {'gender': 'bart', 'age': 'low'}}], lotameData: {'Profile': {'tpid': 'c8ef27a0d4ba771a81159f0d2e792db4', 'Audiences': {'Audience': [{'id': '99999', 'abbr': 'sports'}, {'id': '88888', 'abbr': 'movie'}, {'id': '77777', 'abbr': 'blogger'}], 'ThirdPartyAudience': [{'id': '123', 'name': 'Automobiles'}, {'id': '456', 'name': 'Ages: 30-39'}]}}}, placementId: '1310000099', siteId: '1234567890', id: 'fea37168-78f1-4a23-a40e-88437a99377e', auctionId: '27dcb421-95c6-4024-a624-3c03816c5f99', imp: [ { banner: { topframe: 1, w: 300, h: 250, format: [{ w: 300, h: 250 }, { w: 300, h: 600 }] }, id: '2899ec066a91ff8', secure: 1, tagid: 'undefined' } ] }, sizes: [[300, 250], [300, 600]], transactionId: '2e63c0ed-b10c-4008-aed5-84582cecfe87' }], @@ -159,6 +176,70 @@ var bidderRequestWithFullGdpr = { }, }; +var gdpr1 = { + 'consentString': 'BOh7mtYOh7mtYAcABBENCU-AAAAncgPIXJiiAoao0PxBFkgCAC8ACIAAQAQQAAIAAAIAAAhBGAAAQAQAEQgAAAAAAABAAAAAAAAAAAAAAACAAAAAAAACgAAAAABAAAAQAAAAAAA', + 'vendorData': { + 'metadata': 'BOh7mtYOh7mtYAcABBENCU-AAAAncgPIXJiiAoao0PxBFkgCAC8ACIAAQAQQAAIAAAIAAAhBGAAAQAQAEQgAAAAAAABAAAAAAAAAAAAAAACAAAAAAAACgAAAAABAAAAQAAAAAAA', + 'gdprApplies': true, + 'hasGlobalScope': false, + 'cookieVersion': '1', + 'created': '2019-05-31T12:46:48.825', + 'lastUpdated': '2019-05-31T12:46:48.825', + 'cmpId': '28', + 'cmpVersion': '1', + 'consentLanguage': 'en', + 'consentScreen': '1', + 'vendorListVersion': 148, + 'maxVendorId': 631, + 'purposeConsents': { + '1': true, + '2': true, + '3': true, + '4': true, + '5': true + }, + 'vendorConsents': { + '468': true, + '522': true, + '524': true, /* 524 is ozone */ + '565': true, + '591': true + } + }, + 'gdprApplies': true +}; + +// simulating the Mirror +var bidderRequestWithPartialGdpr = { + auctionId: '27dcb421-95c6-4024-a624-3c03816c5f99', + auctionStart: 1536838908986, + bidderCode: 'ozone', + bidderRequestId: '1c1586b27a1b5c8', + bids: [{ + adUnitCode: 'div-gpt-ad-1460505748561-0', + auctionId: '27dcb421-95c6-4024-a624-3c03816c5f99', + bidId: '2899ec066a91ff8', + bidRequestsCount: 1, + bidder: 'ozone', + bidderRequestId: '1c1586b27a1b5c8', + crumbs: {pubcid: '203a0692-f728-4856-87f6-9a25a6b63715'}, + params: { publisherId: '9876abcd12-3', customData: [{'settings': {}, 'targeting': {'gender': 'bart', 'age': 'low'}}], lotameData: {'Profile': {'tpid': 'c8ef27a0d4ba771a81159f0d2e792db4', 'Audiences': {'Audience': [{'id': '99999', 'abbr': 'sports'}, {'id': '88888', 'abbr': 'movie'}, {'id': '77777', 'abbr': 'blogger'}], 'ThirdPartyAudience': [{'id': '123', 'name': 'Automobiles'}, {'id': '456', 'name': 'Ages: 30-39'}]}}}, placementId: '1310000099', siteId: '1234567890', id: 'fea37168-78f1-4a23-a40e-88437a99377e', auctionId: '27dcb421-95c6-4024-a624-3c03816c5f99', imp: [ { banner: { topframe: 1, w: 300, h: 250, format: [{ w: 300, h: 250 }, { w: 300, h: 600 }] }, id: '2899ec066a91ff8', secure: 1, tagid: 'undefined' } ] }, + sizes: [[300, 250], [300, 600]], + transactionId: '2e63c0ed-b10c-4008-aed5-84582cecfe87' + }], + doneCbCallCount: 1, + start: 1536838908987, + timeout: 3000, + gdprConsent: { + 'consentString': 'BOh7mtYOh7mtYAcABBENCU-AAAAncgPIXJiiAoao0PxBFkgCAC8ACIAAQAQQAAIAAAIAAAhBGAAAQAQAEQgAAAAAAABAAAAAAAAAAAAAAACAAAAAAAACgAAAAABAAAAQAAAAAAA', + 'gdprApplies': true, + 'vendorData': { + 'metadata': 'BOh7mtYOh7mtYAcABBENCU-AAAAncgPIXJiiAoao0PxBFkgCAC8ACIAAQAQQAAIAAAIAAAhBGAAAQAQAEQgAAAAAAABAAAAAAAAAAAAAAACAAAAAAAACgAAAAABAAAAQAAAAAAA', + 'gdprApplies': true + } + }, +}; + // make sure the impid matches the request bidId var validResponse = { 'body': { @@ -201,6 +282,7 @@ var validResponse = { 'seat': 'appnexus' } ], + 'cur': 'GBP', /* NOTE - this is where cur is, not in the seatbids. */ 'ext': { 'responsetimemillis': { 'appnexus': 47, @@ -390,7 +472,7 @@ describe('ozone Adapter', function () { placementId: '1310000099', publisherId: '9876abcd12-3', siteId: '1234567890', - customData: {'gender': 'bart', 'age': 'low'}, + customData: [{'settings': {}, 'targeting': {'gender': 'bart', 'age': 'low'}}], lotameData: {'Profile': {'tpid': 'c8ef27a0d4ba771a81159f0d2e792db4', 'Audiences': {'Audience': [{'id': '99999', 'abbr': 'sports'}, {'id': '88888', 'abbr': 'movie'}, {'id': '77777', 'abbr': 'blogger'}], 'ThirdPartyAudience': [{'id': '123', 'name': 'Automobiles'}, {'id': '456', 'name': 'Ages: 30-39'}]}}}, }, siteId: 1234567890 @@ -615,67 +697,88 @@ describe('ozone Adapter', function () { } }; - it('should not validate customData not being an object', function () { + it('should not validate customData not being an array', function () { expect(spec.isBidRequestValid(xBadCustomData)).to.equal(false); }); - var xCustomParams = { + var xBadCustomData_OLD_CUSTOMDATA_VALUE = { bidder: BIDDER_CODE, params: { 'placementId': '1234567890', 'publisherId': '9876abcd12-3', - 'customParams': {'info': 'this is not allowed'}, - siteId: '1234567890' + 'siteId': '1234567890', + 'customData': {'gender': 'bart', 'age': 'low'} } }; - it('should not validate customParams being sent', function () { - expect(spec.isBidRequestValid(xCustomParams)).to.equal(false); + it('should not validate customData being an object, not an array', function () { + expect(spec.isBidRequestValid(xBadCustomData_OLD_CUSTOMDATA_VALUE)).to.equal(false); }); - var xBadCustomData = { + var xBadCustomData_zerocd = { + bidder: BIDDER_CODE, + params: { + 'placementId': '1111111110', + 'publisherId': '9876abcd12-3', + 'siteId': '1234567890', + 'customData': [] + } + }; + + it('should not validate customData array having no elements', function () { + expect(spec.isBidRequestValid(xBadCustomData_zerocd)).to.equal(false); + }); + + var xBadCustomData_notargeting = { bidder: BIDDER_CODE, params: { 'placementId': '1234567890', 'publisherId': '9876abcd12-3', - 'customData': 'this should be an object', + 'customData': [{'settings': {}, 'xx': {'gender': 'bart', 'age': 'low'}}], siteId: '1234567890' } }; - it('should not validate ozoneData being sent', function () { - expect(spec.isBidRequestValid(xBadCustomData)).to.equal(false); + it('should not validate customData[] having no "targeting"', function () { + expect(spec.isBidRequestValid(xBadCustomData_notargeting)).to.equal(false); }); - var xBadLotame = { + var xBadCustomData_tgt_not_obj = { bidder: BIDDER_CODE, params: { 'placementId': '1234567890', 'publisherId': '9876abcd12-3', - 'lotameData': 'this should be an object', + 'customData': [{'settings': {}, 'targeting': 'this should be an object'}], siteId: '1234567890' } }; - it('should not validate lotameData being sent', function () { - expect(spec.isBidRequestValid(xBadLotame)).to.equal(false); + it('should not validate customData[0].targeting not being an object', function () { + expect(spec.isBidRequestValid(xBadCustomData_tgt_not_obj)).to.equal(false); }); - var xBadVideoContext = { + var xBadCustomParams = { bidder: BIDDER_CODE, params: { 'placementId': '1234567890', 'publisherId': '9876abcd12-3', - 'lotameData': {}, - siteId: '1234567890' - }, - mediaTypes: { - video: { - mimes: ['video/mp4'], - 'context': 'instream'}, + 'siteId': '1234567890', + 'customParams': 'this key is no longer valid' } }; + it('should not validate customParams - this is a renamed key', function () { + expect(spec.isBidRequestValid(xBadCustomParams)).to.equal(false); + }); - it('should not validate video instream being sent', function () { - expect(spec.isBidRequestValid(xBadVideoContext)).to.equal(false); + var xBadLotame = { + bidder: BIDDER_CODE, + params: { + 'placementId': '1234567890', + 'publisherId': '9876abcd12-3', + 'lotameData': 'this should be an object', + siteId: '1234567890' + } + }; + it('should not validate lotameData being sent', function () { + expect(spec.isBidRequestValid(xBadLotame)).to.equal(false); }); var xBadVideoContext2 = { @@ -713,6 +816,40 @@ describe('ozone Adapter', function () { it('should validate video outstream being sent', function () { expect(spec.isBidRequestValid(validVideoBidReq)).to.equal(true); }); + it('should validate video instream being sent even though its not properly supported yet', function () { + let instreamVid = JSON.parse(JSON.stringify(validVideoBidReq)); + instreamVid.mediaTypes.video.context = 'instream'; + expect(spec.isBidRequestValid(instreamVid)).to.equal(true); + }); + // validate lotame override parameters + it('should validate lotame override params', function () { + // mock the getGetParametersAsObject function to simulate GET parameters for lotame overrides: + spec.getGetParametersAsObject = function() { + return {'oz_lotameid': '123abc', 'oz_lotamepid': 'pid123', 'oz_lotametpid': 'tpid123'}; + }; + expect(spec.isBidRequestValid(validBidReq)).to.equal(true); + }); + it('should validate missing lotame override params', function () { + // mock the getGetParametersAsObject function to simulate GET parameters for lotame overrides: + spec.getGetParametersAsObject = function() { + return {'oz_lotameid': '123abc', 'oz_lotamepid': 'pid123'}; + }; + expect(spec.isBidRequestValid(validBidReq)).to.equal(false); + }); + it('should validate invalid lotame override params', function () { + // mock the getGetParametersAsObject function to simulate GET parameters for lotame overrides: + spec.getGetParametersAsObject = function() { + return {'oz_lotameid': '123abc', 'oz_lotamepid': 'pid123', 'oz_lotametpid': '123 "this ain\\t right!" eee'}; + }; + expect(spec.isBidRequestValid(validBidReq)).to.equal(false); + }); + it('should validate no lotame override params', function () { + // mock the getGetParametersAsObject function to simulate GET parameters for lotame overrides: + spec.getGetParametersAsObject = function() { + return {}; + }; + expect(spec.isBidRequestValid(validBidReq)).to.equal(true); + }); }); describe('buildRequests', function () { @@ -737,7 +874,7 @@ describe('ozone Adapter', function () { expect(request.data).to.be.a('string'); var data = JSON.parse(request.data); expect(data.imp[0].ext.ozone.lotameData).to.be.an('object'); - expect(data.imp[0].ext.ozone.customData).to.be.an('object'); + expect(data.imp[0].ext.ozone.customData).to.be.an('array'); expect(request).not.to.have.key('lotameData'); expect(request).not.to.have.key('customData'); }); @@ -749,7 +886,7 @@ describe('ozone Adapter', function () { expect(request.data).to.be.a('string'); var data = JSON.parse(request.data); expect(data.imp[0].ext.ozone.lotameData).to.be.an('object'); - expect(data.imp[0].ext.ozone.customData).to.be.an('object'); + expect(data.imp[0].ext.ozone.customData).to.be.an('array'); expect(data.imp[0].ext.ozone.ozoneData).to.be.undefined; expect(request).not.to.have.key('lotameData'); expect(request).not.to.have.key('customData'); @@ -796,6 +933,8 @@ describe('ozone Adapter', function () { consentString: consentString, gdprApplies: true, vendorData: { + metadata: consentString, + gdprApplies: true, vendorConsents: {524: true}, purposeConsents: {1: true, 2: true, 3: true, 4: true, 5: true} } @@ -804,46 +943,59 @@ describe('ozone Adapter', function () { const request = spec.buildRequests(validBidRequestsNoSizes, bidderRequest); const payload = JSON.parse(request.data); expect(payload.regs.ext.gdpr).to.equal(1); - expect(payload.regs.ext.oz_con).to.exist.and.to.equal(1); - expect(payload.regs.ext.gap).to.exist.and.to.be.an('array').and.to.eql([1, 2, 3, 4, 5]); + expect(payload.user.ext.consent).to.equal(consentString); }); - it('should add correct gdpr consent information to the request when user has accepted only some purpose consents', function () { + // mirror + it('should add gdpr consent information to the request when ozone.oz_enforceGdpr is false and vendorData is missing vendorConsents (Mirror)', function () { let consentString = 'BOcocyaOcocyaAfEYDENCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NphLgA=='; let bidderRequest = validBidderRequest; bidderRequest.gdprConsent = { consentString: consentString, gdprApplies: true, vendorData: { - vendorConsents: {524: true}, - purposeConsents: {1: true, 4: true, 5: true} + metadata: consentString, + gdprApplies: true } } const request = spec.buildRequests(validBidRequestsNoSizes, bidderRequest); const payload = JSON.parse(request.data); expect(payload.regs.ext.gdpr).to.equal(1); - expect(payload.regs.ext.oz_con).to.exist.and.to.equal(1); - expect(payload.regs.ext.gap).to.exist.and.to.be.an('array').and.to.eql([1, 4, 5]); + expect(payload.user.ext.consent).to.equal(consentString); }); - - it('should add gdpr consent information to the request when ozone is false', function () { + it('should add gdpr consent information to the request when ozone.oz_enforceGdpr is NOT PRESENT and vendorData is missing vendorConsents (Mirror)', function () { let consentString = 'BOcocyaOcocyaAfEYDENCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NphLgA=='; let bidderRequest = validBidderRequest; bidderRequest.gdprConsent = { consentString: consentString, gdprApplies: true, vendorData: { - vendorConsents: {}, /* 524 is not present */ - purposeConsents: {1: true, 2: true, 3: true, 4: true, 5: true} + metadata: consentString, + gdprApplies: true } - }; - + } const request = spec.buildRequests(validBidRequestsNoSizes, bidderRequest); const payload = JSON.parse(request.data); expect(payload.regs.ext.gdpr).to.equal(1); - expect(payload.regs.ext.oz_con).to.exist.and.to.equal(0); - expect(payload.regs.ext.gap).to.exist.and.to.be.an('array').and.to.eql([1, 2, 3, 4, 5]); + expect(payload.user.ext.consent).to.equal(consentString); + config.resetConfig(); + }); + it('should kill the auction request when ozone.oz_enforceGdpr is true & vendorData is missing vendorConsents (Mirror)', function () { + let consentString = 'BOcocyaOcocyaAfEYDENCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NphLgA=='; + let bidderRequest = validBidderRequest; + bidderRequest.gdprConsent = { + consentString: consentString, + gdprApplies: true, + vendorData: { + metadata: consentString, + gdprApplies: true + } + } + config.setConfig({'ozone': {'oz_enforceGdpr': true}}); + const request = spec.buildRequests(validBidRequestsNoSizes, bidderRequest); + expect(request.length).to.equal(0); + config.resetConfig(); }); it('should set regs.ext.gdpr flag to 0 when gdprApplies is false', function () { @@ -853,6 +1005,8 @@ describe('ozone Adapter', function () { consentString: consentString, gdprApplies: false, vendorData: { + metadata: consentString, + gdprApplies: true, vendorConsents: {}, /* 524 is not present */ purposeConsents: {1: true, 2: true, 3: true, 4: true, 5: true} } @@ -861,8 +1015,184 @@ describe('ozone Adapter', function () { const request = spec.buildRequests(validBidRequestsNoSizes, bidderRequest); const payload = JSON.parse(request.data); expect(payload.regs.ext.gdpr).to.equal(0); - expect(payload.regs.ext.oz_con).to.be.undefined; - expect(payload.regs.ext.gap).to.be.undefined; + }); + + it('should not have imp[N].ext.ozone.userId', function () { + let consentString = 'BOcocyaOcocyaAfEYDENCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NphLgA=='; + let bidderRequest = validBidderRequest; + bidderRequest.gdprConsent = { + consentString: consentString, + gdprApplies: false, + vendorData: { + metadata: consentString, + gdprApplies: true, + vendorConsents: {524: true}, + purposeConsents: {1: true, 2: true, 3: true, 4: true, 5: true} + } + }; + + let bidRequests = validBidRequests; + // values from http://prebid.org/dev-docs/modules/userId.html#pubcommon-id + bidRequests[0]['userId'] = { + 'criteortus': '1111', + 'digitrustid': {data: {id: 'DTID', keyv: 4, privacy: {optout: false}, producer: 'ABC', version: 2}}, + 'id5id': '2222', + 'idl_env': '3333', + 'lipb': {'lipbid': '4444'}, + 'parrableid': 'eidVersion.encryptionKeyReference.encryptedValue', + 'pubcid': '5555', + 'tdid': '6666' + }; + const request = spec.buildRequests(bidRequests, bidderRequest); + const payload = JSON.parse(request.data); + let firstBid = payload.imp[0].ext.ozone; + expect(firstBid).to.not.have.property('userId'); + delete validBidRequests[0].userId; // tidy up now, else it will screw with other tests + }); + + it('should pick up the value of pubcid when built using the pubCommonId module (not userId)', function () { + let bidRequests = validBidRequests; + // values from http://prebid.org/dev-docs/modules/userId.html#pubcommon-id + bidRequests[0]['userId'] = { + 'criteortus': '1111', + 'digitrustid': {data: {id: 'DTID', keyv: 4, privacy: {optout: false}, producer: 'ABC', version: 2}}, + 'id5id': '2222', + 'idl_env': '3333', + 'lipb': {'lipbid': '4444'}, + 'parrableid': 'eidVersion.encryptionKeyReference.encryptedValue', + // 'pubcid': '5555', // remove pubcid from here to emulate the OLD module & cause the failover code to kick in + 'tdid': '6666' + }; + const request = spec.buildRequests(bidRequests, validBidderRequest); + const payload = JSON.parse(request.data); + expect(payload.ext.ozone.pubcid).to.equal(bidRequests[0]['crumbs']['pubcid']); + delete validBidRequests[0].userId; // tidy up now, else it will screw with other tests + }); + + it('should add a user.ext.eids object to contain user ID data in the new location (Nov 2019)', function() { + const request = spec.buildRequests(validBidRequestsWithUserIdData, validBidderRequest); + const payload = JSON.parse(request.data); + expect(payload.user).to.exist; + expect(payload.user.ext).to.exist; + expect(payload.user.ext.eids).to.exist; + expect(payload.user.ext.eids[0]['source']).to.equal('pubcid'); + expect(payload.user.ext.eids[0]['uids'][0]['id']).to.equal('12345678'); + expect(payload.user.ext.eids[1]['source']).to.equal('pubcommon'); + expect(payload.user.ext.eids[1]['uids'][0]['id']).to.equal('12345678'); + expect(payload.user.ext.eids[2]['source']).to.equal('id5-sync.com'); + expect(payload.user.ext.eids[2]['uids'][0]['id']).to.equal('ID5-someId'); + expect(payload.user.ext.eids[3]['source']).to.equal('criteortus'); + expect(payload.user.ext.eids[3]['uids'][0]['id']).to.equal('critId123'); + expect(payload.user.ext.eids[4]['source']).to.equal('liveramp.com'); + expect(payload.user.ext.eids[4]['uids'][0]['id']).to.equal('liverampId'); + expect(payload.user.ext.eids[5]['source']).to.equal('liveintent.com'); + expect(payload.user.ext.eids[5]['uids'][0]['id']).to.equal('lipbidId123'); + expect(payload.user.ext.eids[6]['source']).to.equal('parrable.com'); + expect(payload.user.ext.eids[6]['uids'][0]['id']).to.equal('parrableid123'); + }); + + it('should use oztestmode GET value if set', function() { + // mock the getGetParametersAsObject function to simulate GET parameters for oztestmode: + spec.getGetParametersAsObject = function() { + return {'oztestmode': 'mytestvalue_123'}; + }; + const request = spec.buildRequests(validBidRequests, validBidderRequest); + const data = JSON.parse(request.data); + expect(data.imp[0].ext.ozone.customData).to.be.an('array'); + expect(data.imp[0].ext.ozone.customData[0].targeting.oztestmode).to.equal('mytestvalue_123'); + }); + it('should use oztestmode GET value if set, even if there is no customdata in config', function() { + // mock the getGetParametersAsObject function to simulate GET parameters for oztestmode: + spec.getGetParametersAsObject = function() { + return {'oztestmode': 'mytestvalue_123'}; + }; + const request = spec.buildRequests(validBidRequestsMinimal, validBidderRequest); + const data = JSON.parse(request.data); + expect(data.imp[0].ext.ozone.customData).to.be.an('array'); + expect(data.imp[0].ext.ozone.customData[0].targeting.oztestmode).to.equal('mytestvalue_123'); + }); + var specMock = utils.deepClone(spec); + it('should use a valid ozstoredrequest GET value if set to override the placementId values, and set oz_rw if we find it', function() { + // mock the getGetParametersAsObject function to simulate GET parameters for ozstoredrequest: + specMock.getGetParametersAsObject = function() { + return {'ozstoredrequest': '1122334455'}; // 10 digits are valid + }; + const request = specMock.buildRequests(validBidRequestsMinimal, validBidderRequest); + const data = JSON.parse(request.data); + expect(data.ext.ozone.oz_rw).to.equal(1); + expect(data.imp[0].ext.prebid.storedrequest.id).to.equal('1122334455'); + }); + it('should NOT use an invalid ozstoredrequest GET value if set to override the placementId values, and set oz_rw to 0', function() { + // mock the getGetParametersAsObject function to simulate GET parameters for ozstoredrequest: + specMock.getGetParametersAsObject = function() { + return {'ozstoredrequest': 'BADVAL'}; // 10 digits are valid + }; + const request = specMock.buildRequests(validBidRequestsMinimal, validBidderRequest); + const data = JSON.parse(request.data); + expect(data.ext.ozone.oz_rw).to.equal(0); + expect(data.imp[0].ext.prebid.storedrequest.id).to.equal('1310000099'); + }); + + it('should pick up the value of valid lotame override parameters when there is a lotame object', function () { + spec.getGetParametersAsObject = function() { + return {'oz_lotameid': '123abc', 'oz_lotamepid': 'pid123', 'oz_lotametpid': '123eee'}; + }; + const request = spec.buildRequests(validBidRequests, validBidderRequest); + const payload = JSON.parse(request.data); + expect(payload.imp[0].ext.ozone.lotameData.Profile.Audiences.Audience[0].id).to.equal('123abc'); + expect(payload.ext.ozone.oz_lot_rw).to.equal(1); + }); + it('should pick up the value of valid lotame override parameters when there is an empty lotame object', function () { + let nolotameBidReq = JSON.parse(JSON.stringify(validBidRequests)); + nolotameBidReq[0].params.lotameData = {}; + spec.getGetParametersAsObject = function() { + return {'oz_lotameid': '123abc', 'oz_lotamepid': 'pid123', 'oz_lotametpid': '123eeetpid'}; + }; + const request = spec.buildRequests(nolotameBidReq, validBidderRequest); + const payload = JSON.parse(request.data); + expect(payload.imp[0].ext.ozone.lotameData.Profile.Audiences.Audience[0].id).to.equal('123abc'); + expect(payload.imp[0].ext.ozone.lotameData.Profile.tpid).to.equal('123eeetpid'); + expect(payload.imp[0].ext.ozone.lotameData.Profile.pid).to.equal('pid123'); + expect(payload.ext.ozone.oz_lot_rw).to.equal(1); + }); + it('should pick up the value of valid lotame override parameters when there is NO "lotame" key at all', function () { + let nolotameBidReq = JSON.parse(JSON.stringify(validBidRequests)); + delete (nolotameBidReq[0].params['lotameData']); + spec.getGetParametersAsObject = function() { + return {'oz_lotameid': '123abc', 'oz_lotamepid': 'pid123', 'oz_lotametpid': '123eeetpid'}; + }; + const request = spec.buildRequests(nolotameBidReq, validBidderRequest); + const payload = JSON.parse(request.data); + expect(payload.imp[0].ext.ozone.lotameData.Profile.Audiences.Audience[0].id).to.equal('123abc'); + expect(payload.imp[0].ext.ozone.lotameData.Profile.tpid).to.equal('123eeetpid'); + expect(payload.imp[0].ext.ozone.lotameData.Profile.pid).to.equal('pid123'); + expect(payload.ext.ozone.oz_lot_rw).to.equal(1); + }); + // NOTE - only one negative test case; + // you can't send invalid lotame params to buildRequests because 'validate' will have rejected them + it('should not use lotame override parameters if they dont exist', function () { + spec.getGetParametersAsObject = function() { + return {}; // no lotame override params + }; + const request = spec.buildRequests(validBidRequests, validBidderRequest); + const payload = JSON.parse(request.data); + expect(payload.ext.ozone.oz_lot_rw).to.equal(0); + }); + + it('should pick up the config value of coppa & set it in the request', function () { + config.setConfig({'coppa': true}); + const request = spec.buildRequests(validBidRequestsNoSizes, validBidderRequest); + const payload = JSON.parse(request.data); + expect(payload.regs).to.include.keys('coppa'); + expect(payload.regs.coppa).to.equal(1); + config.resetConfig(); + }); + it('should pick up the config value of coppa & only set it in the request if its true', function () { + config.setConfig({'coppa': false}); + const request = spec.buildRequests(validBidRequestsNoSizes, validBidderRequest); + const payload = JSON.parse(request.data); + expect(utils.deepAccess(payload, 'regs.coppa')).to.be.undefined; + config.resetConfig(); }); }); @@ -883,13 +1213,20 @@ describe('ozone Adapter', function () { }); it('should build bid array with gdpr', function () { - var validBidderRequestWithGdpr = validBidderRequest; - validBidderRequestWithGdpr.gdprConsent = {'gdprApplies': 1, 'consentString': 'This is the gdpr consent string'}; - const request = spec.buildRequests(validBidRequests, validBidderRequestWithGdpr); + let validBR = JSON.parse(JSON.stringify(bidderRequestWithFullGdpr)); + validBR.gdprConsent = {'gdprApplies': 1, 'consentString': 'This is the gdpr consent string'}; + const request = spec.buildRequests(validBidRequests, validBR); // works the old way, with GDPR not enforced by default + // const request = spec.buildRequests(validBidRequests, bidderRequestWithFullGdpr); // works with oz_enforceGdpr true by default const result = spec.interpretResponse(validResponse, request); expect(result.length).to.equal(1); }); + it('should build bid array with only partial gdpr', function () { + var validBidderRequestWithGdpr = bidderRequestWithPartialGdpr; + validBidderRequestWithGdpr.gdprConsent = {'gdprApplies': 1, 'consentString': 'This is the gdpr consent string'}; + const request = spec.buildRequests(validBidRequests, validBidderRequestWithGdpr); + }); + it('should fail ok if no seatbid in server response', function () { const result = spec.interpretResponse({}, {}); expect(result).to.be.an('array'); @@ -914,17 +1251,33 @@ describe('ozone Adapter', function () { const result = spec.interpretResponse(validBidResponse1adWith2Bidders, request); expect(result.length).to.equal(2); }); + + it('should have a ttl of 600', function () { + const request = spec.buildRequests(validBidRequests, validBidderRequest); + const result = spec.interpretResponse(validResponse, request); + expect(result[0].ttl).to.equal(300); + }); }); describe('userSyncs', function () { it('should fail gracefully if no server response', function () { - const result = spec.getUserSyncs('bad', false); + const result = spec.getUserSyncs('bad', false, gdpr1); expect(result).to.be.empty; }); it('should fail gracefully if server response is empty', function () { - const result = spec.getUserSyncs('bad', []); + const result = spec.getUserSyncs('bad', [], gdpr1); expect(result).to.be.empty; }); + it('should append the various values if they exist', function() { + // get the cookie bag populated + spec.buildRequests(validBidRequests, validBidderRequest); + const result = spec.getUserSyncs({iframeEnabled: true}, 'good server response', gdpr1); + expect(result).to.be.an('array'); + expect(result[0].url).to.include('publisherId=9876abcd12-3'); + expect(result[0].url).to.include('siteId=1234567890'); + expect(result[0].url).to.include('gdpr=1'); + expect(result[0].url).to.include('gdpr_consent=BOh7mtYOh7mtYAcABBENCU-AAAAncgPIXJiiAoao0PxBFkgCAC8ACIAAQAQQAAIAAAIAAAhBGAAAQAQAEQgAAAAAAABAAAAAAAAAAAAAAACAAAAAAAACgAAAAABAAAAQAAAAAAA'); + }); }); describe('video object utils', function () { @@ -981,6 +1334,7 @@ describe('ozone Adapter', function () { expect(result).to.be.null; }); }); + describe('default size', function () { it('should should return default sizes if no obj is sent', function () { let obj = ''; @@ -989,4 +1343,159 @@ describe('ozone Adapter', function () { expect(result.defaultWidth).to.equal(300); }); }); + + describe('getGranularityKeyName', function() { + it('should return a string granularity as-is', function() { + const result = getGranularityKeyName('', 'this is it', ''); + expect(result).to.equal('this is it'); + }); + it('should return "custom" for a mediaTypeGranularity object', function() { + const result = getGranularityKeyName('', {}, ''); + expect(result).to.equal('custom'); + }); + it('should return "custom" for a mediaTypeGranularity object', function() { + const result = getGranularityKeyName('', false, 'string buckets'); + expect(result).to.equal('string buckets'); + }); + }); + + describe('getGranularityObject', function() { + it('should return an object as-is', function() { + const result = getGranularityObject('', {'name': 'mark'}, '', ''); + expect(result.name).to.equal('mark'); + }); + it('should return an object as-is', function() { + const result = getGranularityObject('', false, 'custom', {'name': 'rupert'}); + expect(result.name).to.equal('rupert'); + }); + }); + + describe('blockTheRequest', function() { + it('should return true if oz_request is false', function() { + config.setConfig({'ozone': {'oz_request': false}}); + let result = spec.blockTheRequest(bidderRequestWithFullGdpr); + expect(result).to.be.true; + config.resetConfig(); + }); + it('should return false if oz_request is true', function() { + config.setConfig({'ozone': {'oz_request': true}}); + let result = spec.blockTheRequest(bidderRequestWithFullGdpr); + expect(result).to.be.false; + config.resetConfig(); + }); + it('should return true if oz_enforceGdpr is true and consentString is undefined', function() { + config.setConfig({'ozone': {'oz_enforceGdpr': true}}); + let req = JSON.parse(JSON.stringify(bidderRequestWithFullGdpr)); + delete req.gdprConsent.consentString; + let result = spec.blockTheRequest(req); + expect(result).to.be.true; + config.resetConfig(); + }); + it('should return false if oz_enforceGdpr is false and consentString is undefined', function() { + config.setConfig({'ozone': {'oz_enforceGdpr': false}}); + let req = JSON.parse(JSON.stringify(bidderRequestWithFullGdpr)); + delete req.gdprConsent.consentString; + let result = spec.blockTheRequest(req); + expect(result).to.be.false; + config.resetConfig(); + }); + it('should return false if oz_enforceGdpr is NOT SET (default) and consentString is undefined', function() { + let req = JSON.parse(JSON.stringify(bidderRequestWithFullGdpr)); + delete req.gdprConsent.consentString; + let result = spec.blockTheRequest(req); + expect(result).to.be.false; + }); + it('should return false if gdprApplies is false', function() { + config.setConfig({'ozone': {'oz_request': true}}); + let req = {'gdprConsent': {'gdprApplies': false}}; + let result = spec.blockTheRequest(req); + expect(result).to.be.false; + config.resetConfig(); + }); + it('should return false if gdprConsent key does not exist', function() { + let req = JSON.parse(JSON.stringify(bidderRequestWithFullGdpr)); + config.setConfig({'ozone': {'oz_enforceGdpr': true}}); + delete req.gdprConsent; + let result = spec.blockTheRequest(req); + expect(result).to.be.false; + config.resetConfig(); + }); + it('should return false if gdpr is set, and all is ok', function() { + let req = JSON.parse(JSON.stringify(bidderRequestWithFullGdpr)); + config.setConfig({'ozone': {'oz_enforceGdpr': true}}); + let result = spec.blockTheRequest(req); + expect(result).to.be.false; + config.resetConfig(); + }); + }); + + describe('failsGdprCheck', function() { + it('should return false for a a fully accepted user', function () { + let result = spec.failsGdprCheck(bidderRequestWithFullGdpr); + expect(result).to.be.false; + }); + it('should return false if gdprConsent is not present on the bidder object', function () { + let result = spec.failsGdprCheck(validBidderRequest); + expect(result).to.be.false; + }); + it('should return true if gdpr applies and vendorData is not an array', function () { + let req = JSON.parse(JSON.stringify(bidderRequestWithFullGdpr)); + req.gdprConsent.vendorData = null; + let result = spec.failsGdprCheck(req); + expect(result).to.be.true; + }); + it('should return true if gdpr applies and purposeConsents do not contain all the required true values', function () { + let req = JSON.parse(JSON.stringify(bidderRequestWithFullGdpr)); + req.gdprConsent.vendorData.purposeConsents[1] = false; + let result = spec.failsGdprCheck(req); + expect(result).to.be.true; + }); + it('should return true if gdpr applies and vendorConsents[524] is not true', function () { + config.setConfig({'ozone': {'oz_enforceGdpr': true}}); + let req = JSON.parse(JSON.stringify(bidderRequestWithFullGdpr)); + req.gdprConsent.vendorData.vendorConsents[524] = false; + let result = spec.failsGdprCheck(req); + expect(result).to.be.true; + config.resetConfig(); + }); + }); + + describe('makeLotameObjectFromOverride', function() { + it('should update an object with valid lotame data', function () { + let objLotameOverride = {'oz_lotametpid': '1234', 'oz_lotameid': '12345', 'oz_lotamepid': '123456'}; + let result = spec.makeLotameObjectFromOverride( + objLotameOverride, + {'Profile': {'pid': 'originalpid', 'tpid': 'originaltpid', 'Audiences': {'Audience': [{'id': 'aud1'}]}}} + ); + expect(result.Profile.Audiences.Audience).to.be.an('array'); + expect(result.Profile.Audiences.Audience[0]).to.be.an('object'); + expect(result.Profile.Audiences.Audience[0]).to.deep.include({'id': '12345', 'abbr': '12345'}); + }); + it('should return the original object if it seems weird', function () { + let objLotameOverride = {'oz_lotametpid': '1234', 'oz_lotameid': '12345', 'oz_lotamepid': '123456'}; + let objLotameOriginal = {'Profile': {'pid': 'originalpid', 'tpid': 'originaltpid', 'somethingstrange': [{'id': 'aud1'}]}}; + let result = spec.makeLotameObjectFromOverride( + objLotameOverride, + objLotameOriginal + ); + expect(result).to.equal(objLotameOriginal); + }); + }); + describe('lotameDataIsValid', function() { + it('should allow a valid minimum lotame object', function() { + let obj = {'Profile': {'pid': '', 'tpid': '', 'Audiences': {'Audience': []}}}; + let result = spec.isLotameDataValid(obj); + expect(result).to.be.true; + }); + it('should allow a valid lotame object', function() { + let obj = {'Profile': {'pid': '12345', 'tpid': '45678', 'Audiences': {'Audience': [{'id': '1234', 'abbr': '567'}, {'id': '9999', 'abbr': '1111'}]}}}; + let result = spec.isLotameDataValid(obj); + expect(result).to.be.true; + }); + it('should disallow a lotame object without an Audience.id', function() { + let obj = {'Profile': {'tpid': '', 'pid': '', 'Audiences': {'Audience': [{'abbr': 'marktest'}]}}}; + let result = spec.isLotameDataValid(obj); + expect(result).to.be.false; + }); + }); }); diff --git a/test/spec/modules/padsquadBidAdapter_spec.js b/test/spec/modules/padsquadBidAdapter_spec.js index aba1efea32f..d30b1f34a9e 100644 --- a/test/spec/modules/padsquadBidAdapter_spec.js +++ b/test/spec/modules/padsquadBidAdapter_spec.js @@ -1,5 +1,5 @@ import {expect} from 'chai'; -import {spec} from 'modules/padsquadBidAdapter'; +import {spec} from 'modules/padsquadBidAdapter.js'; const REQUEST = { 'bidderCode': 'padsquad', @@ -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 289da56379a..20fcced2950 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'; +import { spec } from 'modules/papyrusBidAdapter.js'; -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/parrableIdSystem_spec.js b/test/spec/modules/parrableIdSystem_spec.js index 540e63aa630..93415126a0a 100644 --- a/test/spec/modules/parrableIdSystem_spec.js +++ b/test/spec/modules/parrableIdSystem_spec.js @@ -1,8 +1,11 @@ import { expect } from 'chai'; -import {config} from 'src/config'; -import * as utils from 'src/utils'; +import {config} from 'src/config.js'; +import * as utils from 'src/utils.js'; import { init, requestBidsHook, setSubmoduleRegistry } from 'modules/userId/index.js'; -import { parrableIdSubmodule } from 'modules/parrableIdSystem'; +import { parrableIdSubmodule } from 'modules/parrableIdSystem.js'; +import { newStorageManager } from 'src/storageManager.js'; + +const storage = newStorageManager(); const EXPIRED_COOKIE_DATE = 'Thu, 01 Jan 1970 00:00:01 GMT'; const P_COOKIE_NAME = '_parrable_eid'; @@ -52,7 +55,7 @@ describe('Parrable ID System', function() { it('should append parrableid to bid request', function(done) { // simulate existing browser local storage values - utils.setCookie( + storage.setCookie( P_COOKIE_NAME, P_COOKIE_VALUE, (new Date(Date.now() + 5000).toUTCString()) @@ -69,7 +72,7 @@ describe('Parrable ID System', function() { expect(bid.userId.parrableid).to.equal(P_COOKIE_VALUE); }); }); - utils.setCookie(P_COOKIE_NAME, '', EXPIRED_COOKIE_DATE); + storage.setCookie(P_COOKIE_NAME, '', EXPIRED_COOKIE_DATE); done(); }, { adUnits }); }); diff --git a/test/spec/modules/peak226BidAdapter_spec.js b/test/spec/modules/peak226BidAdapter_spec.js deleted file mode 100644 index 8b8157225bb..00000000000 --- 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/piximediaBidAdapter_spec.js b/test/spec/modules/piximediaBidAdapter_spec.js index 95e03734345..88a6433b71d 100644 --- a/test/spec/modules/piximediaBidAdapter_spec.js +++ b/test/spec/modules/piximediaBidAdapter_spec.js @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import { spec } from 'modules/piximediaBidAdapter'; +import { spec } from 'modules/piximediaBidAdapter.js'; describe('piximediaAdapterTest', function() { describe('bidRequestValidity', function() { diff --git a/test/spec/modules/platformioBidAdapter_spec.js b/test/spec/modules/platformioBidAdapter_spec.js index 4ef2dc1bba0..ee753be17a7 100644 --- a/test/spec/modules/platformioBidAdapter_spec.js +++ b/test/spec/modules/platformioBidAdapter_spec.js @@ -1,18 +1,21 @@ 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', + mediaTypes: { + banner: { + sizes: [[300, 250]] + } + }, bidId: 'bid12345', mediaType: 'banner', params: { pubId: '29521', siteId: '26047', placementId: '123', - size: '300x250', bidFloor: '0.001', ifa: 'IFA', latitude: '40.712775', @@ -20,13 +23,17 @@ describe('Platform.io Adapter Tests', function () { } }, { placementCode: '/DfpAccount2/slot2', + mediaTypes: { + banner: { + sizes: [[728, 90]] + } + }, bidId: 'bid23456', mediaType: 'banner', params: { pubId: '29521', siteId: '26047', placementId: '1234', - size: '728x90', bidFloor: '0.000001', } }]; @@ -49,6 +56,11 @@ describe('Platform.io Adapter Tests', function () { }]; const videoSlotConfig = [{ placementCode: '/DfpAccount1/slot4', + mediaTypes: { + video: { + playerSize: [[640, 480]] + } + }, bidId: 'bid12345678', mediaType: 'video', video: { @@ -58,7 +70,6 @@ describe('Platform.io Adapter Tests', function () { pubId: '29521', placementId: '1234567', siteId: '26047', - size: '640x480' } }]; const appSlotConfig = [{ @@ -71,7 +82,7 @@ describe('Platform.io Adapter Tests', function () { id: '1111', name: 'app name', bundle: 'io.platform.apps', - storeUrl: 'http://platform.io/apps', + storeUrl: 'https://platform.io/apps', domain: 'platform.io' } } @@ -79,7 +90,7 @@ describe('Platform.io Adapter Tests', function () { it('Verify build request', function () { const request = spec.buildRequests(slotConfigs); - expect(request.url).to.equal('//piohbdisp.hb.adx1.com/'); + expect(request.url).to.equal('https://piohbdisp.hb.adx1.com/'); expect(request.method).to.equal('POST'); const ortbRequest = JSON.parse(request.data); // site object @@ -87,7 +98,7 @@ describe('Platform.io Adapter Tests', function () { 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.site.page).to.equal(window.location.href); expect(ortbRequest.imp).to.have.lengthOf(2); // device object expect(ortbRequest.device).to.not.equal(null); @@ -117,7 +128,9 @@ describe('Platform.io Adapter Tests', function () { bid: [{ impid: ortbRequest.imp[0].id, price: 1.25, - adm: 'This is an Ad' + adm: 'This is an Ad', + w: 300, + h: 250 }] }], cur: 'USD' @@ -145,7 +158,7 @@ describe('Platform.io Adapter Tests', function () { it('Verify Native request', function () { const request = spec.buildRequests(nativeSlotConfig); - expect(request.url).to.equal('//piohbdisp.hb.adx1.com/'); + expect(request.url).to.equal('https://piohbdisp.hb.adx1.com/'); expect(request.method).to.equal('POST'); const ortbRequest = JSON.parse(request.data); // native impression @@ -183,7 +196,7 @@ describe('Platform.io Adapter Tests', function () { it('Verify Native response', function () { const request = spec.buildRequests(nativeSlotConfig); - expect(request.url).to.equal('//piohbdisp.hb.adx1.com/'); + expect(request.url).to.equal('https://piohbdisp.hb.adx1.com/'); expect(request.method).to.equal('POST'); const ortbRequest = JSON.parse(request.data); const nativeResponse = { @@ -195,7 +208,7 @@ describe('Platform.io Adapter Tests', function () { { 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/' } + link: { url: 'https://brand.com/' } } }; const ortbResponse = { @@ -203,7 +216,7 @@ describe('Platform.io Adapter Tests', function () { bid: [{ impid: ortbRequest.imp[0].id, price: 1.25, - nurl: 'http://rtb.adx1.com/log', + nurl: 'https://rtb.adx1.com/log', adm: JSON.stringify(nativeResponse) }] }], @@ -226,21 +239,21 @@ describe('Platform.io Adapter Tests', function () { 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.clickUrl).to.equal(encodeURIComponent('https://brand.com/')); expect(nativeBid.impressionTrackers).to.have.lengthOf(1); - expect(nativeBid.impressionTrackers[0]).to.equal('http://rtb.adx1.com/log'); + expect(nativeBid.impressionTrackers[0]).to.equal('https://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.url).to.equal('https://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); + expect(videoRequest.site.page).to.equal(window.location.href); // device object expect(videoRequest.device).to.not.equal(null); expect(videoRequest.device.ua).to.equal(navigator.userAgent); @@ -261,7 +274,7 @@ describe('Platform.io Adapter Tests', function () { bid: [{ impid: videoRequest.imp[0].id, price: 1.90, - adm: 'http://vid.example.com/9876', + adm: 'https://vid.example.com/9876', crid: '510511_754567308' }] }], @@ -272,7 +285,7 @@ describe('Platform.io Adapter Tests', function () { // 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.vastUrl).to.equal('https://vid.example.com/9876'); expect(bid.crid).to.equal('510511_754567308'); expect(bid.width).to.equal(640); expect(bid.height).to.equal(480); @@ -310,7 +323,7 @@ describe('Platform.io Adapter Tests', function () { 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.storeurl).to.equal('https://platform.io/apps'); expect(ortbRequest.app.domain).to.equal('platform.io'); }); @@ -322,7 +335,7 @@ describe('Platform.io Adapter Tests', function () { } }; const request = spec.buildRequests(slotConfigs, bidderRequest); - expect(request.url).to.equal('//piohbdisp.hb.adx1.com/'); + expect(request.url).to.equal('https://piohbdisp.hb.adx1.com/'); expect(request.method).to.equal('POST'); const ortbRequest = JSON.parse(request.data); expect(ortbRequest.user).to.not.equal(null); diff --git a/test/spec/modules/polluxBidAdapter_spec.js b/test/spec/modules/polluxBidAdapter_spec.js deleted file mode 100644 index 22c7f470f83..00000000000 --- 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 6fd4bd90288..00000000000 --- 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 52c8919b557..4744bef0ee3 100644 --- a/test/spec/modules/prebidServerBidAdapter_spec.js +++ b/test/spec/modules/prebidServerBidAdapter_spec.js @@ -1,11 +1,13 @@ import { expect } from 'chai'; import { PrebidServer as Adapter, resetSyncedStatus } from 'modules/prebidServerBidAdapter/index.js'; -import adapterManager from 'src/adapterManager'; -import * as utils from 'src/utils'; -import { ajax } from 'src/ajax'; -import { config } from 'src/config'; -import events from 'src/events'; -import CONSTANTS from 'src/constants'; +import adapterManager from 'src/adapterManager.js'; +import * as utils from 'src/utils.js'; +import { ajax } from 'src/ajax.js'; +import { config } from 'src/config.js'; +import events from 'src/events.js'; +import CONSTANTS from 'src/constants.json'; +import { server } from 'test/mocks/xhr.js'; +import { createEidsArray } from 'modules/userId/eids.js'; let CONFIG = { accountId: '1', @@ -13,7 +15,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 +167,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 +242,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 +257,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': { @@ -376,6 +298,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: { @@ -503,15 +426,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(), @@ -547,13 +461,17 @@ describe('S2S Adapter', function () { 'sizes': [300, 250], 'bidId': '123', 'bidderRequestId': '3d1063078dfcc8', - 'auctionId': '173afb6d132ba3' + 'auctionId': '173afb6d132ba3', + 'storedAuctionResponse': 11111 } ], 'auctionStart': 1510852447530, 'timeout': 5000, 'src': 's2s', - 'doneCbCallCount': 0 + 'doneCbCallCount': 0, + 'refererInfo': { + 'referer': 'http://mytestpage.com' + } } ]; }); @@ -564,19 +482,13 @@ describe('S2S Adapter', function () { }); describe('request function', function () { - let xhr; - let requests; - beforeEach(function () { - xhr = sinon.useFakeXMLHttpRequest(); - requests = []; - xhr.onCreate = request => requests.push(request); config.resetConfig(); resetSyncedStatus(); }); afterEach(function () { - xhr.restore(); + config.resetConfig(); }); it('should not add outstrean without renderer', function () { @@ -586,7 +498,7 @@ describe('S2S Adapter', function () { config.setConfig({ s2sConfig: ortb2Config }); adapter.callBids(OUTSTREAM_VIDEO_REQUEST, BID_REQUESTS, addBidResponse, done, ajax); - const requestBid = JSON.parse(requests[0].requestBody); + const requestBid = JSON.parse(server.requests[0].requestBody); expect(requestBid.imp[0].banner).to.exist; expect(requestBid.imp[0].video).to.not.exist; }); @@ -595,15 +507,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(); @@ -624,7 +527,7 @@ describe('S2S Adapter', function () { }; adapter.callBids(REQUEST, gdprBidRequest, addBidResponse, done, ajax); - let requestBid = JSON.parse(requests[0].requestBody); + let requestBid = JSON.parse(server.requests[0].requestBody); expect(requestBid.regs.ext.gdpr).is.equal(1); expect(requestBid.user.ext.consent).is.equal('abc123'); @@ -633,7 +536,7 @@ describe('S2S Adapter', function () { config.setConfig({ s2sConfig: CONFIG }); adapter.callBids(REQUEST, BID_REQUESTS, addBidResponse, done, ajax); - requestBid = JSON.parse(requests[1].requestBody); + requestBid = JSON.parse(server.requests[1].requestBody); expect(requestBid.regs).to.not.exist; expect(requestBid.user).to.not.exist; @@ -654,7 +557,7 @@ describe('S2S Adapter', function () { }; adapter.callBids(REQUEST, gdprBidRequest, addBidResponse, done, ajax); - let requestBid = JSON.parse(requests[0].requestBody); + let requestBid = JSON.parse(server.requests[0].requestBody); expect(requestBid.gdpr).is.equal(1); expect(requestBid.gdpr_consent).is.equal('abc123def'); @@ -676,7 +579,7 @@ describe('S2S Adapter', function () { }; adapter.callBids(REQUEST, gdprBidRequest, addBidResponse, done, ajax); - let requestBid = JSON.parse(requests[0].requestBody); + let requestBid = JSON.parse(server.requests[0].requestBody); expect(requestBid.gdpr).is.equal(0); expect(requestBid.gdpr_consent).is.undefined; @@ -696,7 +599,7 @@ describe('S2S Adapter', function () { }; adapter.callBids(REQUEST, gdprBidRequest, addBidResponse, done, ajax); - let requestBid = JSON.parse(requests[0].requestBody); + let requestBid = JSON.parse(server.requests[0].requestBody); expect(requestBid.gdpr).is.undefined; expect(requestBid.gdpr_consent).is.undefined; @@ -718,7 +621,7 @@ describe('S2S Adapter', function () { uspBidRequest[0].uspConsent = '1NYN'; adapter.callBids(REQUEST, uspBidRequest, addBidResponse, done, ajax); - let requestBid = JSON.parse(requests[0].requestBody); + let requestBid = JSON.parse(server.requests[0].requestBody); expect(requestBid.regs.ext.us_privacy).is.equal('1NYN'); @@ -726,7 +629,7 @@ describe('S2S Adapter', function () { config.setConfig({ s2sConfig: CONFIG }); adapter.callBids(REQUEST, BID_REQUESTS, addBidResponse, done, ajax); - requestBid = JSON.parse(requests[1].requestBody); + requestBid = JSON.parse(server.requests[1].requestBody); expect(requestBid.regs).to.not.exist; }); @@ -740,7 +643,7 @@ describe('S2S Adapter', function () { uspBidRequest[0].uspConsent = '1YNN'; adapter.callBids(REQUEST, uspBidRequest, addBidResponse, done, ajax); - let requestBid = JSON.parse(requests[0].requestBody); + let requestBid = JSON.parse(server.requests[0].requestBody); expect(requestBid.us_privacy).is.equal('1YNN'); expect(requestBid.bidders).to.contain('appnexus').and.to.have.lengthOf(1); @@ -767,7 +670,7 @@ describe('S2S Adapter', function () { }; adapter.callBids(REQUEST, consentBidRequest, addBidResponse, done, ajax); - let requestBid = JSON.parse(requests[0].requestBody); + let requestBid = JSON.parse(server.requests[0].requestBody); expect(requestBid.regs.ext.us_privacy).is.equal('1NYN'); expect(requestBid.regs.ext.gdpr).is.equal(1); @@ -777,7 +680,7 @@ describe('S2S Adapter', function () { config.setConfig({ s2sConfig: CONFIG }); adapter.callBids(REQUEST, BID_REQUESTS, addBidResponse, done, ajax); - requestBid = JSON.parse(requests[1].requestBody); + requestBid = JSON.parse(server.requests[1].requestBody); expect(requestBid.regs).to.not.exist; expect(requestBid.user).to.not.exist; @@ -796,7 +699,7 @@ describe('S2S Adapter', function () { }; adapter.callBids(REQUEST, consentBidRequest, addBidResponse, done, ajax); - let requestBid = JSON.parse(requests[0].requestBody); + let requestBid = JSON.parse(server.requests[0].requestBody); expect(requestBid.us_privacy).is.equal('1YNN'); expect(requestBid.gdpr).is.equal(1); @@ -806,16 +709,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'; @@ -835,7 +728,7 @@ describe('S2S Adapter', function () { digiTrustBidRequest[0].bids[0].userId = { digitrustid: { data: digiTrustObj } }; adapter.callBids(REQUEST, digiTrustBidRequest, addBidResponse, done, ajax); - let requestBid = JSON.parse(requests[0].requestBody); + let requestBid = JSON.parse(server.requests[0].requestBody); expect(requestBid.user.ext.digitrust).to.deep.equal({ id: digiTrustObj.id, @@ -845,7 +738,7 @@ describe('S2S Adapter', function () { digiTrustObj.privacy.optout = true; adapter.callBids(REQUEST, digiTrustBidRequest, addBidResponse, done, ajax); - requestBid = JSON.parse(requests[1].requestBody); + requestBid = JSON.parse(server.requests[1].requestBody); expect(requestBid.user && request.user.ext && requestBid.user.ext.digitrust).to.not.exist; }); @@ -859,7 +752,7 @@ describe('S2S Adapter', function () { config.setConfig(_config); adapter.callBids(REQUEST, BID_REQUESTS, addBidResponse, done, ajax); - const requestBid = JSON.parse(requests[0].requestBody); + const requestBid = JSON.parse(server.requests[0].requestBody); expect(requestBid.device).to.deep.equal({ ifa: '6D92078A-8246-4BA4-AE5B-76104861E7DC', w: window.innerWidth, @@ -884,7 +777,7 @@ describe('S2S Adapter', function () { config.setConfig(_config); adapter.callBids(REQUEST, BID_REQUESTS, addBidResponse, done, ajax); - const requestBid = JSON.parse(requests[0].requestBody); + const requestBid = JSON.parse(server.requests[0].requestBody); expect(requestBid.device).to.deep.equal({ ifa: '6D92078A-8246-4BA4-AE5B-76104861E7DC', w: window.innerWidth, @@ -896,6 +789,27 @@ describe('S2S Adapter', function () { }); }); + it('adds debugging value from storedAuctionResponse to OpenRTB', function () { + const s2sConfig = Object.assign({}, CONFIG, { + endpoint: 'https://prebid.adnxs.com/pbs/v1/openrtb2/auction' + }); + const _config = { + s2sConfig: s2sConfig, + device: { ifa: '6D92078A-8246-4BA4-AE5B-76104861E7DC' }, + app: { bundle: 'com.test.app' } + }; + + config.setConfig(_config); + adapter.callBids(REQUEST, BID_REQUESTS, addBidResponse, done, ajax); + const requestBid = JSON.parse(server.requests[0].requestBody); + expect(requestBid.imp).to.exist.and.to.be.a('array'); + expect(requestBid.imp).to.have.lengthOf(1); + expect(requestBid.imp[0].ext).to.exist.and.to.be.a('object'); + expect(requestBid.imp[0].ext.prebid).to.exist.and.to.be.a('object'); + expect(requestBid.imp[0].ext.prebid.storedauctionresponse).to.exist.and.to.be.a('object'); + expect(requestBid.imp[0].ext.prebid.storedauctionresponse.id).to.equal('11111'); + }); + it('adds device.w and device.h even if the config lacks a device object', function () { const s2sConfig = Object.assign({}, CONFIG, { endpoint: 'https://prebid.adnxs.com/pbs/v1/openrtb2/auction' @@ -908,7 +822,7 @@ describe('S2S Adapter', function () { config.setConfig(_config); adapter.callBids(REQUEST, BID_REQUESTS, addBidResponse, done, ajax); - const requestBid = JSON.parse(requests[0].requestBody); + const requestBid = JSON.parse(server.requests[0].requestBody); expect(requestBid.device).to.deep.equal({ w: window.innerWidth, h: window.innerHeight @@ -930,7 +844,7 @@ describe('S2S Adapter', function () { config.setConfig(_config); adapter.callBids(REQUEST, BID_REQUESTS, addBidResponse, done, ajax); - const requestBid = JSON.parse(requests[0].requestBody); + const requestBid = JSON.parse(server.requests[0].requestBody); expect(requestBid.imp[0].native).to.deep.equal({ request: JSON.stringify({ @@ -985,14 +899,37 @@ describe('S2S Adapter', function () { const _config = { s2sConfig: s2sConfig, + site: { + publisher: { + id: '1234', + domain: 'test.com' + }, + content: { + language: 'en' + } + } }; config.setConfig(_config); adapter.callBids(REQUEST, BID_REQUESTS, addBidResponse, done, ajax); - const requestBid = JSON.parse(requests[0].requestBody); + const requestBid = JSON.parse(server.requests[0].requestBody); expect(requestBid.site).to.exist.and.to.be.a('object'); expect(requestBid.site.publisher).to.exist.and.to.be.a('object'); + expect(requestBid.site.publisher.id).to.exist.and.to.be.a('string'); + expect(requestBid.site.publisher.domain).to.exist.and.to.be.a('string'); expect(requestBid.site.page).to.exist.and.to.be.a('string'); + expect(requestBid.site.content).to.exist.and.to.be.a('object'); + expect(requestBid.site.content.language).to.exist.and.to.be.a('string'); + expect(requestBid.site).to.deep.equal({ + publisher: { + id: '1', + domain: 'test.com' + }, + content: { + language: 'en' + }, + page: 'http://mytestpage.com' + }); }); it('adds appnexus aliases to request', function () { @@ -1011,7 +948,7 @@ describe('S2S Adapter', function () { adapter.callBids(request, BID_REQUESTS, addBidResponse, done, ajax); - const requestBid = JSON.parse(requests[0].requestBody); + const requestBid = JSON.parse(server.requests[0].requestBody); expect(requestBid.ext).to.deep.equal({ prebid: { @@ -1045,7 +982,7 @@ describe('S2S Adapter', function () { $$PREBID_GLOBAL$$.aliasBidder('appnexus', alias); adapter.callBids(request, BID_REQUESTS, addBidResponse, done, ajax); - const requestBid = JSON.parse(requests[0].requestBody); + const requestBid = JSON.parse(server.requests[0].requestBody); expect(requestBid.ext).to.deep.equal({ prebid: { @@ -1074,7 +1011,7 @@ describe('S2S Adapter', function () { }; adapter.callBids(myRequest, BID_REQUESTS, addBidResponse, done, ajax); - const requestBid = JSON.parse(requests[0].requestBody); + const requestBid = JSON.parse(server.requests[0].requestBody); expect(requestBid.imp[0].ext.appnexus).to.exist; expect(requestBid.imp[0].ext.appnexus.placement_id).to.exist.and.to.equal(10433394); @@ -1087,27 +1024,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 () { @@ -1119,7 +1035,7 @@ describe('S2S Adapter', function () { let bidRequest = utils.deepClone(BID_REQUESTS); adapter.callBids(REQUEST, bidRequest, addBidResponse, done, ajax); - let requestBid = JSON.parse(requests[0].requestBody); + let requestBid = JSON.parse(server.requests[0].requestBody); expect(requestBid.bidders).to.contain('appnexus').and.to.have.lengthOf(1); expect(requestBid.account).is.equal('1'); @@ -1133,7 +1049,7 @@ describe('S2S Adapter', function () { let bidRequest = utils.deepClone(BID_REQUESTS); adapter.callBids(REQUEST, bidRequest, addBidResponse, done, ajax); - let requestBid = JSON.parse(requests[0].requestBody); + let requestBid = JSON.parse(server.requests[0].requestBody); expect(requestBid.bidders).to.contain('appnexus').and.to.have.lengthOf(1); expect(requestBid.account).is.equal('1'); @@ -1145,7 +1061,7 @@ describe('S2S Adapter', function () { bidRequest = utils.deepClone(BID_REQUESTS); adapter.callBids(REQUEST, bidRequest, addBidResponse, done, ajax); - requestBid = JSON.parse(requests[0].requestBody); + requestBid = JSON.parse(server.requests[0].requestBody); expect(requestBid.bidders).to.contain('appnexus').and.to.have.lengthOf(1); expect(requestBid.account).is.equal('1'); @@ -1169,7 +1085,7 @@ describe('S2S Adapter', function () { config.setConfig(_config); adapter.callBids(REQUEST, BID_REQUESTS, addBidResponse, done, ajax); - const requestBid = JSON.parse(requests[0].requestBody); + const requestBid = JSON.parse(server.requests[0].requestBody); expect(requestBid.imp[0].ext.appnexus).to.haveOwnProperty('key'); expect(requestBid.imp[0].ext.appnexus.key).to.be.equal('value') }); @@ -1190,11 +1106,13 @@ describe('S2S Adapter', function () { lipb: { lipbid: 'li-xyz', segments: ['segA', 'segB'] - } + }, + idl_env: '0000-1111-2222-3333' }; + userIdBidRequest[0].bids[0].userIdAsEids = createEidsArray(userIdBidRequest[0].bids[0].userId); adapter.callBids(REQUEST, userIdBidRequest, addBidResponse, done, ajax); - let requestBid = JSON.parse(requests[0].requestBody); + let requestBid = JSON.parse(server.requests[0].requestBody); expect(typeof requestBid.user.ext.eids).is.equal('object'); expect(Array.isArray(requestBid.user.ext.eids)).to.be.true; expect(requestBid.user.ext.eids.filter(eid => eid.source === 'adserver.org')).is.not.empty; @@ -1210,6 +1128,8 @@ describe('S2S Adapter', function () { expect(requestBid.user.ext.eids.filter(eid => eid.source === 'liveintent.com')[0].ext.segments.length).is.equal(2); expect(requestBid.user.ext.eids.filter(eid => eid.source === 'liveintent.com')[0].ext.segments[0]).is.equal('segA'); expect(requestBid.user.ext.eids.filter(eid => eid.source === 'liveintent.com')[0].ext.segments[1]).is.equal('segB'); + // LiveRamp should exist + expect(requestBid.user.ext.eids.filter(eid => eid.source === 'liveramp.com')[0].uids[0].id).is.equal('0000-1111-2222-3333'); }); it('when config \'currency.adServerCurrency\' value is an array: ORTB has property \'cur\' value set to a single item array', function () { @@ -1223,7 +1143,7 @@ describe('S2S Adapter', function () { const bidRequests = utils.deepClone(BID_REQUESTS); adapter.callBids(REQUEST, bidRequests, addBidResponse, done, ajax); - const parsedRequestBody = JSON.parse(requests[0].requestBody); + const parsedRequestBody = JSON.parse(server.requests[0].requestBody); expect(parsedRequestBody.cur).to.deep.equal(['USD']); }); @@ -1238,7 +1158,7 @@ describe('S2S Adapter', function () { const bidRequests = utils.deepClone(BID_REQUESTS); adapter.callBids(REQUEST, bidRequests, addBidResponse, done, ajax); - const parsedRequestBody = JSON.parse(requests[1].requestBody); + const parsedRequestBody = JSON.parse(server.requests[1].requestBody); expect(parsedRequestBody.cur).to.deep.equal(['NZ']); }); @@ -1250,7 +1170,7 @@ describe('S2S Adapter', function () { const bidRequests = utils.deepClone(BID_REQUESTS); adapter.callBids(REQUEST, bidRequests, addBidResponse, done, ajax); - const parsedRequestBody = JSON.parse(requests[0].requestBody); + const parsedRequestBody = JSON.parse(server.requests[0].requestBody); expect(typeof parsedRequestBody.cur).to.equal('undefined'); }); @@ -1271,7 +1191,7 @@ describe('S2S Adapter', function () { config.setConfig(_config); adapter.callBids(REQUEST, BID_REQUESTS, addBidResponse, done, ajax); - const requestBid = JSON.parse(requests[0].requestBody); + const requestBid = JSON.parse(server.requests[0].requestBody); expect(requestBid.ext.prebid.targeting).to.haveOwnProperty('includebidderkeys'); expect(requestBid.ext.prebid.targeting.includebidderkeys).to.equal(false); @@ -1294,7 +1214,7 @@ describe('S2S Adapter', function () { config.setConfig(_config); adapter.callBids(REQUEST, BID_REQUESTS, addBidResponse, done, ajax); - const requestBid = JSON.parse(requests[0].requestBody); + const requestBid = JSON.parse(server.requests[0].requestBody); expect(requestBid.ext.prebid.targeting).to.haveOwnProperty('includewinners'); expect(requestBid.ext.prebid.targeting.includewinners).to.equal(true); @@ -1315,7 +1235,7 @@ describe('S2S Adapter', function () { config.setConfig(_config); adapter.callBids(REQUEST, BID_REQUESTS, addBidResponse, done, ajax); - const requestBid = JSON.parse(requests[0].requestBody); + const requestBid = JSON.parse(server.requests[0].requestBody); expect(requestBid).to.haveOwnProperty('ext'); expect(requestBid.ext).to.haveOwnProperty('prebid'); @@ -1346,7 +1266,7 @@ describe('S2S Adapter', function () { config.setConfig(_config); adapter.callBids(REQUEST, BID_REQUESTS, addBidResponse, done, ajax); - const requestBid = JSON.parse(requests[0].requestBody); + const requestBid = JSON.parse(server.requests[0].requestBody); expect(requestBid).to.haveOwnProperty('ext'); expect(requestBid.ext).to.haveOwnProperty('prebid'); @@ -1379,7 +1299,7 @@ describe('S2S Adapter', function () { config.setConfig(_config); adapter.callBids(REQUEST, BID_REQUESTS, addBidResponse, done, ajax); - const requestBid = JSON.parse(requests[0].requestBody); + const requestBid = JSON.parse(server.requests[0].requestBody); expect(requestBid).to.haveOwnProperty('ext'); expect(requestBid.ext).to.haveOwnProperty('prebid'); @@ -1415,9 +1335,127 @@ describe('S2S Adapter', function () { }; bidRequests[0].bids[0].schain = schainObject; adapter.callBids(REQUEST, bidRequests, addBidResponse, done, ajax); - const parsedRequestBody = JSON.parse(requests[0].requestBody); + const parsedRequestBody = JSON.parse(server.requests[0].requestBody); expect(parsedRequestBody.source.ext.schain).to.deep.equal(schainObject); - }) + }); + + it('passes first party data in request', () => { + const s2sBidRequest = utils.deepClone(REQUEST); + const bidRequests = utils.deepClone(BID_REQUESTS); + + const commonContext = { + keywords: ['power tools'], + search: 'drill' + }; + const commonUser = { + keywords: ['a', 'b'], + gender: 'M' + }; + + const context = { + content: { userrating: 4 }, + data: { + pageType: 'article', + category: 'tools' + } + }; + const user = { + yob: '1984', + geo: { country: 'ca' }, + data: { + registered: true, + interests: ['cars'] + } + }; + const allowedBidders = [ 'rubicon', 'appnexus' ]; + + const expected = allowedBidders.map(bidder => ({ + bidders: [ bidder ], + config: { fpd: { site: context, user } } + })); + + config.setConfig({ fpd: { context: commonContext, user: commonUser } }); + config.setBidderConfig({ bidders: allowedBidders, config: { fpd: { context, user } } }); + adapter.callBids(s2sBidRequest, bidRequests, addBidResponse, done, ajax); + const parsedRequestBody = JSON.parse(server.requests[0].requestBody); + expect(parsedRequestBody.ext.prebid.bidderconfig).to.deep.equal(expected); + expect(parsedRequestBody.site.ext.data).to.deep.equal(commonContext); + expect(parsedRequestBody.user.ext.data).to.deep.equal(commonUser); + }); + + describe('pbAdSlot config', function () { + it('should not send \"imp.ext.context.data.adslot\" if \"fpd.context\" is undefined', function () { + const ortb2Config = utils.deepClone(CONFIG); + ortb2Config.endpoint = 'https://prebid.adnxs.com/pbs/v1/openrtb2/auction'; + const consentConfig = { s2sConfig: ortb2Config }; + config.setConfig(consentConfig); + const bidRequest = utils.deepClone(REQUEST); + + adapter.callBids(bidRequest, BID_REQUESTS, addBidResponse, done, ajax); + const parsedRequestBody = JSON.parse(server.requests[0].requestBody); + + expect(parsedRequestBody.imp).to.be.a('array'); + expect(parsedRequestBody.imp[0]).to.be.a('object'); + expect(parsedRequestBody.imp[0]).to.not.have.deep.nested.property('ext.context.data.adslot'); + }); + + it('should not send \"imp.ext.context.data.adslot\" if \"fpd.context.pbAdSlot\" is undefined', function () { + const ortb2Config = utils.deepClone(CONFIG); + ortb2Config.endpoint = 'https://prebid.adnxs.com/pbs/v1/openrtb2/auction'; + const consentConfig = { s2sConfig: ortb2Config }; + config.setConfig(consentConfig); + const bidRequest = utils.deepClone(REQUEST); + bidRequest.ad_units[0].fpd = {}; + + adapter.callBids(bidRequest, BID_REQUESTS, addBidResponse, done, ajax); + const parsedRequestBody = JSON.parse(server.requests[0].requestBody); + + expect(parsedRequestBody.imp).to.be.a('array'); + expect(parsedRequestBody.imp[0]).to.be.a('object'); + expect(parsedRequestBody.imp[0]).to.not.have.deep.nested.property('ext.context.data.adslot'); + }); + + it('should not send \"imp.ext.context.data.adslot\" if \"fpd.context.pbAdSlot\" is empty string', function () { + const ortb2Config = utils.deepClone(CONFIG); + ortb2Config.endpoint = 'https://prebid.adnxs.com/pbs/v1/openrtb2/auction'; + const consentConfig = { s2sConfig: ortb2Config }; + config.setConfig(consentConfig); + const bidRequest = utils.deepClone(REQUEST); + bidRequest.ad_units[0].fpd = { + context: { + pbAdSlot: '' + } + }; + + adapter.callBids(bidRequest, BID_REQUESTS, addBidResponse, done, ajax); + const parsedRequestBody = JSON.parse(server.requests[0].requestBody); + + expect(parsedRequestBody.imp).to.be.a('array'); + expect(parsedRequestBody.imp[0]).to.be.a('object'); + expect(parsedRequestBody.imp[0]).to.not.have.deep.nested.property('ext.context.data.adslot'); + }); + + it('should send \"imp.ext.context.data.adslot\" if \"fpd.context.pbAdSlot\" value is a non-empty string', function () { + const ortb2Config = utils.deepClone(CONFIG); + ortb2Config.endpoint = 'https://prebid.adnxs.com/pbs/v1/openrtb2/auction'; + const consentConfig = { s2sConfig: ortb2Config }; + config.setConfig(consentConfig); + const bidRequest = utils.deepClone(REQUEST); + bidRequest.ad_units[0].fpd = { + context: { + pbAdSlot: '/a/b/c' + } + }; + + adapter.callBids(bidRequest, BID_REQUESTS, addBidResponse, done, ajax); + const parsedRequestBody = JSON.parse(server.requests[0].requestBody); + + expect(parsedRequestBody.imp).to.be.a('array'); + expect(parsedRequestBody.imp[0]).to.be.a('object'); + expect(parsedRequestBody.imp[0]).to.have.deep.nested.property('ext.context.data.adslot'); + expect(parsedRequestBody.imp[0].ext.context.data.adslot).to.equal('/a/b/c'); + }); + }); }); describe('response handler', function () { @@ -1443,47 +1481,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)); @@ -1518,7 +1515,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); @@ -1536,7 +1533,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); @@ -1545,11 +1542,32 @@ describe('S2S Adapter', function () { expect(response).to.have.property('dealId', 'test-dealid'); }); + 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 set the bidResponse currency to whats in the PBS response', function() { server.respondWith(JSON.stringify(RESPONSE_OPENRTB)); - let ortb2Config = utils.deepClone(CONFIG); - ortb2Config.endpoint = 'https://prebid.adnxs.com/pbs/v1/openrtb2/auction'; - config.setConfig({ s2sConfig: ortb2Config }); adapter.callBids(REQUEST, BID_REQUESTS, addBidResponse, done, ajax); server.respond(); sinon.assert.calledOnce(addBidResponse); @@ -1560,9 +1578,6 @@ describe('S2S Adapter', function () { it('should set the default bidResponse currency when not specified in OpenRTB', function() { let modifiedResponse = utils.deepClone(RESPONSE_OPENRTB); modifiedResponse.cur = ''; - let ortb2Config = utils.deepClone(CONFIG); - ortb2Config.endpoint = 'https://prebid.adnxs.com/pbs/v1/openrtb2/auction'; - config.setConfig({ s2sConfig: ortb2Config }); server.respondWith(JSON.stringify(modifiedResponse)); adapter.callBids(REQUEST, BID_REQUESTS, addBidResponse, done, ajax); server.respond(); @@ -1571,11 +1586,23 @@ describe('S2S Adapter', function () { expect(pbjsResponse).to.have.property('currency', 'USD'); }); - 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 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' }); }); @@ -1617,25 +1644,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' @@ -1657,6 +1665,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 () { @@ -1784,42 +1794,17 @@ 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 () { - let xhr; - let requests; let logErrorSpy; beforeEach(function () { - xhr = sinon.useFakeXMLHttpRequest(); - requests = []; - xhr.onCreate = request => requests.push(request); logErrorSpy = sinon.spy(utils, 'logError'); resetSyncedStatus(); }); afterEach(function () { - xhr.restore(); utils.logError.restore(); }); @@ -1829,7 +1814,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 }); @@ -1842,7 +1827,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 }); @@ -1889,8 +1874,8 @@ describe('S2S Adapter', function () { expect(vendorConfig).to.have.property('adapter', 'prebidServer'); expect(vendorConfig.bidders).to.deep.equal(['appnexus']); expect(vendorConfig.enabled).to.be.true; - expect(vendorConfig).to.have.property('endpoint', '//prebid.adnxs.com/pbs/v1/openrtb2/auction'); - expect(vendorConfig).to.have.property('syncEndpoint', '//prebid.adnxs.com/pbs/v1/cookie_sync'); + expect(vendorConfig).to.have.property('endpoint', 'https://prebid.adnxs.com/pbs/v1/openrtb2/auction'); + expect(vendorConfig).to.have.property('syncEndpoint', 'https://prebid.adnxs.com/pbs/v1/cookie_sync'); expect(vendorConfig).to.have.property('timeout', 750); }); @@ -1910,8 +1895,8 @@ describe('S2S Adapter', function () { expect(vendorConfig).to.have.property('adapter', 'prebidServer'); expect(vendorConfig.bidders).to.deep.equal(['rubicon']); expect(vendorConfig.enabled).to.be.true; - expect(vendorConfig).to.have.property('endpoint', '//prebid-server.rubiconproject.com/openrtb2/auction'); - expect(vendorConfig).to.have.property('syncEndpoint', '//prebid-server.rubiconproject.com/cookie_sync'); + expect(vendorConfig).to.have.property('endpoint', 'https://prebid-server.rubiconproject.com/openrtb2/auction'); + expect(vendorConfig).to.have.property('syncEndpoint', 'https://prebid-server.rubiconproject.com/cookie_sync'); expect(vendorConfig).to.have.property('timeout', 750); }); @@ -1922,8 +1907,8 @@ describe('S2S Adapter', function () { 'bidders': ['rubicon'], 'defaultVendor': 'rubicon', 'enabled': true, - 'endpoint': '//prebid-server.rubiconproject.com/openrtb2/auction', - 'syncEndpoint': '//prebid-server.rubiconproject.com/cookie_sync', + 'endpoint': 'https://prebid-server.rubiconproject.com/openrtb2/auction', + 'syncEndpoint': 'https://prebid-server.rubiconproject.com/cookie_sync', 'timeout': 750 }) }); @@ -1944,8 +1929,8 @@ describe('S2S Adapter', function () { accountId: 'abc', bidders: ['rubicon'], defaultVendor: 'rubicon', - endpoint: '//prebid-server.rubiconproject.com/openrtb2/auction', - syncEndpoint: '//prebid-server.rubiconproject.com/cookie_sync' + endpoint: 'https://prebid-server.rubiconproject.com/openrtb2/auction', + syncEndpoint: 'https://prebid-server.rubiconproject.com/cookie_sync', }) }); @@ -2049,7 +2034,7 @@ describe('S2S Adapter', function () { adapter.callBids(request, bidRequest, addBidResponse, done, ajax); - const requestBid = JSON.parse(requests[0].requestBody); + const requestBid = JSON.parse(server.requests[0].requestBody); expect(requestBid.bidders).to.deep.equal(['appnexus', 'rubicon']); }); }); diff --git a/test/spec/modules/prebidmanagerAnalyticsAdapter_spec.js b/test/spec/modules/prebidmanagerAnalyticsAdapter_spec.js index cd414a70236..e87be40314c 100644 --- a/test/spec/modules/prebidmanagerAnalyticsAdapter_spec.js +++ b/test/spec/modules/prebidmanagerAnalyticsAdapter_spec.js @@ -1,12 +1,10 @@ -import prebidmanagerAnalytics from 'modules/prebidmanagerAnalyticsAdapter'; +import prebidmanagerAnalytics from 'modules/prebidmanagerAnalyticsAdapter.js'; import {expect} from 'chai'; +import {server} from 'test/mocks/xhr.js'; let events = require('src/events'); let constants = require('src/constants.json'); describe('Prebid Manager Analytics Adapter', function () { - let xhr; - let requests; - let bidWonEvent = { 'bidderCode': 'appnexus', 'width': 300, @@ -33,18 +31,8 @@ describe('Prebid Manager Analytics Adapter', function () { 'adUrl': 'ad url' }; - before(function () { - xhr = sinon.useFakeXMLHttpRequest(); - xhr.onCreate = request => requests.push(request); - }); - - after(function () { - xhr.restore(); - }); - describe('Prebid Manager Analytic tests', function () { beforeEach(function () { - requests = []; sinon.stub(events, 'getEvents').returns([]); }); @@ -67,7 +55,6 @@ describe('Prebid Manager Analytics Adapter', function () { }); it('bid won event', function() { - xhr.onCreate = request => requests.push(request); let bundleId = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'; prebidmanagerAnalytics.enableAnalytics({ provider: 'prebidmanager', @@ -79,11 +66,11 @@ describe('Prebid Manager Analytics Adapter', function () { events.emit(constants.EVENTS.BID_WON, bidWonEvent); prebidmanagerAnalytics.flush(); - expect(requests.length).to.equal(1); - expect(requests[0].url).to.equal('https://endpoint.prebidmanager.com/endpoint'); - expect(requests[0].requestBody.substring(0, 2)).to.equal('1:'); + expect(server.requests.length).to.equal(1); + expect(server.requests[0].url).to.equal('https://endpoint.prebidmanager.com/endpoint'); + expect(server.requests[0].requestBody.substring(0, 2)).to.equal('1:'); - const pmEvents = JSON.parse(requests[0].requestBody.substring(2)); + const pmEvents = JSON.parse(server.requests[0].requestBody.substring(2)); expect(pmEvents.pageViewId).to.exist; expect(pmEvents.bundleId).to.equal(bundleId); expect(pmEvents.ver).to.equal(1); @@ -114,4 +101,38 @@ describe('Prebid Manager Analytics Adapter', function () { sinon.assert.callCount(prebidmanagerAnalytics.track, 6); }); }); + + describe('build utm tag data', function () { + beforeEach(function () { + localStorage.setItem('pm_utm_source', 'utm_source'); + localStorage.setItem('pm_utm_medium', 'utm_medium'); + localStorage.setItem('pm_utm_campaign', 'utm_camp'); + localStorage.setItem('pm_utm_term', ''); + localStorage.setItem('pm_utm_content', ''); + }); + afterEach(function () { + localStorage.removeItem('pm_utm_source'); + localStorage.removeItem('pm_utm_medium'); + localStorage.removeItem('pm_utm_campaign'); + localStorage.removeItem('pm_utm_term'); + localStorage.removeItem('pm_utm_content'); + prebidmanagerAnalytics.disableAnalytics() + }); + it('should build utm data from local storage', function () { + prebidmanagerAnalytics.enableAnalytics({ + provider: 'prebidmanager', + options: { + bundleId: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' + } + }); + + const pmEvents = JSON.parse(server.requests[0].requestBody.substring(2)); + + expect(pmEvents.utmTags.utm_source).to.equal('utm_source'); + expect(pmEvents.utmTags.utm_medium).to.equal('utm_medium'); + expect(pmEvents.utmTags.utm_campaign).to.equal('utm_camp'); + expect(pmEvents.utmTags.utm_term).to.equal(''); + expect(pmEvents.utmTags.utm_content).to.equal(''); + }); + }); }); diff --git a/test/spec/modules/priceFloorsSchema.json b/test/spec/modules/priceFloorsSchema.json new file mode 100644 index 00000000000..7b524da381e --- /dev/null +++ b/test/spec/modules/priceFloorsSchema.json @@ -0,0 +1,86 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "A Price Floors object which is parsed and used to enforce dynamic floors depending on the properties of the json", + "type": "object", + "title": "Price Floors Enforcement", + "required": [ + "schema", + "values" + ], + "properties": { + "schema": { + "type": "object", + "description": "Defines the schema of the rules", + "required": [ + "fields" + ], + "properties": { + "fields": { + "type": "array", + "description": "The list of fields to be used for matching criteria of a bid response with a price floor", + "minItems": 1, + "uniqueItems": true, + "additionalItems": false, + "items": { + "type": "string" + } + }, + "delimiter": { + "type": "string", + "description": "The character used to differentiate the fields inside a single rule", + "examples": [ + "|", + "^", + "~" + ] + } + } + }, + "values": { + "type": "object", + "description": "A object with key : value pairs which constitutes a rule and floor", + "additionalProperties": { + "type": "number" + }, + "minProperties": 1, + "examples": [ + { + "123456/someSlot|300x250|www.prebid.org": 1.5, + "123456/someSlot|300x600|www.prebid.org": 2.5, + "123456/someSlot|300x600|*": 1.2, + "123456/someSlot|*|*": 0.8 + } + ] + }, + "currency": { + "type": "string", + "description": "The three digit Currency Code which the floors are provided in", + "examples": [ + "USD", + "EUR", + "JPY" + ], + "pattern": "^[a-zA-Z]{3}$" + }, + "modelVersion": { + "type": "string", + "description": "The floor modeling name to be used for tracking", + "examples": [ + "Prebid-Floor-Model-1.2" + ] + }, + "skipRate": { + "type": "integer", + "description": "The skip rate as to which flooring will be 'turned off' for a given auction", + "minimum": 0, + "maximum": 100 + }, + "default": { + "type": "number", + "description": "The default floor to use if no entry in the value matches a bid response", + "examples": [ + 0.75 + ] + } + } +} \ No newline at end of file diff --git a/test/spec/modules/priceFloors_spec.js b/test/spec/modules/priceFloors_spec.js new file mode 100644 index 00000000000..55aa7900252 --- /dev/null +++ b/test/spec/modules/priceFloors_spec.js @@ -0,0 +1,972 @@ +import {expect} from 'chai'; +import * as utils from 'src/utils.js'; +import { getGlobal } from 'src/prebidGlobal.js'; +import CONSTANTS from 'src/constants.json'; +import { + _floorDataForAuction, + getFloorsDataForAuction, + getFirstMatchingFloor, + getFloor, + handleSetFloorsConfig, + requestBidsHook, + isFloorsDataValid, + addBidResponseHook, + fieldMatchingFunctions, + allowedFields +} from 'modules/priceFloors.js'; + +describe('the price floors module', function () { + let logErrorSpy; + let logWarnSpy; + let sandbox; + const basicFloorData = { + modelVersion: 'basic model', + currency: 'USD', + schema: { + delimiter: '|', + fields: ['mediaType'] + }, + values: { + 'banner': 1.0, + 'video': 5.0, + '*': 2.5 + } + }; + const basicFloorConfig = { + enabled: true, + auctionDelay: 0, + endpoint: {}, + enforcement: { + enforceJS: true, + enforcePBS: false, + floorDeals: false, + bidAdjustment: true + }, + data: basicFloorData + } + const basicBidRequest = { + bidder: 'rubicon', + adUnitCode: 'test_div_1', + auctionId: '1234-56-789', + }; + + function getAdUnitMock(code = 'adUnit-code') { + return { + code, + mediaTypes: {banner: { sizes: [[300, 200], [300, 600]] }, native: {}}, + bids: [{bidder: 'someBidder'}, {bidder: 'someOtherBidder'}] + }; + } + beforeEach(function() { + sandbox = sinon.sandbox.create(); + logErrorSpy = sinon.spy(utils, 'logError'); + logWarnSpy = sinon.spy(utils, 'logWarn'); + }); + + afterEach(function() { + handleSetFloorsConfig({enabled: false}); + sandbox.restore(); + utils.logError.restore(); + utils.logWarn.restore(); + // reset global bidder settings so no weird test side effects + getGlobal().bidderSettings = {}; + }); + + describe('getFloorsDataForAuction', function () { + it('converts basic input floor data into a floorData map for the auction correctly', function () { + // basic input where nothing needs to be updated + expect(getFloorsDataForAuction(basicFloorData)).to.deep.equal(basicFloorData); + + // if cur and delim not defined then default to correct ones (usd and |) + let inputFloorData = utils.deepClone(basicFloorData); + delete inputFloorData.currency; + delete inputFloorData.schema.delimiter; + expect(getFloorsDataForAuction(inputFloorData)).to.deep.equal(basicFloorData); + + // should not use defaults if differing values + inputFloorData.currency = 'EUR' + inputFloorData.schema.delimiter = '^' + let resultingData = getFloorsDataForAuction(inputFloorData); + expect(resultingData.currency).to.equal('EUR'); + expect(resultingData.schema.delimiter).to.equal('^'); + }); + + it('converts more complex floor data correctly', function () { + let inputFloorData = { + schema: { + fields: ['mediaType', 'size', 'domain'] + }, + values: { + 'banner|300x250|prebid.org': 1.0, + 'video|640x480|prebid.org': 5.0, + 'banner|728x90|rubicon.com': 3.5, + 'video|600x300|appnexus.com': 3.5, + '*|*|prebid.org': 3.5, + } + }; + let resultingData = getFloorsDataForAuction(inputFloorData); + expect(resultingData).to.deep.equal({ + currency: 'USD', + schema: { + delimiter: '|', + fields: ['mediaType', 'size', 'domain'] + }, + values: { + 'banner|300x250|prebid.org': 1.0, + 'video|640x480|prebid.org': 5.0, + 'banner|728x90|rubicon.com': 3.5, + 'video|600x300|appnexus.com': 3.5, + '*|*|prebid.org': 3.5, + } + }); + }); + + it('adds adUnitCode to the schema if the floorData comes from adUnit level to maintain scope', function () { + let inputFloorData = utils.deepClone(basicFloorData); + let resultingData = getFloorsDataForAuction(inputFloorData, 'test_div_1'); + expect(resultingData).to.deep.equal({ + modelVersion: 'basic model', + currency: 'USD', + schema: { + delimiter: '|', + fields: ['adUnitCode', 'mediaType'] + }, + values: { + 'test_div_1|banner': 1.0, + 'test_div_1|video': 5.0, + 'test_div_1|*': 2.5 + } + }); + + // uses the right delim if not | + inputFloorData.schema.delimiter = '^'; + resultingData = getFloorsDataForAuction(inputFloorData, 'this_is_a_div'); + expect(resultingData).to.deep.equal({ + modelVersion: 'basic model', + currency: 'USD', + schema: { + delimiter: '^', + fields: ['adUnitCode', 'mediaType'] + }, + values: { + 'this_is_a_div^banner': 1.0, + 'this_is_a_div^video': 5.0, + 'this_is_a_div^*': 2.5 + } + }); + }); + }); + + describe('getFirstMatchingFloor', function () { + it('selects the right floor for different mediaTypes', function () { + // banner with * size (not in rule file so does not do anything) + expect(getFirstMatchingFloor({...basicFloorData}, basicBidRequest, {mediaType: 'banner', size: '*'})).to.deep.equal({ + matchingFloor: 1.0, + matchingData: 'banner', + matchingRule: 'banner' + }); + // video with * size (not in rule file so does not do anything) + expect(getFirstMatchingFloor({...basicFloorData}, basicBidRequest, {mediaType: 'video', size: '*'})).to.deep.equal({ + matchingFloor: 5.0, + matchingData: 'video', + matchingRule: 'video' + }); + // native (not in the rule list) with * size (not in rule file so does not do anything) + expect(getFirstMatchingFloor({...basicFloorData}, basicBidRequest, {mediaType: 'native', size: '*'})).to.deep.equal({ + matchingFloor: 2.5, + matchingData: 'native', + matchingRule: '*' + }); + }); + it('selects the right floor for different sizes', function () { + let inputFloorData = { + currency: 'USD', + schema: { + delimiter: '|', + fields: ['size'] + }, + values: { + '300x250': 1.1, + '640x480': 2.2, + '728x90': 3.3, + '600x300': 4.4, + '*': 5.5, + } + } + // banner with 300x250 size + expect(getFirstMatchingFloor(inputFloorData, basicBidRequest, {mediaType: 'banner', size: [300, 250]})).to.deep.equal({ + matchingFloor: 1.1, + matchingData: '300x250', + matchingRule: '300x250' + }); + // video with 300x250 size + expect(getFirstMatchingFloor(inputFloorData, basicBidRequest, {mediaType: 'video', size: [300, 250]})).to.deep.equal({ + matchingFloor: 1.1, + matchingData: '300x250', + matchingRule: '300x250' + }); + // native (not in the rule list) with 300x600 size + expect(getFirstMatchingFloor(inputFloorData, basicBidRequest, {mediaType: 'native', size: [600, 300]})).to.deep.equal({ + matchingFloor: 4.4, + matchingData: '600x300', + matchingRule: '600x300' + }); + // n/a mediaType with a size not in file should go to catch all + expect(getFirstMatchingFloor(inputFloorData, basicBidRequest, {mediaType: undefined, size: [1, 1]})).to.deep.equal({ + matchingFloor: 5.5, + matchingData: '1x1', + matchingRule: '*' + }); + }); + it('selects the right floor for more complex rules', function () { + let inputFloorData = { + currency: 'USD', + schema: { + delimiter: '^', + fields: ['adUnitCode', 'mediaType', 'size'] + }, + values: { + 'test_div_1^banner^300x250': 1.1, + 'test_div_1^video^640x480': 2.2, + 'test_div_2^*^*': 3.3, + '*^banner^300x250': 4.4, + 'weird_div^*^300x250': 5.5 + }, + default: 0.5 + }; + // banner with 300x250 size + expect(getFirstMatchingFloor(inputFloorData, basicBidRequest, {mediaType: 'banner', size: [300, 250]})).to.deep.equal({ + matchingFloor: 1.1, + matchingData: 'test_div_1^banner^300x250', + matchingRule: 'test_div_1^banner^300x250' + }); + // video with 300x250 size -> No matching rule so should use default + expect(getFirstMatchingFloor(inputFloorData, basicBidRequest, {mediaType: 'video', size: [300, 250]})).to.deep.equal({ + matchingFloor: 0.5, + matchingData: 'test_div_1^video^300x250', + matchingRule: undefined + }); + // remove default and should still return the same floor as above since matches are cached + delete inputFloorData.default; + expect(getFirstMatchingFloor(inputFloorData, basicBidRequest, {mediaType: 'video', size: [300, 250]})).to.deep.equal({ + matchingFloor: 0.5, + matchingData: 'test_div_1^video^300x250', + matchingRule: undefined + }); + // update adUnitCode to test_div_2 with weird other params + let newBidRequest = { ...basicBidRequest, adUnitCode: 'test_div_2' } + expect(getFirstMatchingFloor(inputFloorData, newBidRequest, {mediaType: 'badmediatype', size: [900, 900]})).to.deep.equal({ + matchingFloor: 3.3, + matchingData: 'test_div_2^badmediatype^900x900', + matchingRule: 'test_div_2^*^*' + }); + }); + it('it does not break if floorData has bad values', function () { + let inputFloorData = {}; + expect(getFirstMatchingFloor(inputFloorData, basicBidRequest, {mediaType: 'banner', size: '*'})).to.deep.equal({ + matchingFloor: undefined + }); + // if default is there use it + inputFloorData = { default: 5.0 }; + expect(getFirstMatchingFloor(inputFloorData, basicBidRequest, {mediaType: 'banner', size: '*'})).to.deep.equal({ + matchingFloor: 5.0 + }); + }); + }); + describe('pre-auction tests', function () { + let exposedAdUnits; + const validateBidRequests = (getFloorExpected, FloorDataExpected) => { + exposedAdUnits.forEach(adUnit => adUnit.bids.forEach(bid => { + expect(bid.hasOwnProperty('getFloor')).to.equal(getFloorExpected); + expect(bid.floorData).to.deep.equal(FloorDataExpected); + })); + }; + const runStandardAuction = (adUnits = [getAdUnitMock('test_div_1')]) => { + requestBidsHook(config => exposedAdUnits = config.adUnits, { + auctionId: basicBidRequest.auctionId, + adUnits, + }); + }; + let fakeFloorProvider; + let clock; + let actualAllowedFields = allowedFields; + let actualFieldMatchingFunctions = fieldMatchingFunctions; + const defaultAllowedFields = [...allowedFields]; + const defaultMatchingFunctions = {...fieldMatchingFunctions}; + before(function () { + clock = sinon.useFakeTimers(); + }); + after(function () { + clock.restore(); + }); + beforeEach(function() { + fakeFloorProvider = sinon.fakeServer.create(); + }); + afterEach(function() { + fakeFloorProvider.restore(); + exposedAdUnits = undefined; + actualAllowedFields = [...defaultAllowedFields]; + actualFieldMatchingFunctions = {...defaultMatchingFunctions}; + }); + it('should not do floor stuff if no resulting floor object can be resolved for auciton', function () { + handleSetFloorsConfig({ + ...basicFloorConfig, + data: undefined + }); + runStandardAuction(); + validateBidRequests(false, undefined); + }); + it('should use adUnit level data if not setConfig or fetch has occured', function () { + handleSetFloorsConfig({ + ...basicFloorConfig, + data: undefined + }); + // attach floor data onto an adUnit and run an auction + let adUnitWithFloors1 = { + ...getAdUnitMock('adUnit-Div-1'), + floors: { + ...basicFloorData, + modelVersion: 'adUnit Model Version', // change the model name + } + }; + let adUnitWithFloors2 = { + ...getAdUnitMock('adUnit-Div-2'), + floors: { + ...basicFloorData, + values: { + 'banner': 5.0, + '*': 10.4 + } + } + }; + runStandardAuction([adUnitWithFloors1, adUnitWithFloors2]); + validateBidRequests(true, { + skipped: false, + modelVersion: 'adUnit Model Version', + location: 'adUnit', + }); + }); + it('bidRequests should have getFloor function and flooring meta data when setConfig occurs', function () { + handleSetFloorsConfig({...basicFloorConfig}); + runStandardAuction(); + validateBidRequests(true, { + skipped: false, + modelVersion: 'basic model', + location: 'setConfig', + }); + }); + it('should not overwrite previous data object if the new one is bad', function () { + handleSetFloorsConfig({...basicFloorConfig}); + handleSetFloorsConfig({ + ...basicFloorConfig, + data: undefined + }); + handleSetFloorsConfig({ + ...basicFloorConfig, + data: 5 + }); + handleSetFloorsConfig({ + ...basicFloorConfig, + data: { + schema: {fields: ['thisIsNotAllowedSoShouldFail']}, + values: {'*': 1.2}, + modelVersion: 'FAIL' + } + }); + runStandardAuction(); + validateBidRequests(true, { + skipped: false, + modelVersion: 'basic model', + location: 'setConfig', + }); + }); + it('should dynamically add new schema fileds and functions if added via setConfig', function () { + let deviceSpoof; + handleSetFloorsConfig({ + ...basicFloorConfig, + data: { + schema: {fields: ['deviceType']}, + values: { + 'mobile': 1.0, + 'desktop': 2.0, + 'tablet': 3.0, + '*': 4.0 + } + }, + additionalSchemaFields: { + deviceType: () => deviceSpoof + } + }); + expect(allowedFields).to.contain('deviceType'); + expect(fieldMatchingFunctions['deviceType']).to.be.a('function'); + + // run getFloor to make sure it selcts right stuff! (other params do not matter since we only are testing deviceType) + runStandardAuction(); + + // set deviceType to mobile; + deviceSpoof = 'mobile'; + exposedAdUnits[0].bids[0].auctionId = basicBidRequest.auctionId + expect(exposedAdUnits[0].bids[0].getFloor()).to.deep.equal({ + currency: 'USD', + floor: 1.0 // 'mobile': 1.0, + }); + + // set deviceType to desktop; + deviceSpoof = 'desktop'; + expect(exposedAdUnits[0].bids[0].getFloor()).to.deep.equal({ + currency: 'USD', + floor: 2.0 // 'desktop': 2.0, + }); + + // set deviceType to tablet; + deviceSpoof = 'tablet'; + expect(exposedAdUnits[0].bids[0].getFloor()).to.deep.equal({ + currency: 'USD', + floor: 3.0 // 'tablet': 3.0 + }); + + // set deviceType to unknown; + deviceSpoof = 'unknown'; + expect(exposedAdUnits[0].bids[0].getFloor()).to.deep.equal({ + currency: 'USD', + floor: 4.0 // '*': 4.0 + }); + }); + it('Should continue auction of delay is hit without a response from floor provider', function () { + handleSetFloorsConfig({...basicFloorConfig, auctionDelay: 250, endpoint: {url: 'http://www.fakeFloorProvider.json'}}); + + // start the auction it should delay and not immediately call `continueAuction` + runStandardAuction(); + + // exposedAdUnits should be undefined if the auction has not continued + expect(exposedAdUnits).to.be.undefined; + + // hit the delay + clock.tick(250); + + // log warn should be called and adUnits not undefined + expect(logWarnSpy.calledOnce).to.equal(true); + expect(exposedAdUnits).to.not.be.undefined; + + // the exposedAdUnits should be from the fetch not setConfig level data + validateBidRequests(true, { + skipped: false, + modelVersion: 'basic model', + location: 'setConfig', + }); + fakeFloorProvider.respond(); + }); + it('It should fetch if config has url and bidRequests have fetch level flooring meta data', function () { + // init the fake server with response stuff + let fetchFloorData = { + ...basicFloorData, + modelVersion: 'fetch model name', // change the model name + }; + fakeFloorProvider.respondWith(JSON.stringify(fetchFloorData)); + + // run setConfig indicating fetch + handleSetFloorsConfig({...basicFloorConfig, auctionDelay: 250, endpoint: {url: 'http://www.fakeFloorProvider.json'}}); + + // floor provider should be called + expect(fakeFloorProvider.requests.length).to.equal(1); + expect(fakeFloorProvider.requests[0].url).to.equal('http://www.fakeFloorProvider.json'); + + // start the auction it should delay and not immediately call `continueAuction` + runStandardAuction(); + + // exposedAdUnits should be undefined if the auction has not continued + expect(exposedAdUnits).to.be.undefined; + + // make the fetch respond + fakeFloorProvider.respond(); + expect(exposedAdUnits).to.not.be.undefined; + + // the exposedAdUnits should be from the fetch not setConfig level data + validateBidRequests(true, { + skipped: false, + modelVersion: 'fetch model name', + location: 'fetch', + }); + }); + it('Should not break if floor provider returns non json', function () { + fakeFloorProvider.respondWith('Not valid response'); + + // run setConfig indicating fetch + handleSetFloorsConfig({...basicFloorConfig, auctionDelay: 250, endpoint: {url: 'http://www.fakeFloorProvider.json'}}); + + // run the auction and make server respond + fakeFloorProvider.respond(); + runStandardAuction(); + + // should have caught the response error and still used setConfig data + validateBidRequests(true, { + skipped: false, + modelVersion: 'basic model', + location: 'setConfig', + }); + }); + it('should handle not using fetch correctly', function () { + // run setConfig twice indicating fetch + fakeFloorProvider.respondWith(JSON.stringify(basicFloorData)); + handleSetFloorsConfig({...basicFloorConfig, auctionDelay: 250, endpoint: {url: 'http://www.fakeFloorProvider.json'}}); + handleSetFloorsConfig({...basicFloorConfig, auctionDelay: 250, endpoint: {url: 'http://www.fakeFloorProvider.json'}}); + + // log warn should be called and server only should have one request + expect(logWarnSpy.calledOnce).to.equal(true); + expect(fakeFloorProvider.requests.length).to.equal(1); + expect(fakeFloorProvider.requests[0].url).to.equal('http://www.fakeFloorProvider.json'); + + // now we respond and then run again it should work and make another request + fakeFloorProvider.respond(); + handleSetFloorsConfig({...basicFloorConfig, auctionDelay: 250, endpoint: {url: 'http://www.fakeFloorProvider.json'}}); + fakeFloorProvider.respond(); + + // now warn still only called once and server called twice + expect(logWarnSpy.calledOnce).to.equal(true); + expect(fakeFloorProvider.requests.length).to.equal(2); + + // should log error if method is not GET for now + expect(logErrorSpy.calledOnce).to.equal(false); + handleSetFloorsConfig({...basicFloorConfig, endpoint: {url: 'http://www.fakeFloorProvider.json', method: 'POST'}}); + expect(logErrorSpy.calledOnce).to.equal(true); + }); + describe('isFloorsDataValid', function () { + it('should work correctly for fields array', function () { + let inputFloorData = utils.deepClone(basicFloorData); + expect(isFloorsDataValid(inputFloorData)).to.to.equal(true); + + // no fields array + delete inputFloorData.schema.fields; + expect(isFloorsDataValid(inputFloorData)).to.to.equal(false); + + // Fields is not an array + inputFloorData.schema.fields = {}; + expect(isFloorsDataValid(inputFloorData)).to.to.equal(false); + inputFloorData.schema.fields = undefined; + expect(isFloorsDataValid(inputFloorData)).to.to.equal(false); + inputFloorData.schema.fields = 'adUnitCode'; + expect(isFloorsDataValid(inputFloorData)).to.to.equal(false); + + // fields has a value that is not one of the "allowed" fields + inputFloorData.schema.fields = ['adUnitCode', 'notValidMapping']; + expect(isFloorsDataValid(inputFloorData)).to.to.equal(false); + }); + it('should work correctly for values object', function () { + let inputFloorData = utils.deepClone(basicFloorData); + expect(isFloorsDataValid(inputFloorData)).to.to.equal(true); + + // no values object + delete inputFloorData.values; + expect(isFloorsDataValid(inputFloorData)).to.to.equal(false); + + // values is not correct type + inputFloorData.values = []; + expect(isFloorsDataValid(inputFloorData)).to.to.equal(false); + inputFloorData.values = '123455/slot'; + expect(isFloorsDataValid(inputFloorData)).to.to.equal(false); + + // is an object but structure is wrong + inputFloorData.values = { + 'banner': 'not a floor value' + }; + expect(isFloorsDataValid(inputFloorData)).to.to.equal(false); + inputFloorData.values = { + 'banner': undefined + }; + expect(isFloorsDataValid(inputFloorData)).to.to.equal(false); + + // should be true if at least one rule is valid + inputFloorData.schema.fields = ['adUnitCode', 'mediaType']; + inputFloorData.values = { + 'banner': 1.0, + 'test-div-1|native': 1.0, // only valid rule should still work and delete the other rules + 'video': 1.0, + '*': 1.0 + }; + expect(isFloorsDataValid(inputFloorData)).to.to.equal(true); + expect(inputFloorData.values).to.deep.equal({ 'test-div-1|native': 1.0 }); + }); + }); + describe('getFloor', function () { + let bidRequest = { + ...basicBidRequest, + getFloor + }; + it('returns empty if no matching data for auction is found', function () { + expect(bidRequest.getFloor({})).to.deep.equal({}); + }); + it('picks the right rule depending on input', function () { + _floorDataForAuction[bidRequest.auctionId] = utils.deepClone(basicFloorConfig); + + // empty params into getFloor should use default of banner * FloorData Curr + let inputParams = {}; + expect(bidRequest.getFloor(inputParams)).to.deep.equal({ + currency: 'USD', + floor: 1.0 + }); + + // ask for banner + inputParams = {mediaType: 'banner'}; + expect(bidRequest.getFloor(inputParams)).to.deep.equal({ + currency: 'USD', + floor: 1.0 + }); + + // ask for video + inputParams = {mediaType: 'video'}; + expect(bidRequest.getFloor(inputParams)).to.deep.equal({ + currency: 'USD', + floor: 5.0 + }); + + // ask for * + inputParams = {mediaType: '*'}; + expect(bidRequest.getFloor(inputParams)).to.deep.equal({ + currency: 'USD', + floor: 2.5 + }); + }); + it('picks the right rule with more complex rules', function () { + _floorDataForAuction[bidRequest.auctionId] = { + ...basicFloorConfig, + data: { + currency: 'USD', + schema: { fields: ['mediaType', 'size'], delimiter: '|' }, + values: { + 'banner|300x250': 0.5, + 'banner|300x600': 1.5, + 'banner|728x90': 2.5, + 'banner|*': 3.5, + 'video|640x480': 4.5, + 'video|*': 5.5 + }, + default: 10.0 + } + }; + + // assumes banner * + let inputParams = {}; + expect(bidRequest.getFloor(inputParams)).to.deep.equal({ + currency: 'USD', + floor: 3.5 + }); + + // ask for banner with a size + inputParams = {mediaType: 'banner', size: [300, 600]}; + expect(bidRequest.getFloor(inputParams)).to.deep.equal({ + currency: 'USD', + floor: 1.5 + }); + + // ask for video with a size + inputParams = {mediaType: 'video', size: [640, 480]}; + expect(bidRequest.getFloor(inputParams)).to.deep.equal({ + currency: 'USD', + floor: 4.5 + }); + + // ask for video with a size not in rules (should pick rule which has video and *) + inputParams = {mediaType: 'video', size: [111, 222]}; + expect(bidRequest.getFloor(inputParams)).to.deep.equal({ + currency: 'USD', + floor: 5.5 + }); + + // ask for native * but no native rule so should use default value if there + inputParams = {mediaType: 'native', size: '*'}; + expect(bidRequest.getFloor(inputParams)).to.deep.equal({ + currency: 'USD', + floor: 10.0 + }); + }); + it('should round up to 4 decimal places', function () { + _floorDataForAuction[bidRequest.auctionId] = utils.deepClone(basicFloorConfig); + _floorDataForAuction[bidRequest.auctionId].data.values = { + 'banner': 1.777777, + 'video': 1.1111111, + }; + + // assumes banner * + let inputParams = {mediaType: 'banner'}; + expect(bidRequest.getFloor(inputParams)).to.deep.equal({ + currency: 'USD', + floor: 1.7778 + }); + + // assumes banner * + inputParams = {mediaType: 'video'}; + expect(bidRequest.getFloor(inputParams)).to.deep.equal({ + currency: 'USD', + floor: 1.1112 + }); + }); + it('should return the adjusted floor if bidder has cpm adjustment function', function () { + getGlobal().bidderSettings = { + rubicon: { + bidCpmAdjustment: function (bidCpm) { + return bidCpm * 0.5; + }, + }, + appnexus: { + bidCpmAdjustment: function (bidCpm) { + return bidCpm * 0.75; + }, + } + }; + _floorDataForAuction[bidRequest.auctionId] = utils.deepClone(basicFloorConfig); + _floorDataForAuction[bidRequest.auctionId].data.values = { '*': 1.0 }; + let appnexusBid = { + ...bidRequest, + bidder: 'appnexus' + }; + + // the conversion should be what the bidder would need to return in order to match the actual floor + // rubicon + expect(bidRequest.getFloor()).to.deep.equal({ + currency: 'USD', + floor: 2.0 // a 2.0 bid after rubicons cpm adjustment would be 1.0 and thus is the floor after adjust + }); + + // appnexus + expect(appnexusBid.getFloor()).to.deep.equal({ + currency: 'USD', + floor: 1.3334 // 1.3334 * 0.75 = 1.000005 which is the floor (we cut off getFloor at 4 decimal points) + }); + }); + it('should correctly pick the right attributes if * is passed in and context can be assumed', function () { + let inputBidReq = { + bidder: 'rubicon', + adUnitCode: 'test_div_2', + auctionId: '987654321', + mediaTypes: { + video: {} + }, + getFloor + }; + _floorDataForAuction[inputBidReq.auctionId] = utils.deepClone(basicFloorConfig); + _floorDataForAuction[inputBidReq.auctionId].data.values = { + '*': 1.0, + 'banner': 3.0, + 'video': 5.0 + }; + + // because bid req only has video, if a bidder asks for a floor for * we can actually give them the right mediaType + expect(inputBidReq.getFloor({mediaType: '*'})).to.deep.equal({ + currency: 'USD', + floor: 5.0 // 'video': 5.0 + }); + delete _floorDataForAuction[inputBidReq.auctionId].data.matchingInputs; + + // Same for if only banner is in the input bid + inputBidReq.mediaTypes = {banner: {}}; + expect(inputBidReq.getFloor({mediaType: '*'})).to.deep.equal({ + currency: 'USD', + floor: 3.0 // 'banner': 3.0, + }); + delete _floorDataForAuction[inputBidReq.auctionId].data.matchingInputs; + + // if both are present then it will really use the * + inputBidReq.mediaTypes = {banner: {}, video: {}}; + expect(inputBidReq.getFloor({mediaType: '*'})).to.deep.equal({ + currency: 'USD', + floor: 1.0 // '*': 1.0, + }); + delete _floorDataForAuction[inputBidReq.auctionId].data.matchingInputs; + + // now if size can be inferred (meaning only one size is in the specified mediaType, it will use it) + _floorDataForAuction[inputBidReq.auctionId].data.schema.fields = ['mediaType', 'size']; + _floorDataForAuction[inputBidReq.auctionId].data.values = { + '*|*': 1.0, + 'banner|300x250': 2.0, + 'banner|728x90': 3.0, + 'banner|*': 4.0, + 'video|300x250': 5.0, + 'video|728x90': 6.0, + 'video|*': 7.0 + }; + // mediaType is banner and only one size, so if someone asks for banner * we should give them banner 300x250 + // instead of banner|* + inputBidReq.mediaTypes = {banner: {sizes: [[300, 250]]}}; + expect(inputBidReq.getFloor({mediaType: 'banner', size: '*'})).to.deep.equal({ + currency: 'USD', + floor: 2.0 // 'banner|300x250': 2.0, + }); + delete _floorDataForAuction[inputBidReq.auctionId].data.matchingInputs; + + // now for video it should look at playersize (prebid core translates playersize into typical array of size arrays) + inputBidReq.mediaTypes = {video: {playerSize: [[728, 90]]}}; + expect(inputBidReq.getFloor({mediaType: 'video', size: '*'})).to.deep.equal({ + currency: 'USD', + floor: 6.0 // 'video|728x90': 6.0, + }); + delete _floorDataForAuction[inputBidReq.auctionId].data.matchingInputs; + + // Now if multiple sizes are there, it will actually use * since can't infer + inputBidReq.mediaTypes = {banner: {sizes: [[300, 250], [728, 90]]}}; + expect(inputBidReq.getFloor({mediaType: 'banner', size: '*'})).to.deep.equal({ + currency: 'USD', + floor: 4.0 // 'banner|*': 4.0, + }); + delete _floorDataForAuction[inputBidReq.auctionId].data.matchingInputs; + + // lastly, if you pass in * mediaType and * size it should resolve both if possble + inputBidReq.mediaTypes = {banner: {sizes: [[300, 250]]}}; + expect(inputBidReq.getFloor({mediaType: '*', size: '*'})).to.deep.equal({ + currency: 'USD', + floor: 2.0 // 'banner|300x250': 2.0, + }); + delete _floorDataForAuction[inputBidReq.auctionId].data.matchingInputs; + + inputBidReq.mediaTypes = {video: {playerSize: [[300, 250]]}}; + expect(inputBidReq.getFloor({mediaType: '*', size: '*'})).to.deep.equal({ + currency: 'USD', + floor: 5.0 // 'video|300x250': 5.0, + }); + delete _floorDataForAuction[inputBidReq.auctionId].data.matchingInputs; + + // now it has both mediaTypes so will use * mediaType and thus not use sizes either + inputBidReq.mediaTypes = {video: {playerSize: [[300, 250]]}, banner: {sizes: [[300, 250]]}}; + expect(inputBidReq.getFloor({mediaType: '*', size: '*'})).to.deep.equal({ + currency: 'USD', + floor: 1.0 // '*|*': 1.0, + }); + delete _floorDataForAuction[inputBidReq.auctionId].data.matchingInputs; + }); + }); + }); + describe('bidResponseHook tests', function () { + let returnedBidResponse; + let bidderRequest = { + bidderCode: 'appnexus', + auctionId: '123456', + bids: [{ + bidder: 'appnexus', + adUnitCode: 'test_div_1', + auctionId: '123456', + bidId: '1111' + }] + }; + let basicBidResponse = { + bidderCode: 'appnexus', + width: 300, + height: 250, + cpm: 0.5, + mediaType: 'banner', + requestId: '1111', + }; + beforeEach(function () { + returnedBidResponse = {}; + }); + function runBidResponse(bidResp = basicBidResponse) { + let next = (adUnitCode, bid) => { + returnedBidResponse = bid; + }; + addBidResponseHook.bind({ bidderRequest })(next, bidResp.adUnitCode, bidResp); + }; + it('continues with the auction if not floors data is present without any flooring', function () { + runBidResponse(); + expect(returnedBidResponse).to.not.haveOwnProperty('floorData'); + }); + it('if no matching rule it should not floor and should call log warn', function () { + _floorDataForAuction[bidderRequest.auctionId] = utils.deepClone(basicFloorConfig); + _floorDataForAuction[bidderRequest.auctionId].data.values = { 'video': 1.0 }; + runBidResponse(); + expect(returnedBidResponse).to.not.haveOwnProperty('floorData'); + expect(logWarnSpy.calledOnce).to.equal(true); + }); + it('if it finds a rule and floors should update the bid accordingly', function () { + _floorDataForAuction[bidderRequest.auctionId] = utils.deepClone(basicFloorConfig); + _floorDataForAuction[bidderRequest.auctionId].data.values = { 'banner': 1.0 }; + runBidResponse(); + expect(returnedBidResponse).to.haveOwnProperty('floorData'); + expect(returnedBidResponse.status).to.equal(CONSTANTS.BID_STATUS.BID_REJECTED); + expect(returnedBidResponse.cpm).to.equal(0); + }); + it('if it finds a rule and does not floor should update the bid accordingly', function () { + _floorDataForAuction[bidderRequest.auctionId] = utils.deepClone(basicFloorConfig); + _floorDataForAuction[bidderRequest.auctionId].data.values = { 'banner': 0.3 }; + runBidResponse(); + expect(returnedBidResponse).to.haveOwnProperty('floorData'); + expect(returnedBidResponse.floorData).to.deep.equal({ + floorValue: 0.3, + floorCurrency: 'USD', + floorRule: 'banner', + cpmAfterAdjustments: 0.5, + enforcements: { + bidAdjustment: true, + enforceJS: true, + enforcePBS: false, + floorDeals: false + }, + matchedFields: { + mediaType: 'banner' + } + }); + expect(returnedBidResponse.cpm).to.equal(0.5); + }); + it('if should work with more complex rules and update accordingly', function () { + _floorDataForAuction[bidderRequest.auctionId] = { + ...basicFloorConfig, + data: { + currency: 'USD', + schema: { fields: ['mediaType', 'size'], delimiter: '|' }, + values: { + 'banner|300x250': 0.5, + 'banner|300x600': 1.5, + 'banner|728x90': 2.5, + 'banner|*': 3.5, + 'video|640x480': 4.5, + 'video|*': 5.5 + }, + default: 10.0 + } + }; + runBidResponse(); + expect(returnedBidResponse).to.haveOwnProperty('floorData'); + expect(returnedBidResponse.floorData).to.deep.equal({ + floorValue: 0.5, + floorCurrency: 'USD', + floorRule: 'banner|300x250', + cpmAfterAdjustments: 0.5, + enforcements: { + bidAdjustment: true, + enforceJS: true, + enforcePBS: false, + floorDeals: false + }, + matchedFields: { + mediaType: 'banner', + size: '300x250' + } + }); + expect(returnedBidResponse.cpm).to.equal(0.5); + + // update bidResponse to have different combinations (should pick video|*) + runBidResponse({ + width: 300, + height: 250, + cpm: 7.5, + mediaType: 'video', + requestId: '1111', + }); + expect(returnedBidResponse).to.haveOwnProperty('floorData'); + expect(returnedBidResponse.floorData).to.deep.equal({ + floorValue: 5.5, + floorCurrency: 'USD', + floorRule: 'video|*', + cpmAfterAdjustments: 7.5, + enforcements: { + bidAdjustment: true, + enforceJS: true, + enforcePBS: false, + floorDeals: false + }, + matchedFields: { + mediaType: 'video', + size: '300x250' + } + }); + expect(returnedBidResponse.cpm).to.equal(7.5); + }); + }); +}); diff --git a/test/spec/modules/projectLimeLightBidAdapter_spec.js b/test/spec/modules/projectLimeLightBidAdapter_spec.js index 434b3fbccb5..3ffc017f177 100644 --- a/test/spec/modules/projectLimeLightBidAdapter_spec.js +++ b/test/spec/modules/projectLimeLightBidAdapter_spec.js @@ -1,5 +1,5 @@ import {expect} from 'chai'; -import {spec} from '../../../modules/projectLimeLightBidAdapter'; +import {spec} from '../../../modules/projectLimeLightBidAdapter.js'; describe('ProjectLimeLightAdapter', function () { let bid = { @@ -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/proxistoreBidAdapter_spec.js b/test/spec/modules/proxistoreBidAdapter_spec.js index 302b7634fbc..e18262ae797 100644 --- a/test/spec/modules/proxistoreBidAdapter_spec.js +++ b/test/spec/modules/proxistoreBidAdapter_spec.js @@ -10,6 +10,11 @@ describe('ProxistoreBidAdapter', function () { 'gdprConsent': { 'gdprApplies': true, 'consentString': 'CONSENT_STRING', + 'vendorData': { + 'vendorConsents': { + '418': true + } + } } }; let bid = { @@ -29,18 +34,35 @@ describe('ProxistoreBidAdapter', function () { }); describe('buildRequests', function () { - const url = '//abs.proxistore.com/fr/v3/rtb/prebid'; + const url = 'https://abs.proxistore.com/fr/v3/rtb/prebid/multi'; const request = spec.buildRequests([bid], bidderRequest); - it('should return an empty array if no cookie sent', function () { - expect(request).to.be.an('array'); - expect(request.length).to.equal(1); + it('should return a valid object', function () { + expect(request).to.be.an('object'); + expect(request.method).to.exist; + expect(request.url).to.exist; + expect(request.data).to.exist; }); it('request method should be POST', function () { - expect(request[0].method).to.equal('POST'); + expect(request.method).to.equal('POST'); }); it('should contain a valid url', function () { - expect(request[0].url).equal(url); - }) + expect(request.url).equal(url); + }); + it('should have the value consentGiven to true bc we have 418 in the vendor list', function () { + const data = JSON.parse(request.data); + + expect(data.gdpr.consentString).equal(bidderRequest.gdprConsent.consentString); + expect(data.gdpr.applies).to.be.true; + expect(data.gdpr.consentGiven).to.be.true; + }); + it('should have a property a length of bids equal to one if there is only one bid', function () { + const data = JSON.parse(request.data); + expect(data.hasOwnProperty('bids')).to.be.true; + expect(data.bids).to.be.an('array'); + expect(data.bids.length).equal(1); + expect(data.bids[0].hasOwnProperty('id')).to.be.true; + expect(data.bids[0].sizes).to.be.an('array'); + }); }); describe('interpretResponse', function () { @@ -66,7 +88,7 @@ describe('ProxistoreBidAdapter', function () { expect(spec.interpretResponse(badResponse, bid)).to.be.an('array'); expect(spec.interpretResponse(badResponse, bid).length).equal(0); }); - it('should interprnet the response correctly if it is valid', function () { + it('should interpret the response correctly if it is valid', function () { expect(interpretedResponse.cpm).equal(6.25); expect(interpretedResponse.creativeId).equal('48fd47c9-ce35-4fda-804b-17e16c8c36ac'); expect(interpretedResponse.currency).equal('EUR'); @@ -74,6 +96,7 @@ describe('ProxistoreBidAdapter', function () { expect(interpretedResponse.width).equal(300); expect(interpretedResponse.requestId).equal('923756713'); expect(interpretedResponse.netRevenue).to.be.true; + expect(interpretedResponse.netRevenue).to.be.true; }) }); diff --git a/test/spec/modules/pubCommonId_spec.js b/test/spec/modules/pubCommonId_spec.js index fd2bff5bac6..ab0ef2adc51 100644 --- a/test/spec/modules/pubCommonId_spec.js +++ b/test/spec/modules/pubCommonId_spec.js @@ -9,11 +9,11 @@ import { setStorageItem, getStorageItem, removeStorageItem, - getPubcidConfig } from 'modules/pubCommonId'; -import { getAdUnits } from 'test/fixtures/fixtures'; -import * as auctionModule from 'src/auction'; -import { registerBidder } from 'src/adapters/bidderFactory'; -import * as utils from 'src/utils'; + getPubcidConfig } from 'modules/pubCommonId.js'; +import { getAdUnits } from 'test/fixtures/fixtures.js'; +import * as auctionModule from 'src/auction.js'; +import { registerBidder } from 'src/adapters/bidderFactory.js'; +import * as utils from 'src/utils.js'; let events = require('src/events'); let constants = require('src/constants.json'); diff --git a/test/spec/modules/pubmaticAnalyticsAdapter_spec.js b/test/spec/modules/pubmaticAnalyticsAdapter_spec.js new file mode 100755 index 00000000000..e9d23692d23 --- /dev/null +++ b/test/spec/modules/pubmaticAnalyticsAdapter_spec.js @@ -0,0 +1,556 @@ +import pubmaticAnalyticsAdapter from 'modules/pubmaticAnalyticsAdapter.js'; +import CONSTANTS from 'src/constants.json'; +import { config } from 'src/config.js'; +import { + setConfig, + addBidResponseHook, +} from 'modules/currency.js'; + +// 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': 'pubmatic', + 'width': 640, + 'height': 480, + 'mediaType': 'video', + 'statusMessage': 'Bid available', + 'bidId': '2ecff0db240757', + 'adId': 'fake_ad_id', + 'source': 's2s', + 'requestId': '2ecff0db240757', + 'currency': 'USD', + 'creativeId': '3571560', + 'cpm': 1.22752, + 'originalCpm': 1.22752, + 'originalCurrency': 'USD', + 'ttl': 300, + 'netRevenue': false, + 'ad': '', + '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': 'pubmatic', + 'hb_adid': '2ecff0db240757', + 'hb_pb': 1.20, + 'hb_size': '640x480', + 'hb_source': 'server' + }, + getStatusCode() { + return 1; + } +}; + +const BID2 = Object.assign({}, BID, { + adUnitCode: '/19968336/header-bid-tag-1', + bidId: '3bd4ebb1c900e2', + adId: 'fake_ad_id_2', + requestId: '3bd4ebb1c900e2', + width: 728, + height: 90, + mediaType: 'banner', + cpm: 1.52, + originalCpm: 1.52, + dealId: 'the-deal-id', + dealChannel: 'PMP', + mi: 'matched-impression', + seatBidId: 'aaaa-bbbb-cccc-dddd', + adserverTargeting: { + 'hb_bidder': 'pubmatic', + '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-tag-1', + 'sizes': [[640, 480]], + 'bids': [ { + 'bidder': 'pubmatic', + 'params': { + 'publisherId': '1001' + } + } ], + 'transactionId': 'ca4af27a-6d02-4f90-949d-d5541fa12014' + } + ], + 'adUnitCodes': ['/19968336/header-bid-tag-1'], + 'bidderRequests': [ { + 'bidderCode': 'pubmatic', + 'auctionId': '25c6d7f5-699a-4bfc-87c9-996f915341fa', + 'bidderRequestId': '1be65d7958826a', + 'bids': [ { + 'bidder': 'pubmatic', + 'params': { + 'publisherId': '1001', + 'kgpv': 'this-is-a-kgpv' + }, + 'mediaTypes': { + 'banner': { + 'sizes': [[640, 480]] + } + }, + 'adUnitCode': '/19968336/header-bid-tag-1', + '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 + }, + BID_REQUESTED: { + 'bidder': 'pubmatic', + 'auctionId': '25c6d7f5-699a-4bfc-87c9-996f915341fa', + 'bidderRequestId': '1be65d7958826a', + 'bids': [ + { + 'bidder': 'pubmatic', + 'params': { + 'publisherId': '1001', + 'video': { + 'minduration': 30, + 'skippable': true + } + }, + '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': 'pubmatic', + 'params': { + 'publisherId': '1001', + 'kgpv': 'this-is-a-kgpv' + }, + 'mediaTypes': { + 'banner': { + 'sizes': [[1000, 300], [970, 250], [728, 90]] + } + }, + 'adUnitCode': '/19968336/header-bid-tag-1', + '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, + 'refererInfo': { + 'referer': 'http://www.test.com/page.html', 'reachedTop': true, 'numIframes': 0, 'stack': ['http://www.test.com/page.html'] + }, + 'gdprConsent': { + 'consentString': 'here-goes-gdpr-consent-string', + 'gdprApplies': true + } + }, + 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': 'pubmatic', + 'bids': [ + BID, + Object.assign({}, BID2, { + 'serverResponseTimeMs': 42, + }) + ] + }, + BID_TIMEOUT: [ + { + 'bidId': '3bd4ebb1c900e2', + 'bidder': 'pubmatic', + 'adUnitCode': '/19968336/header-bid-tag-1', + 'auctionId': '25c6d7f5-699a-4bfc-87c9-996f915341fa' + } + ] +}; + +function getLoggerJsonFromRequest(requestBody) { + return JSON.parse(decodeURIComponent(requestBody.split('json=')[1])); +} + +describe('pubmatic 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([]); + + clock = sandbox.useFakeTimers(1519767013781); + + config.setConfig({ + s2sConfig: { + timeout: 1000, + accountId: 10000, + bidders: ['pubmatic'] + } + }) + }); + + afterEach(function () { + sandbox.restore(); + config.resetConfig(); + }); + + it('should require publisherId', function () { + sandbox.stub(utils, 'logError'); + pubmaticAnalyticsAdapter.enableAnalytics({ + options: {} + }); + expect(utils.logError.called).to.equal(true); + }); + + describe('when handling events', function() { + beforeEach(function () { + pubmaticAnalyticsAdapter.enableAnalytics({ + options: { + publisherId: 9999, + profileId: 1111, + profileVersionId: 20 + } + }); + }); + + afterEach(function () { + pubmaticAnalyticsAdapter.disableAnalytics(); + }); + + it('Logger: best case + win tracker', 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]); + events.emit(BID_WON, MOCK.BID_WON[1]); + + clock.tick(2000 + 1000); + expect(requests.length).to.equal(3); // 1 logger and 2 win-tracker + let request = requests[2]; // logger is executed late, trackers execute first + expect(request.url).to.equal('https://t.pubmatic.com/wl?pubid=9999&gdEn=1'); + let data = getLoggerJsonFromRequest(request.requestBody); + expect(data.pubid).to.equal('9999'); + expect(data.pid).to.equal('1111'); + expect(data.pdvid).to.equal('20'); + expect(data.iid).to.equal('25c6d7f5-699a-4bfc-87c9-996f915341fa'); + expect(data.to).to.equal('3000'); + expect(data.purl).to.equal('http://www.test.com/page.html'); + expect(data.orig).to.equal('www.test.com'); + expect(data.tst).to.equal(1519767016); + expect(data.cns).to.equal('here-goes-gdpr-consent-string'); + expect(data.gdpr).to.equal(1); + expect(data.s).to.be.an('array'); + expect(data.s.length).to.equal(2); + // slot 1 + expect(data.s[0].sn).to.equal('/19968336/header-bid-tag-0'); + expect(data.s[0].sz).to.deep.equal(['640x480']); + expect(data.s[0].ps).to.be.an('array'); + expect(data.s[0].ps.length).to.equal(1); + expect(data.s[0].ps[0].pn).to.equal('pubmatic'); + expect(data.s[0].ps[0].bidid).to.equal('2ecff0db240757'); + expect(data.s[0].ps[0].db).to.equal(0); + expect(data.s[0].ps[0].kgpv).to.equal('/19968336/header-bid-tag-0'); + expect(data.s[0].ps[0].kgpsv).to.equal('/19968336/header-bid-tag-0'); + expect(data.s[0].ps[0].psz).to.equal('640x480'); + expect(data.s[0].ps[0].eg).to.equal(1.23); + expect(data.s[0].ps[0].en).to.equal(1.23); + expect(data.s[0].ps[0].di).to.equal(''); + expect(data.s[0].ps[0].dc).to.equal(''); + expect(data.s[0].ps[0].l1).to.equal(3214); + expect(data.s[0].ps[0].l2).to.equal(0); + expect(data.s[0].ps[0].ss).to.equal(1); + expect(data.s[0].ps[0].t).to.equal(0); + expect(data.s[0].ps[0].wb).to.equal(1); + expect(data.s[0].ps[0].af).to.equal('video'); + expect(data.s[0].ps[0].ocpm).to.equal(1.23); + expect(data.s[0].ps[0].ocry).to.equal('USD'); + // slot 2 + expect(data.s[1].sn).to.equal('/19968336/header-bid-tag-1'); + expect(data.s[1].sz).to.deep.equal(['1000x300', '970x250', '728x90']); + expect(data.s[1].ps).to.be.an('array'); + expect(data.s[1].ps.length).to.equal(1); + expect(data.s[1].ps[0].pn).to.equal('pubmatic'); + expect(data.s[1].ps[0].bidid).to.equal('3bd4ebb1c900e2'); + expect(data.s[1].ps[0].db).to.equal(0); + expect(data.s[1].ps[0].kgpv).to.equal('this-is-a-kgpv'); + expect(data.s[1].ps[0].kgpsv).to.equal('this-is-a-kgpv'); + expect(data.s[1].ps[0].psz).to.equal('728x90'); + expect(data.s[1].ps[0].eg).to.equal(1.52); + expect(data.s[1].ps[0].en).to.equal(1.52); + expect(data.s[1].ps[0].di).to.equal('the-deal-id'); + expect(data.s[1].ps[0].dc).to.equal('PMP'); + expect(data.s[1].ps[0].mi).to.equal('matched-impression'); + expect(data.s[1].ps[0].l1).to.equal(3214); + expect(data.s[1].ps[0].l2).to.equal(0); + expect(data.s[1].ps[0].ss).to.equal(1); + expect(data.s[1].ps[0].t).to.equal(0); + expect(data.s[1].ps[0].wb).to.equal(1); + expect(data.s[1].ps[0].af).to.equal('banner'); + expect(data.s[1].ps[0].ocpm).to.equal(1.52); + expect(data.s[1].ps[0].ocry).to.equal('USD'); + + // tracker slot1 + let firstTracker = requests[0].url; + expect(firstTracker.split('?')[0]).to.equal('https://t.pubmatic.com/wt'); + data = {}; + firstTracker.split('?')[1].split('&').map(e => e.split('=')).forEach(e => data[e[0]] = e[1]); + expect(data.pubid).to.equal('9999'); + expect(decodeURIComponent(data.purl)).to.equal('http://www.test.com/page.html'); + expect(data.tst).to.equal('1519767014'); + expect(data.iid).to.equal('25c6d7f5-699a-4bfc-87c9-996f915341fa'); + expect(data.bidid).to.equal('2ecff0db240757'); + expect(data.pid).to.equal('1111'); + expect(data.pdvid).to.equal('20'); + expect(decodeURIComponent(data.slot)).to.equal('/19968336/header-bid-tag-0'); + expect(decodeURIComponent(data.kgpv)).to.equal('/19968336/header-bid-tag-0'); + expect(data.pn).to.equal('pubmatic'); + expect(data.eg).to.equal('1.23'); + expect(data.en).to.equal('1.23'); + }); + + it('Logger: when bid is not submitted, default bid status 1 check: pubmatic set as s2s', 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(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(2000 + 1000); + expect(requests.length).to.equal(2); // 1 logger and 1 win-tracker + let request = requests[1]; // logger is executed late, trackers execute first + let data = getLoggerJsonFromRequest(request.requestBody); + expect(data.s[1].sn).to.equal('/19968336/header-bid-tag-1'); + expect(data.s[1].sz).to.deep.equal(['1000x300', '970x250', '728x90']); + expect(data.s[1].ps).to.be.an('array'); + expect(data.s[1].ps.length).to.equal(1); + expect(data.s[1].ps[0].pn).to.equal('pubmatic'); + expect(data.s[1].ps[0].bidid).to.equal('3bd4ebb1c900e2'); + expect(data.s[1].ps[0].db).to.equal(1); + expect(data.s[1].ps[0].kgpv).to.equal('this-is-a-kgpv'); + expect(data.s[1].ps[0].kgpsv).to.equal('this-is-a-kgpv'); + expect(data.s[1].ps[0].psz).to.equal('0x0'); + expect(data.s[1].ps[0].eg).to.equal(0); + expect(data.s[1].ps[0].en).to.equal(0); + expect(data.s[1].ps[0].di).to.equal(''); + expect(data.s[1].ps[0].dc).to.equal(''); + expect(data.s[1].ps[0].mi).to.equal(undefined); + expect(data.s[1].ps[0].l1).to.equal(0); + expect(data.s[1].ps[0].l2).to.equal(0); + expect(data.s[1].ps[0].ss).to.equal(1); + expect(data.s[1].ps[0].t).to.equal(0); + expect(data.s[1].ps[0].wb).to.equal(0); + expect(data.s[1].ps[0].af).to.equal(undefined); + expect(data.s[1].ps[0].ocpm).to.equal(0); + expect(data.s[1].ps[0].ocry).to.equal('USD'); + }); + + it('Logger: post-timeout check without bid response', function() { + // db = 1 and t = 1 means bidder did NOT respond with a bid but we got a timeout notification + 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(2000 + 1000); + + expect(requests.length).to.equal(1); // 1 logger and 0 win-tracker + let request = requests[0]; + let data = getLoggerJsonFromRequest(request.requestBody); + expect(data.s[1].sn).to.equal('/19968336/header-bid-tag-1'); + expect(data.s[1].sz).to.deep.equal(['1000x300', '970x250', '728x90']); + expect(data.s[1].ps).to.be.an('array'); + expect(data.s[1].ps.length).to.equal(1); + expect(data.s[1].ps[0].pn).to.equal('pubmatic'); + expect(data.s[1].ps[0].bidid).to.equal('3bd4ebb1c900e2'); + expect(data.s[1].ps[0].db).to.equal(1); + expect(data.s[1].ps[0].kgpv).to.equal('this-is-a-kgpv'); + expect(data.s[1].ps[0].kgpsv).to.equal('this-is-a-kgpv'); + expect(data.s[1].ps[0].psz).to.equal('0x0'); + expect(data.s[1].ps[0].eg).to.equal(0); + expect(data.s[1].ps[0].en).to.equal(0); + expect(data.s[1].ps[0].di).to.equal(''); + expect(data.s[1].ps[0].dc).to.equal(''); + expect(data.s[1].ps[0].mi).to.equal(undefined); + expect(data.s[1].ps[0].l1).to.equal(0); + expect(data.s[1].ps[0].l2).to.equal(0); + expect(data.s[1].ps[0].ss).to.equal(1); + expect(data.s[1].ps[0].t).to.equal(1); + expect(data.s[1].ps[0].wb).to.equal(0); + expect(data.s[1].ps[0].af).to.equal(undefined); + expect(data.s[1].ps[0].ocpm).to.equal(0); + expect(data.s[1].ps[0].ocry).to.equal('USD'); + }); + + it('Logger: post-timeout check with bid response', function() { + // db = 1 and t = 1 means bidder did NOT respond with a bid but we got a timeout notification + events.emit(AUCTION_INIT, MOCK.AUCTION_INIT); + events.emit(BID_REQUESTED, MOCK.BID_REQUESTED); + events.emit(BID_RESPONSE, MOCK.BID_RESPONSE[1]); + events.emit(BID_TIMEOUT, MOCK.BID_TIMEOUT); + events.emit(AUCTION_END, MOCK.AUCTION_END); + clock.tick(2000 + 1000); + + expect(requests.length).to.equal(1); // 1 logger and 0 win-tracker + let request = requests[0]; + let data = getLoggerJsonFromRequest(request.requestBody); + expect(data.s[1].sn).to.equal('/19968336/header-bid-tag-1'); + expect(data.s[1].sz).to.deep.equal(['1000x300', '970x250', '728x90']); + expect(data.s[1].ps).to.be.an('array'); + expect(data.s[1].ps.length).to.equal(1); + expect(data.s[1].ps[0].pn).to.equal('pubmatic'); + expect(data.s[1].ps[0].bidid).to.equal('3bd4ebb1c900e2'); + expect(data.s[1].ps[0].db).to.equal(0); + expect(data.s[1].ps[0].kgpv).to.equal('this-is-a-kgpv'); + expect(data.s[1].ps[0].kgpsv).to.equal('this-is-a-kgpv'); + expect(data.s[1].ps[0].psz).to.equal('728x90'); + expect(data.s[1].ps[0].eg).to.equal(1.52); + expect(data.s[1].ps[0].en).to.equal(1.52); + expect(data.s[1].ps[0].di).to.equal('the-deal-id'); + expect(data.s[1].ps[0].dc).to.equal('PMP'); + expect(data.s[1].ps[0].mi).to.equal('matched-impression'); + expect(data.s[1].ps[0].l1).to.equal(3214); + expect(data.s[1].ps[0].l2).to.equal(0); + expect(data.s[1].ps[0].ss).to.equal(1); + expect(data.s[1].ps[0].t).to.equal(1); + expect(data.s[1].ps[0].wb).to.equal(1); + expect(data.s[1].ps[0].af).to.equal('banner'); + expect(data.s[1].ps[0].ocpm).to.equal(1.52); + expect(data.s[1].ps[0].ocry).to.equal('USD'); + }); + + it('Logger: currency conversion check', function() { + setConfig({ + adServerCurrency: 'JPY', + rates: { + USD: { + JPY: 100 + } + } + }); + const bidCopy = utils.deepClone(BID2); + bidCopy.currency = 'JPY'; + bidCopy.cpm = 100; + bidCopy.originalCpm = 100; + bidCopy.originalCurrency = 'JPY'; + + 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, bidCopy); + 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]); + + clock.tick(2000 + 1000); + expect(requests.length).to.equal(3); // 1 logger and 2 win-tracker + let request = requests[2]; // logger is executed late, trackers execute first + expect(request.url).to.equal('https://t.pubmatic.com/wl?pubid=9999&gdEn=1'); + let data = getLoggerJsonFromRequest(request.requestBody); + expect(data.s[1].sn).to.equal('/19968336/header-bid-tag-1'); + expect(data.s[1].sz).to.deep.equal(['1000x300', '970x250', '728x90']); + expect(data.s[1].ps).to.be.an('array'); + expect(data.s[1].ps.length).to.equal(1); + expect(data.s[1].ps[0].pn).to.equal('pubmatic'); + expect(data.s[1].ps[0].bidid).to.equal('3bd4ebb1c900e2'); + expect(data.s[1].ps[0].db).to.equal(0); + expect(data.s[1].ps[0].kgpv).to.equal('this-is-a-kgpv'); + expect(data.s[1].ps[0].kgpsv).to.equal('this-is-a-kgpv'); + expect(data.s[1].ps[0].psz).to.equal('728x90'); + expect(data.s[1].ps[0].eg).to.equal(undefined); // bidPriceUSD is not getting set as currency module is not added + expect(data.s[1].ps[0].en).to.equal(undefined); // bidPriceUSD is not getting set as currency module is not added + expect(data.s[1].ps[0].di).to.equal('the-deal-id'); + expect(data.s[1].ps[0].dc).to.equal('PMP'); + expect(data.s[1].ps[0].mi).to.equal('matched-impression'); + expect(data.s[1].ps[0].l1).to.equal(3214); + expect(data.s[1].ps[0].l2).to.equal(0); + expect(data.s[1].ps[0].ss).to.equal(1); + expect(data.s[1].ps[0].t).to.equal(0); + expect(data.s[1].ps[0].wb).to.equal(0); // bidPriceUSD is not getting set as currency module is not added, so unable to set wb to 1 + expect(data.s[1].ps[0].af).to.equal('banner'); + expect(data.s[1].ps[0].ocpm).to.equal(100); + expect(data.s[1].ps[0].ocry).to.equal('JPY'); + }); + }) +}); diff --git a/test/spec/modules/pubmaticBidAdapter_spec.js b/test/spec/modules/pubmaticBidAdapter_spec.js index c7b3cc20e93..8fc42e97709 100644 --- a/test/spec/modules/pubmaticBidAdapter_spec.js +++ b/test/spec/modules/pubmaticBidAdapter_spec.js @@ -1,7 +1,7 @@ import {expect} from 'chai'; -import {spec} from 'modules/pubmaticBidAdapter'; -import * as utils from 'src/utils'; -import {config} from 'src/config'; +import {spec} from 'modules/pubmaticBidAdapter.js'; +import * as utils from 'src/utils.js'; +import {config} from 'src/config.js'; const constants = require('src/constants.json'); describe('PubMatic adapter', function () { @@ -28,6 +28,9 @@ describe('PubMatic adapter', function () { let bannerBidResponse; let videoBidResponse; let schainConfig; + let outstreamBidRequest; + let validOutstreamBidRequest; + let outstreamVideoBidResponse; beforeEach(() => { schainConfig = { @@ -89,6 +92,10 @@ describe('PubMatic adapter', function () { bidRequests = [firstBid, secoundBid]; firstResponse = { + 'seat': 'seat-id', + 'ext': { + 'buyid': 'BUYER-ID-987' + }, 'bid': [{ 'id': '74858439-49D7-4169-BA5D-44A046315B2F', 'impid': '23acc48ad47af5', @@ -105,6 +112,9 @@ describe('PubMatic adapter', function () { }] }; secoundResponse = { + 'ext': { + 'buyid': 'BUYER-ID-789' + }, 'bid': [{ 'id': '74858439-49D7-4169-BA5D-44A046315BEF', 'impid': '22bddb28db77e', @@ -661,6 +671,89 @@ describe('PubMatic adapter', function () { }] } } + + outstreamBidRequest = + [ + { + code: 'video1', + mediaTypes: { + video: { + playerSize: [640, 480], + context: 'outstream' + } + }, + bidder: 'pubmatic', + bidId: '47acc48ad47af5', + requestId: '0fb4905b-1234-4152-86be-c6f6d259ba99', + bidderRequestId: '1c56ad30b9b8ca8', + transactionId: '92489f71-1bf2-49a0-adf9-000cea934729', + params: { + publisherId: '5890', + outstreamAU: 'pubmatic-test', + adSlot: 'Div1@0x0', // ad_id or tagid + video: { + mimes: ['video/mp4', 'video/x-flv'], + skippable: true, + minduration: 5, + maxduration: 30 + } + } + } + ]; + + validOutstreamBidRequest = { + auctionId: '92489f71-1bf2-49a0-adf9-000cea934729', + auctionStart: 1585918458868, + bidderCode: 'pubmatic', + bidderRequestId: '47acc48ad47af5', + bids: [{ + adUnitCode: 'video1', + auctionId: '92489f71-1bf2-49a0-adf9-000cea934729', + bidId: '47acc48ad47af5', + bidRequestsCount: 1, + bidder: 'pubmatic', + bidderRequestId: '47acc48ad47af5', + mediaTypes: { + video: { + context: 'outstream' + } + }, + params: { + publisherId: '5890', + outstreamAU: 'pubmatic-test', + adSlot: 'Div1@0x0', // ad_id or tagid + video: { + mimes: ['video/mp4', 'video/x-flv'], + skippable: true, + minduration: 5, + maxduration: 30 + } + }, + sizes: [[768, 432], [640, 480], [630, 360]], + transactionId: '92489f71-1bf2-49a0-adf9-000cea934729' + }], + start: 11585918458869, + timeout: 3000 + }; + + outstreamVideoBidResponse = { + 'body': { + 'id': '93D3BAD6-E2E2-49FB-9D89-920B1761C865', + 'seatbid': [{ + 'bid': [{ + 'id': '0fb4905b-1234-4152-86be-c6f6d259ba99', + 'impid': '47acc48ad47af5', + 'price': 1.3, + 'adm': 'Acudeo CompatibleVAST 2.0 Instream Test 1VAST 2.0 Instream Test 1https://dsptracker.com/{PSPM}00:00:04https://www.pubmatic.com', + 'h': 250, + 'w': 300, + 'ext': { + 'deal_channel': 6 + } + }] + }] + } + } }); describe('implementation', function () { @@ -710,6 +803,45 @@ describe('PubMatic adapter', function () { isValid = spec.isBidRequestValid(validBid); expect(isValid).to.equal(true); }); + + it('is an invalid bid case: mediatype is video outstream and outstreamAU is not passed', function () { + let validBid = { + bidder: 'pubmatic', + mediaTypes: { + video: { + context: 'outstream' + } + }, + params: { + publisherId: '301', + video: { + mimes: ['video/mp4', 'video/x-flv'] + } + } + }, + isValid = spec.isBidRequestValid(validBid); + expect(isValid).to.equal(false); + }); + + it('is an valid bid case: mediatype is video outstream and outstreamAU is passed', function () { + let validBid = { + bidder: 'pubmatic', + mediaTypes: { + video: { + context: 'outstream' + } + }, + params: { + publisherId: '301', + outstreamAU: 'Div1', + video: { + mimes: ['video/mp4', 'video/x-flv'] + } + } + }, + isValid = spec.isBidRequestValid(validBid); + expect(isValid).to.equal(true); + }); }); describe('Request formation', function () { @@ -729,7 +861,17 @@ describe('PubMatic adapter', function () { let request = spec.buildRequests(bidRequests); expect(request.url).to.equal('https://hbopenbid.pubmatic.com/translator?source=prebid-client'); expect(request.method).to.equal('POST'); - }); + }); + + it('should return bidderRequest property', function() { + let request = spec.buildRequests(bidRequests, validOutstreamBidRequest); + expect(request.bidderRequest).to.equal(validOutstreamBidRequest); + }); + + it('bidderRequest should be undefined if bidderRequest is not present', function() { + let request = spec.buildRequests(bidRequests); + expect(request.bidderRequest).to.be.undefined; + }); it('test flag not sent when pubmaticTest=true is absent in page url', function() { let request = spec.buildRequests(bidRequests); @@ -737,7 +879,9 @@ describe('PubMatic adapter', function () { expect(data.test).to.equal(undefined); }); - it('test flag set to 1 when pubmaticTest=true is present in page url', function() { + // disabled this test case as it refreshes the whole suite when in karma watch mode + // todo: needs a fix + xit('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); @@ -763,6 +907,7 @@ describe('PubMatic adapter', function () { 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.source.tid).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 @@ -777,6 +922,70 @@ describe('PubMatic adapter', function () { expect(data.source.ext.schain).to.deep.equal(bidRequests[0].schain); }); + it('Merge the device info from config', function() { + let sandbox = sinon.sandbox.create(); + sandbox.stub(config, 'getConfig').callsFake((key) => { + var config = { + device: { + 'newkey': 'new-device-data' + } + }; + return config[key]; + }); + let request = spec.buildRequests(bidRequests); + let data = JSON.parse(request.data); + expect(data.device.js).to.equal(1); + expect(data.device.dnt).to.equal((navigator.doNotTrack == 'yes' || navigator.doNotTrack == '1' || navigator.msDoNotTrack == '1') ? 1 : 0); + expect(data.device.h).to.equal(screen.height); + expect(data.device.w).to.equal(screen.width); + expect(data.device.language).to.equal(navigator.language); + expect(data.device.newkey).to.equal('new-device-data');// additional data from config + sandbox.restore(); + }); + + it('Merge the device info from config; data from config overrides the info we have gathered', function() { + let sandbox = sinon.sandbox.create(); + sandbox.stub(config, 'getConfig').callsFake((key) => { + var config = { + device: { + newkey: 'new-device-data', + language: 'MARATHI' + } + }; + return config[key]; + }); + let request = spec.buildRequests(bidRequests); + let data = JSON.parse(request.data); + expect(data.device.js).to.equal(1); + expect(data.device.dnt).to.equal((navigator.doNotTrack == 'yes' || navigator.doNotTrack == '1' || navigator.msDoNotTrack == '1') ? 1 : 0); + expect(data.device.h).to.equal(screen.height); + expect(data.device.w).to.equal(screen.width); + expect(data.device.language).to.equal('MARATHI');// // data overriding from config + expect(data.device.newkey).to.equal('new-device-data');// additional data from config + sandbox.restore(); + }); + + it('Set app from config, copy publisher and ext from site, unset site', function() { + let sandbox = sinon.sandbox.create(); + sandbox.stub(config, 'getConfig').callsFake((key) => { + var config = { + app: { + bundle: 'org.prebid.mobile.demoapp', + domain: 'prebid.org' + } + }; + return config[key]; + }); + let request = spec.buildRequests(bidRequests); + let data = JSON.parse(request.data); + expect(data.app.bundle).to.equal('org.prebid.mobile.demoapp'); + expect(data.app.domain).to.equal('prebid.org'); + expect(data.app.publisher.id).to.equal(bidRequests[0].params.publisherId); + expect(data.app.ext.key_val).to.exist.and.to.equal(bidRequests[0].params.dctr); + expect(data.site).to.not.exist; + sandbox.restore(); + }); + it('Request params check: without adSlot', function () { delete bidRequests[0].params.adSlot; @@ -1875,6 +2084,42 @@ describe('PubMatic adapter', function () { expect(data.user.eids).to.equal(undefined); }); }); + + describe('NetId', function() { + it('send the NetId if it is present', function() { + bidRequests[0].userId = {}; + bidRequests[0].userId.netId = 'netid-user-id'; + let request = spec.buildRequests(bidRequests, {}); + let data = JSON.parse(request.data); + expect(data.user.eids).to.deep.equal([{ + 'source': 'netid.de', + 'uids': [{ + 'id': 'netid-user-id', + 'atype': 1 + }] + }]); + }); + + it('do not pass if not string', function() { + bidRequests[0].userId = {}; + bidRequests[0].userId.netId = 1; + let request = spec.buildRequests(bidRequests, {}); + let data = JSON.parse(request.data); + expect(data.user.eids).to.equal(undefined); + bidRequests[0].userId.netId = []; + request = spec.buildRequests(bidRequests, {}); + data = JSON.parse(request.data); + expect(data.user.eids).to.equal(undefined); + bidRequests[0].userId.netId = null; + request = spec.buildRequests(bidRequests, {}); + data = JSON.parse(request.data); + expect(data.user.eids).to.equal(undefined); + bidRequests[0].userId.netId = {}; + request = spec.buildRequests(bidRequests, {}); + data = JSON.parse(request.data); + expect(data.user.eids).to.equal(undefined); + }); + }); }); it('Request params check for video ad', function () { @@ -2326,6 +2571,112 @@ describe('PubMatic adapter', function () { }); }); + it('Request params deals check', function () { + let multipleBidRequests = [ + { + bidder: 'pubmatic', + params: { + publisherId: '301', + adSlot: '/15671365/DMDemo@300x250:0', + kadfloor: '1.2', + pmzoneid: 'aabc, ddef', + kadpageurl: 'www.publisher.com', + yob: '1986', + gender: 'M', + lat: '12.3', + lon: '23.7', + wiid: '1234567890', + profId: '100', + verId: '200', + currency: 'AUD', + deals: ['deal-id-1', 'deal-id-2', 'dea'] // "dea" will not be passed as more than 3 characters needed + }, + placementCode: '/19968336/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' + }, + { + bidder: 'pubmatic', + params: { + publisherId: '301', + adSlot: '/15671365/DMDemo@300x250:0', + kadfloor: '1.2', + pmzoneid: 'aabc, ddef', + kadpageurl: 'www.publisher.com', + yob: '1986', + gender: 'M', + lat: '12.3', + lon: '23.7', + wiid: '1234567890', + profId: '100', + verId: '200', + currency: 'GBP', + deals: ['deal-id-100', 'deal-id-200'] + }, + placementCode: '/19968336/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' + } + ]; + + let request = spec.buildRequests(multipleBidRequests); + let data = JSON.parse(request.data); + // case 1 - deals are passed as expected, ['', ''] , in both adUnits + expect(data.imp[0].pmp).to.deep.equal({ + 'private_auction': 0, + 'deals': [ + { + 'id': 'deal-id-1' + }, + { + 'id': 'deal-id-2' + } + ] + }); + expect(data.imp[1].pmp).to.deep.equal({ + 'private_auction': 0, + 'deals': [ + { + 'id': 'deal-id-100' + }, + { + 'id': 'deal-id-200' + } + ] + }); + + // case 2 - deals not present in adunit[0] + delete multipleBidRequests[0].params.deals; + request = spec.buildRequests(multipleBidRequests); + data = JSON.parse(request.data); + expect(data.imp[0].pmp).to.not.exist; + + // case 3 - deals is present in adunit[0], but is not an array + multipleBidRequests[0].params.deals = 123; + request = spec.buildRequests(multipleBidRequests); + data = JSON.parse(request.data); + expect(data.imp[0].pmp).to.not.exist; + + // case 4 - deals is present in adunit[0] as an array but one of the value is not a string + multipleBidRequests[0].params.deals = [123, 'deal-id-1']; + request = spec.buildRequests(multipleBidRequests); + data = JSON.parse(request.data); + expect(data.imp[0].pmp).to.deep.equal({ + 'private_auction': 0, + 'deals': [ + { + 'id': 'deal-id-1' + } + ] + }); + }); + describe('Request param bcat checking', function() { let multipleBidRequests = [ { @@ -2444,6 +2795,8 @@ describe('PubMatic adapter', function () { expect(response[0].meta.clickUrl).to.equal('blackrock.com'); expect(response[0].referrer).to.include(data.site.ref); expect(response[0].ad).to.equal(bidResponses.body.seatbid[0].bid[0].adm); + expect(response[0].pm_seat).to.equal(bidResponses.body.seatbid[0].seat); + expect(response[0].pm_dspid).to.equal(bidResponses.body.seatbid[0].bid[0].ext.dspid); expect(response[1].requestId).to.equal(bidResponses.body.seatbid[1].bid[0].impid); expect(response[1].cpm).to.equal((bidResponses.body.seatbid[1].bid[0].price).toFixed(2)); @@ -2463,6 +2816,8 @@ describe('PubMatic adapter', function () { expect(response[1].meta.clickUrl).to.equal('hivehome.com'); expect(response[1].referrer).to.include(data.site.ref); expect(response[1].ad).to.equal(bidResponses.body.seatbid[1].bid[0].adm); + expect(response[1].pm_seat).to.equal(bidResponses.body.seatbid[1].seat || null); + expect(response[1].pm_dspid).to.equal(bidResponses.body.seatbid[1].bid[0].ext.dspid); }); it('should check for dealChannel value selection', function () { @@ -2481,202 +2836,307 @@ describe('PubMatic adapter', function () { let request = spec.buildRequests(bidRequests); let updateBiResponse = bidResponses; updateBiResponse.body.seatbid[0].bid[0].ext.deal_channel = 11; - let response = spec.interpretResponse(updateBiResponse, request); - expect(response).to.be.an('array').with.length.above(0); expect(response[0].dealChannel).to.equal(null); }); - it('should add a dummy bid when, empty bid is returned by hbopenbid', () => { - let request = spec.buildRequests(bidRequests); - let response = spec.interpretResponse(emptyBidResponse, request); - - request = JSON.parse(request.data); - expect(response).to.exist.and.be.an('array').with.length.above(0); - expect(response[0].requestId).to.equal(request.imp[0].id); - expect(response[0].width).to.equal(0); - expect(response[0].height).to.equal(0); - expect(response[0].ttl).to.equal(300); - expect(response[0].ad).to.equal(''); - expect(response[0].creativeId).to.equal(0); - expect(response[0].netRevenue).to.equal(false); - expect(response[0].cpm).to.equal(0); - expect(response[0].currency).to.equal('USD'); - expect(response[0].referrer).to.equal(request.site && request.site.ref ? request.site.ref : ''); + it('should assign renderer if bid is video and request is for outstream', function() { + let request = spec.buildRequests(outstreamBidRequest, validOutstreamBidRequest); + let response = spec.interpretResponse(outstreamVideoBidResponse, request); + expect(response[0].renderer).to.exist; }); - it('should add one dummy & one original bid if partial response come from hbopenbid', () => { - let request = spec.buildRequests([firstBid, secoundBid]); - let response = spec.interpretResponse({ - 'body': { - 'id': '93D3BAD6-E2E2-49FB-9D89-920B1761C865', - 'seatbid': [firstResponse] - } - }, request); - - request = JSON.parse(request.data); - expect(response).to.exist.and.be.an('array').with.length.above(0); - expect(response.length).to.equal(2); - 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); - expect(response[0].referrer).to.include(request.site && request.site.ref ? request.site.ref : ''); - expect(response[0].ad).to.equal(bidResponses.body.seatbid[0].bid[0].adm); - - expect(response[1].requestId).to.equal(request.imp[1].id); - expect(response[1].width).to.equal(0); - expect(response[1].height).to.equal(0); - expect(response[1].ttl).to.equal(300); - expect(response[1].ad).to.equal(''); - expect(response[1].creativeId).to.equal(0); - expect(response[1].netRevenue).to.equal(false); - expect(response[1].cpm).to.equal(0); - expect(response[1].currency).to.equal('USD'); - expect(response[1].referrer).to.equal(request.site && request.site.ref ? request.site.ref : ''); + it('should not assign renderer if bidderRequest is not present', function() { + let request = spec.buildRequests(outstreamBidRequest); + let response = spec.interpretResponse(outstreamVideoBidResponse, request); + expect(response[0].renderer).to.not.exist; }); - it('should responsed bid if partial response come from hbopenbid', () => { - let request = spec.buildRequests([firstBid]); - let response = spec.interpretResponse(bidResponses, request); - - request = JSON.parse(request.data); - expect(response.length).to.equal(1); - 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); - expect(response[0].referrer).to.include(request.site && request.site.ref ? request.site.ref : ''); - expect(response[0].ad).to.equal(bidResponses.body.seatbid[0].bid[0].adm); + it('should not assign renderer if bid is video and request is for instream', function() { + let request = spec.buildRequests(videoBidRequests); + let response = spec.interpretResponse(videoBidResponse, request); + expect(response[0].renderer).to.not.exist; }); - it('should have a valid native bid response', function() { + it('should not assign renderer if bid is native', function() { let request = spec.buildRequests(nativeBidRequests); - let data = JSON.parse(request.data); - data.imp[0].id = '2a5571261281d4'; - request.data = JSON.stringify(data); let response = spec.interpretResponse(nativeBidResponse, request); - expect(response).to.be.an('array').with.length.above(0); - expect(response[0].native).to.exist.and.to.be.an('object'); - expect(response[0].mediaType).to.exist.and.to.equal('native'); - expect(response[0].native.title).to.exist.and.to.be.an('string'); - expect(response[0].native.image).to.exist.and.to.be.an('object'); - expect(response[0].native.image.url).to.exist.and.to.be.an('string'); - expect(response[0].native.image.height).to.exist; - expect(response[0].native.image.width).to.exist; - expect(response[0].native.sponsoredBy).to.exist.and.to.be.an('string'); - expect(response[0].native.clickUrl).to.exist.and.to.be.an('string'); + expect(response[0].renderer).to.not.exist; }); - it('should check for valid banner mediaType in case of multiformat request', function() { + it('should not assign renderer if bid is of banner', function() { let request = spec.buildRequests(bidRequests); - let response = spec.interpretResponse(bannerBidResponse, request); - - expect(response[0].mediaType).to.equal('banner'); + let response = spec.interpretResponse(bidResponses, request); + expect(response[0].renderer).to.not.exist; }); - it('should check for valid video mediaType in case of multiformat request', function() { - let request = spec.buildRequests(videoBidRequests); - let response = spec.interpretResponse(videoBidResponse, request); + describe('Response checking', function () { + it('should check for valid response values', function () { + let request = spec.buildRequests(bidRequests); + let data = JSON.parse(request.data); + let 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); + expect(response[0].meta.networkId).to.equal(123); + expect(response[0].adserverTargeting.hb_buyid_pubmatic).to.equal('BUYER-ID-987'); + expect(response[0].meta.buyerId).to.equal(976); + expect(response[0].meta.clickUrl).to.equal('blackrock.com'); + expect(response[0].referrer).to.include(data.site.ref); + expect(response[0].ad).to.equal(bidResponses.body.seatbid[0].bid[0].adm); + expect(response[0].pm_seat).to.equal(bidResponses.body.seatbid[0].seat); + expect(response[0].pm_dspid).to.equal(bidResponses.body.seatbid[0].bid[0].ext.dspid); + + expect(response[1].requestId).to.equal(bidResponses.body.seatbid[1].bid[0].impid); + expect(response[1].cpm).to.equal((bidResponses.body.seatbid[1].bid[0].price).toFixed(2)); + expect(response[1].width).to.equal(bidResponses.body.seatbid[1].bid[0].w); + expect(response[1].height).to.equal(bidResponses.body.seatbid[1].bid[0].h); + if (bidResponses.body.seatbid[1].bid[0].crid) { + expect(response[1].creativeId).to.equal(bidResponses.body.seatbid[1].bid[0].crid); + } else { + expect(response[1].creativeId).to.equal(bidResponses.body.seatbid[1].bid[0].id); + } + expect(response[1].dealId).to.equal(bidResponses.body.seatbid[1].bid[0].dealid); + expect(response[1].currency).to.equal('USD'); + expect(response[1].netRevenue).to.equal(false); + expect(response[1].ttl).to.equal(300); + expect(response[1].meta.networkId).to.equal(422); + expect(response[1].adserverTargeting.hb_buyid_pubmatic).to.equal('BUYER-ID-789'); + expect(response[1].meta.buyerId).to.equal(832); + expect(response[1].meta.clickUrl).to.equal('hivehome.com'); + expect(response[1].referrer).to.include(data.site.ref); + expect(response[1].ad).to.equal(bidResponses.body.seatbid[1].bid[0].adm); + expect(response[1].pm_seat).to.equal(bidResponses.body.seatbid[1].seat || null); + expect(response[1].pm_dspid).to.equal(bidResponses.body.seatbid[1].bid[0].ext.dspid); + }); - expect(response[0].mediaType).to.equal('video'); - }); + it('should add a dummy bid when, empty bid is returned by hbopenbid', () => { + let request = spec.buildRequests(bidRequests); + let response = spec.interpretResponse(emptyBidResponse, request); + + request = JSON.parse(request.data); + expect(response).to.exist.and.be.an('array').with.length.above(0); + expect(response[0].requestId).to.equal(request.imp[0].id); + expect(response[0].width).to.equal(0); + expect(response[0].height).to.equal(0); + expect(response[0].ttl).to.equal(300); + expect(response[0].ad).to.equal(''); + expect(response[0].creativeId).to.equal(0); + expect(response[0].netRevenue).to.equal(false); + expect(response[0].cpm).to.equal(0); + expect(response[0].currency).to.equal('USD'); + expect(response[0].referrer).to.equal(request.site && request.site.ref ? request.site.ref : ''); + }); - it('should check for valid native mediaType in case of multiformat request', function() { - let request = spec.buildRequests(nativeBidRequests); - let response = spec.interpretResponse(nativeBidResponse, request); + it('should add one dummy & one original bid if partial response come from hbopenbid', () => { + let request = spec.buildRequests([firstBid, secoundBid]); + let response = spec.interpretResponse({ + 'body': { + 'id': '93D3BAD6-E2E2-49FB-9D89-920B1761C865', + 'seatbid': [firstResponse] + } + }, request); + + request = JSON.parse(request.data); + expect(response).to.exist.and.be.an('array').with.length.above(0); + expect(response.length).to.equal(2); + 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); + expect(response[0].referrer).to.include(request.site && request.site.ref ? request.site.ref : ''); + expect(response[0].ad).to.equal(bidResponses.body.seatbid[0].bid[0].adm); + + expect(response[1].requestId).to.equal(request.imp[1].id); + expect(response[1].width).to.equal(0); + expect(response[1].height).to.equal(0); + expect(response[1].ttl).to.equal(300); + expect(response[1].ad).to.equal(''); + expect(response[1].creativeId).to.equal(0); + expect(response[1].netRevenue).to.equal(false); + expect(response[1].cpm).to.equal(0); + expect(response[1].currency).to.equal('USD'); + expect(response[1].referrer).to.equal(request.site && request.site.ref ? request.site.ref : ''); + }); - expect(response[0].mediaType).to.equal('native'); - }); + it('should responsed bid if partial response come from hbopenbid', () => { + let request = spec.buildRequests([firstBid]); + let response = spec.interpretResponse(bidResponses, request); + + request = JSON.parse(request.data); + expect(response.length).to.equal(1); + 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); + expect(response[0].referrer).to.include(request.site && request.site.ref ? request.site.ref : ''); + expect(response[0].ad).to.equal(bidResponses.body.seatbid[0].bid[0].adm); + }); - 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(); + it('should have a valid native bid response', function() { + let request = spec.buildRequests(nativeBidRequests); + let data = JSON.parse(request.data); + data.imp[0].id = '2a5571261281d4'; + request.data = JSON.stringify(data); + let response = spec.interpretResponse(nativeBidResponse, request); + expect(response).to.be.an('array').with.length.above(0); + expect(response[0].native).to.exist.and.to.be.an('object'); + expect(response[0].mediaType).to.exist.and.to.equal('native'); + expect(response[0].native.title).to.exist.and.to.be.an('string'); + expect(response[0].native.image).to.exist.and.to.be.an('object'); + expect(response[0].native.image.url).to.exist.and.to.be.an('string'); + expect(response[0].native.image.height).to.exist; + expect(response[0].native.image.width).to.exist; + expect(response[0].native.sponsoredBy).to.exist.and.to.be.an('string'); + expect(response[0].native.clickUrl).to.exist.and.to.be.an('string'); }); - 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('should check for valid banner mediaType in case of multiformat request', function() { + let request = spec.buildRequests(bidRequests); + let response = spec.interpretResponse(bannerBidResponse, request); + + expect(response[0].mediaType).to.equal('banner'); }); - it('CCPA/USP', function() { - expect(spec.getUserSyncs({ iframeEnabled: true }, {}, undefined, '1NYN')).to.deep.equal([{ - type: 'iframe', url: `${syncurl}&us_privacy=1NYN` - }]); + it('should check for valid video mediaType in case of multiformat request', function() { + let request = spec.buildRequests(videoBidRequests); + let response = spec.interpretResponse(videoBidResponse, request); + + expect(response[0].mediaType).to.equal('video'); }); - 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('should check for valid native mediaType in case of multiformat request', function() { + let request = spec.buildRequests(nativeBidRequests); + let response = spec.interpretResponse(nativeBidResponse, request); + + expect(response[0].mediaType).to.equal('native'); }); - it('COPPA: true', function() { - sandbox.stub(config, 'getConfig').callsFake(key => { - const config = { - 'coppa': true - }; - return config[key]; + describe('getUserSyncs', function() { + const syncurl_iframe = 'https://ads.pubmatic.com/AdServer/js/showad.js#PIX&kdntuid=1&p=5670'; + const syncurl_image = 'https://image8.pubmatic.com/AdServer/ImgSync?p=5670'; + let sandbox; + beforeEach(function () { + sandbox = sinon.sandbox.create(); + }); + afterEach(function() { + sandbox.restore(); }); - 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]; + it('execute as per config', function() { + expect(spec.getUserSyncs({ iframeEnabled: true }, {}, undefined, undefined)).to.deep.equal([{ + type: 'iframe', url: syncurl_iframe + }]); + expect(spec.getUserSyncs({ iframeEnabled: false }, {}, undefined, undefined)).to.deep.equal([{ + type: 'image', url: syncurl_image + }]); }); - 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]; + it('CCPA/USP', function() { + expect(spec.getUserSyncs({ iframeEnabled: true }, {}, undefined, '1NYN')).to.deep.equal([{ + type: 'iframe', url: `${syncurl_iframe}&us_privacy=1NYN` + }]); + expect(spec.getUserSyncs({ iframeEnabled: false }, {}, undefined, '1NYN')).to.deep.equal([{ + type: 'image', url: `${syncurl_image}&us_privacy=1NYN` + }]); + }); + + it('GDPR', function() { + expect(spec.getUserSyncs({ iframeEnabled: true }, {}, {gdprApplies: true, consentString: 'foo'}, undefined)).to.deep.equal([{ + type: 'iframe', url: `${syncurl_iframe}&gdpr=1&gdpr_consent=foo` + }]); + expect(spec.getUserSyncs({ iframeEnabled: true }, {}, {gdprApplies: false, consentString: 'foo'}, undefined)).to.deep.equal([{ + type: 'iframe', url: `${syncurl_iframe}&gdpr=0&gdpr_consent=foo` + }]); + expect(spec.getUserSyncs({ iframeEnabled: true }, {}, {gdprApplies: true, consentString: undefined}, undefined)).to.deep.equal([{ + type: 'iframe', url: `${syncurl_iframe}&gdpr=1&gdpr_consent=` + }]); + + expect(spec.getUserSyncs({ iframeEnabled: false }, {}, {gdprApplies: true, consentString: 'foo'}, undefined)).to.deep.equal([{ + type: 'image', url: `${syncurl_image}&gdpr=1&gdpr_consent=foo` + }]); + expect(spec.getUserSyncs({ iframeEnabled: false }, {}, {gdprApplies: false, consentString: 'foo'}, undefined)).to.deep.equal([{ + type: 'image', url: `${syncurl_image}&gdpr=0&gdpr_consent=foo` + }]); + expect(spec.getUserSyncs({ iframeEnabled: false }, {}, {gdprApplies: true, consentString: undefined}, undefined)).to.deep.equal([{ + type: 'image', url: `${syncurl_image}&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_iframe}&coppa=1` + }]); + expect(spec.getUserSyncs({ iframeEnabled: false }, {}, undefined, undefined)).to.deep.equal([{ + type: 'image', url: `${syncurl_image}&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_iframe}` + }]); + expect(spec.getUserSyncs({ iframeEnabled: false }, {}, undefined, undefined)).to.deep.equal([{ + type: 'image', url: `${syncurl_image}` + }]); + }); + + 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_iframe}&gdpr=1&gdpr_consent=foo&us_privacy=1NYN&coppa=1` + }]); + expect(spec.getUserSyncs({ iframeEnabled: false }, {}, {gdprApplies: true, consentString: 'foo'}, '1NYN')).to.deep.equal([{ + type: 'image', url: `${syncurl_image}&gdpr=1&gdpr_consent=foo&us_privacy=1NYN&coppa=1` + }]); }); - 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` - }]); }); }); }); diff --git a/test/spec/modules/pubmaticServerBidAdapter_spec.js b/test/spec/modules/pubmaticServerBidAdapter_spec.js index 62debc4eec0..ed897ab8242 100644 --- a/test/spec/modules/pubmaticServerBidAdapter_spec.js +++ b/test/spec/modules/pubmaticServerBidAdapter_spec.js @@ -7,9 +7,9 @@ describe('PubMaticServer adapter', () => { let bidRequests; let bidResponses; let errorCodeBidResponses; - window.PWT = {}; beforeEach(() => { + window.PWT = {}; window.PWT.bidMap = { '/19968336/header-bid-tag-1': { name: '/19968336/header-bid-tag-1', @@ -96,7 +96,14 @@ describe('PubMaticServer adapter', () => { 'bid': 1.3, 'width': 300, 'height': 250 - }] + }], + 'prebid': { + 'targeting': { + 'pwtbuyid_pubmatic': '15', + 'pwtpb': '6.60' + }, + 'type': '' + } } }], 'seat': 'pubmatic' @@ -137,6 +144,10 @@ describe('PubMaticServer adapter', () => { }; }); + afterEach(() => { + delete window.PWT; + }); + describe('implementation', () => { describe('Bid validations', () => { it('valid bid case', () => { @@ -433,10 +444,11 @@ describe('PubMaticServer adapter', () => { expect(response[0].netRevenue).to.equal(true); expect(response[0].ttl).to.equal(300); expect(response[0].serverSideResponseTime).to.equal(47); - expect(response[0].referrer).to.include(utils.getTopWindowUrl()); + expect(response[0].referrer).to.include(request.site && request.site.ref ? request.site.ref : ''); expect(response[0].ad).to.equal(bidResponses.body.seatbid[0].bid[0].adm); expect(response[0].originalBidder).to.equal(bidResponses.body.seatbid[0].bid[0].ext.summary[0].bidder); expect(response[0].bidderCode).to.equal(spec.code); + expect(response[0].adserverTargeting.pwtbuyid_pubmatic).to.equal('15'); }); }); diff --git a/test/spec/modules/pubnxBidAdapter_spec.js b/test/spec/modules/pubnxBidAdapter_spec.js deleted file mode 100644 index 002922fa066..00000000000 --- 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/pubstackAnalyticsAdapter_spec.js b/test/spec/modules/pubstackAnalyticsAdapter_spec.js new file mode 100644 index 00000000000..e3db334c888 --- /dev/null +++ b/test/spec/modules/pubstackAnalyticsAdapter_spec.js @@ -0,0 +1,38 @@ +import * as utils from 'src/utils.js'; +import pubstackAnalytics from '../../../modules/pubstackAnalyticsAdapter.js'; +import adapterManager from 'src/adapterManager'; +import events from 'src/events'; +import constants from 'src/constants.json' + +describe('Pubstack Analytics Adapter', () => { + const scope = utils.getWindowSelf(); + let queue = []; + + beforeEach(() => { + scope.PubstackAnalytics = (...args) => queue.push(args); + adapterManager.enableAnalytics({ + provider: 'pubstack' + }); + queue = [] + }); + + afterEach(() => { + pubstackAnalytics.disableAnalytics(); + }); + + it('should forward all events to the queue', () => { + // Given + const args = 'any-args' + + // When + events.emit(constants.EVENTS.AUCTION_END, args) + events.emit(constants.EVENTS.BID_REQUESTED, args) + events.emit(constants.EVENTS.BID_ADJUSTMENT, args) + events.emit(constants.EVENTS.BID_RESPONSE, args) + events.emit(constants.EVENTS.BID_WON, args) + events.emit(constants.EVENTS.NO_BID, args) + + // Then + expect(queue.length).to.eql(6); + }); +}); diff --git a/test/spec/modules/pubwiseAnalyticsAdapter_spec.js b/test/spec/modules/pubwiseAnalyticsAdapter_spec.js index b77788fff4a..5e4b2be894e 100644 --- a/test/spec/modules/pubwiseAnalyticsAdapter_spec.js +++ b/test/spec/modules/pubwiseAnalyticsAdapter_spec.js @@ -1,17 +1,10 @@ -import pubwiseAnalytics from 'modules/pubwiseAnalyticsAdapter'; +import pubwiseAnalytics from 'modules/pubwiseAnalyticsAdapter.js'; let events = require('src/events'); let adapterManager = require('src/adapterManager').default; let constants = require('src/constants.json'); describe('PubWise Prebid Analytics', function () { - let xhr; - - before(function () { - xhr = sinon.useFakeXMLHttpRequest(); - }); - after(function () { - xhr.restore(); pubwiseAnalytics.disableAnalytics(); }); diff --git a/test/spec/modules/pulsepointBidAdapter_spec.js b/test/spec/modules/pulsepointBidAdapter_spec.js index 6ab05a0a001..4b21856b68e 100644 --- a/test/spec/modules/pulsepointBidAdapter_spec.js +++ b/test/spec/modules/pulsepointBidAdapter_spec.js @@ -1,11 +1,16 @@ /* eslint dot-notation:0, quote-props:0 */ import {expect} from 'chai'; -import {spec} from 'modules/pulsepointBidAdapter'; -import {deepClone} from 'src/utils'; +import {spec} from 'modules/pulsepointBidAdapter.js'; +import {deepClone} from 'src/utils.js'; describe('PulsePoint Adapter Tests', function () { const slotConfigs = [{ placementCode: '/DfpAccount1/slot1', + mediaTypes: { + banner: { + sizes: [[728, 90], [160, 600]] + } + }, bidId: 'bid12345', params: { cp: 'p10000', @@ -42,7 +47,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 +323,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 +349,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 +411,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 +480,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 +564,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 +572,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 +582,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); @@ -655,4 +660,45 @@ describe('PulsePoint Adapter Tests', function () { userVerify(ortbRequest.user.ext.eids[4], 'parrable.com', 'parrable_id234'); userVerify(ortbRequest.user.ext.eids[5], 'liveintent.com', 'liveintent_id123'); }); + it('Verify multiple adsizes', function () { + const bidRequests = deepClone(slotConfigs); + const request = spec.buildRequests(bidRequests, bidderRequest); + expect(request).to.be.not.null; + expect(request.data).to.be.not.null; + const ortbRequest = request.data; + expect(ortbRequest.imp).to.have.lengthOf(2); + // first impression has multi sizes + expect(ortbRequest.imp[0].banner).to.not.be.null; + expect(ortbRequest.imp[0].banner.w).to.equal(300); + expect(ortbRequest.imp[0].banner.h).to.equal(250); + expect(ortbRequest.imp[0].banner.format).to.not.be.null; + expect(ortbRequest.imp[0].banner.format).to.have.lengthOf(2); + expect(ortbRequest.imp[0].banner.format[0].w).to.equal(728); + expect(ortbRequest.imp[0].banner.format[0].h).to.equal(90); + expect(ortbRequest.imp[0].banner.format[1].w).to.equal(160); + expect(ortbRequest.imp[0].banner.format[1].h).to.equal(600); + // slot 2 + expect(ortbRequest.imp[1].banner).to.not.be.null; + expect(ortbRequest.imp[1].banner.w).to.equal(728); + expect(ortbRequest.imp[1].banner.h).to.equal(90); + expect(ortbRequest.imp[1].banner.format).to.be.null; + // adsize on response + const ortbResponse = { + seatbid: [{ + bid: [{ + impid: ortbRequest.imp[0].id, + price: 1.25, + adm: 'This is an Ad', + crid: 'Creative#123', + w: 728, + h: 90 + }] + }] + }; + const bids = spec.interpretResponse({ body: ortbResponse }, request); + expect(bids).to.have.lengthOf(1); + const bid = bids[0]; + expect(bid.width).to.equal(728); + expect(bid.height).to.equal(90); + }); }); diff --git a/test/spec/modules/playgroundxyzBidAdapter_spec.js b/test/spec/modules/pxyzBidAdapter_spec.js similarity index 60% rename from test/spec/modules/playgroundxyzBidAdapter_spec.js rename to test/spec/modules/pxyzBidAdapter_spec.js index a90564003f4..6d8c6056076 100644 --- a/test/spec/modules/playgroundxyzBidAdapter_spec.js +++ b/test/spec/modules/pxyzBidAdapter_spec.js @@ -1,12 +1,18 @@ import { expect } from 'chai'; -import { spec } from 'modules/playgroundxyzBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; -import { deepClone } from 'src/utils'; +import { spec } from 'modules/pxyzBidAdapter.js'; +import { newBidder } from 'src/adapters/bidderFactory.js'; +import { deepClone } from 'src/utils.js'; const URL = 'https://ads.playground.xyz/host-config/prebid?v=2'; const GDPR_CONSENT = 'XYZ-CONSENT'; -describe('playgroundxyzBidAdapter', function () { +const BIDDER_REQUEST = { + refererInfo: { + referer: 'https://example.com' + } +}; + +describe('pxyzBidAdapter', function () { const adapter = newBidder(spec); describe('inherited functions', function () { @@ -17,7 +23,7 @@ describe('playgroundxyzBidAdapter', function () { describe('isBidRequestValid', function () { let bid = { - 'bidder': 'playgroundxyz', + 'bidder': 'pxyz', 'params': { 'placementId': '10433394' }, @@ -45,7 +51,7 @@ describe('playgroundxyzBidAdapter', function () { describe('buildRequests', function () { let bidRequests = [ { - 'bidder': 'playgroundxyz', + 'bidder': 'pxyz', 'params': { 'placementId': '10433394' }, @@ -58,9 +64,7 @@ describe('playgroundxyzBidAdapter', function () { ]; it('sends bid request to ENDPOINT via POST', function () { - let bidRequest = Object.assign([], bidRequests); - - const request = spec.buildRequests(bidRequest); + const request = spec.buildRequests(bidRequests, BIDDER_REQUEST); const data = JSON.parse(request.data); const banner = data.imp[0].banner; @@ -70,6 +74,72 @@ describe('playgroundxyzBidAdapter', function () { expect(request.url).to.equal(URL); expect(request.method).to.equal('POST'); }); + + describe('CCPA', function () { + describe('when USP consent object is NOT present in bidder request', function () { + const request = spec.buildRequests(bidRequests, BIDDER_REQUEST); + const data = JSON.parse(request.data); + it('should not populate ext.gdpr or ext.consent', function () { + expect(data).to.not.have.property('Regs.ext.us_privacy'); + }); + }); + + describe('when USP consent object is present in bidder request', function () { + describe('when GDPR is applicable', function () { + const request = spec.buildRequests( + bidRequests, + Object.assign({}, BIDDER_REQUEST, { uspConsent: '1YYY' }) + ); + const data = JSON.parse(request.data); + it('should set Regs.ext.us_privacy with the correct value', function () { + expect(data.Regs.ext['us_privacy']).to.equal('1YYY'); + }); + }); + }); + }); + + describe('GDPR', function () { + describe('when no GDPR consent object is present in bidder request', function () { + const request = spec.buildRequests(bidRequests, BIDDER_REQUEST); + const data = JSON.parse(request.data); + it('should not populate ext.gdpr or ext.consent', function () { + expect(data).to.not.have.property('Regs.ext.consent'); + }); + }); + + describe('when GDPR consent object is present in bidder request', function () { + describe('when GDPR is applicable', function () { + const request = spec.buildRequests( + bidRequests, + Object.assign({}, BIDDER_REQUEST, { + gdprConsent: { gdprApplies: true, consentString: GDPR_CONSENT } + }) + ); + const data = JSON.parse(request.data); + it('should set ext.gdpr with 1', function () { + expect(data.Regs.ext.gdpr).to.equal(1); + }); + it('should set ext.consent', function () { + expect(data.User.ext.consent).to.equal('XYZ-CONSENT'); + }); + }); + describe('when GDPR is NOT applicable', function () { + const request = spec.buildRequests( + bidRequests, + Object.assign({}, BIDDER_REQUEST, { + gdprConsent: { gdprApplies: false, consentString: GDPR_CONSENT } + }) + ); + const data = JSON.parse(request.data); + it('should set ext.gdpr to 0', function () { + expect(data.Regs.ext.gdpr).to.equal(0); + }); + it('should populate ext.consent', function () { + expect(data.User.ext.consent).to.equal('XYZ-CONSENT'); + }); + }); + }); + }); }) describe('interpretResponse', function () { @@ -106,7 +176,7 @@ describe('playgroundxyzBidAdapter', function () { }; let bidderRequest = { - 'bidderCode': 'playgroundxyz' + 'bidderCode': 'pxyz' }; it('should get correct bid response', function () { @@ -135,54 +205,6 @@ describe('playgroundxyzBidAdapter', function () { }); }); - 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'; diff --git a/test/spec/modules/quantcastBidAdapter_spec.js b/test/spec/modules/quantcastBidAdapter_spec.js index 7e7d47d3644..cd168ec61e6 100644 --- a/test/spec/modules/quantcastBidAdapter_spec.js +++ b/test/spec/modules/quantcastBidAdapter_spec.js @@ -8,9 +8,10 @@ import { QUANTCAST_PROTOCOL, QUANTCAST_PORT, spec as qcSpec -} from '../../../modules/quantcastBidAdapter'; -import { newBidder } from '../../../src/adapters/bidderFactory'; -import { parse } from 'src/url'; +} from '../../../modules/quantcastBidAdapter.js'; +import { newBidder } from '../../../src/adapters/bidderFactory.js'; +import { parseUrl } from 'src/utils.js'; +import { config } from 'src/config.js'; describe('Quantcast adapter', function () { const quantcastAdapter = newBidder(qcSpec); @@ -89,13 +90,13 @@ describe('Quantcast adapter', function () { describe('`buildRequests`', function () { it('sends secure bid requests', function () { const requests = qcSpec.buildRequests([bidRequest]); - const url = parse(requests[0]['url']); + const url = parseUrl(requests[0]['url']); expect(url.protocol).to.equal('https'); }); it('sends bid requests to Quantcast Canary Endpoint if `publisherId` is `test-publisher`', function () { const requests = qcSpec.buildRequests([bidRequest]); - const url = parse(requests[0]['url']); + const url = parseUrl(requests[0]['url']); expect(url.hostname).to.equal(QUANTCAST_TEST_DOMAIN); }); @@ -138,6 +139,7 @@ describe('Quantcast adapter', function () { bidId: '2f7b179d443f14', gdprSignal: 0, uspSignal: 0, + coppa: 0, prebidJsVersion: '$prebid.version$' }; @@ -205,6 +207,7 @@ describe('Quantcast adapter', function () { bidId: '2f7b179d443f14', gdprSignal: 0, uspSignal: 0, + coppa: 0, prebidJsVersion: '$prebid.version$' }; @@ -240,6 +243,7 @@ describe('Quantcast adapter', function () { bidId: '2f7b179d443f14', gdprSignal: 0, uspSignal: 0, + coppa: 0, prebidJsVersion: '$prebid.version$' }; @@ -271,6 +275,7 @@ describe('Quantcast adapter', function () { bidId: '2f7b179d443f14', gdprSignal: 0, uspSignal: 0, + coppa: 0, prebidJsVersion: '$prebid.version$' }; @@ -334,6 +339,7 @@ describe('Quantcast adapter', function () { bidId: '2f7b179d443f14', gdprSignal: 0, uspSignal: 0, + coppa: 0, prebidJsVersion: '$prebid.version$' }; @@ -342,13 +348,254 @@ describe('Quantcast adapter', function () { }); it('propagates GDPR consent string and signal', function () { - const bidderRequest = { gdprConsent: { gdprApplies: true, consentString: 'consentString' } } + 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('consentString'); + }); + + it('allows TCF v1 request with consent for purpose 1', function () { + const bidderRequest = { + gdprConsent: { + gdprApplies: true, + consentString: 'consentString', + vendorData: { + vendorConsents: { + '11': true + }, + purposeConsents: { + '1': true + } + }, + apiVersion: 1 + } + }; + + const requests = qcSpec.buildRequests([bidRequest], bidderRequest); + const parsed = JSON.parse(requests[0].data); + + expect(parsed.gdprSignal).to.equal(1); + expect(parsed.gdprConsent).to.equal('consentString'); + }); + + it('blocks TCF v1 request without vendor consent', function () { + const bidderRequest = { + gdprConsent: { + gdprApplies: true, + consentString: 'consentString', + vendorData: { + vendorConsents: { + '11': false + }, + purposeConsents: { + '1': true + } + }, + apiVersion: 1 + } + }; + + const requests = qcSpec.buildRequests([bidRequest], bidderRequest); + + expect(requests).to.equal(undefined); + }); + + it('blocks TCF v1 request without consent for purpose 1', function () { + const bidderRequest = { + gdprConsent: { + gdprApplies: true, + consentString: 'consentString', + vendorData: { + vendorConsents: { + '11': true + }, + purposeConsents: { + '1': false + } + }, + apiVersion: 1 + } + }; + + const requests = qcSpec.buildRequests([bidRequest], bidderRequest); + + expect(requests).to.equal(undefined); + }); + + it('allows TCF v2 request from Germany for purpose 1', function () { + const bidderRequest = { + gdprConsent: { + gdprApplies: true, + consentString: 'consentString', + vendorData: { + publisherCC: 'DE', + purposeOneTreatment: true + }, + apiVersion: 2 + } + }; + + const requests = qcSpec.buildRequests([bidRequest], bidderRequest); + const parsed = JSON.parse(requests[0].data); + + expect(parsed.gdprSignal).to.equal(1); + expect(parsed.gdprConsent).to.equal('consentString'); + }); + + it('allows TCF v2 request when Quantcast has consent for purpose 1', function() { + const bidderRequest = { + gdprConsent: { + gdprApplies: true, + consentString: 'consentString', + vendorData: { + vendor: { + consents: { + '11': true + } + }, + purpose: { + consents: { + '1': true + } + } + }, + apiVersion: 2 + } + }; + const requests = qcSpec.buildRequests([bidRequest], bidderRequest); const parsed = JSON.parse(requests[0].data); + expect(parsed.gdprSignal).to.equal(1); expect(parsed.gdprConsent).to.equal('consentString'); }); + it('blocks TCF v2 request when no consent for Quantcast', function() { + const bidderRequest = { + gdprConsent: { + gdprApplies: true, + consentString: 'consentString', + vendorData: { + vendor: { + consents: { + '11': false + } + }, + purpose: { + consents: { + '1': true + } + } + }, + apiVersion: 2 + } + }; + + const requests = qcSpec.buildRequests([bidRequest], bidderRequest); + + expect(requests).to.equal(undefined); + }); + + it('blocks TCF v2 request when no consent for purpose 1', function() { + const bidderRequest = { + gdprConsent: { + gdprApplies: true, + consentString: 'consentString', + vendorData: { + vendor: { + consents: { + '11': true + } + }, + purpose: { + consents: { + '1': false + } + } + }, + apiVersion: 2 + } + }; + + const requests = qcSpec.buildRequests([bidRequest], bidderRequest); + + expect(requests).to.equal(undefined); + }); + + it('blocks TCF v2 request when Quantcast not allowed by publisher', function () { + const bidderRequest = { + gdprConsent: { + gdprApplies: true, + consentString: 'consentString', + vendorData: { + vendor: { + consents: { + '11': true + } + }, + purpose: { + consents: { + '1': true + } + }, + publisher: { + restrictions: { + '1': { + '11': 0 + } + } + } + }, + apiVersion: 2 + } + }; + + const requests = qcSpec.buildRequests([bidRequest], bidderRequest); + + expect(requests).to.equal(undefined); + }); + + it('blocks TCF v2 request when legitimate interest required', function () { + const bidderRequest = { + gdprConsent: { + gdprApplies: true, + consentString: 'consentString', + vendorData: { + vendor: { + consents: { + '11': true + } + }, + purpose: { + consents: { + '1': true + } + }, + publisher: { + restrictions: { + '1': { + '11': 2 + } + } + } + }, + apiVersion: 2 + } + }; + + const requests = qcSpec.buildRequests([bidRequest], bidderRequest); + + expect(requests).to.equal(undefined); + }); + it('propagates US Privacy/CCPA consent information', function () { const bidderRequest = { uspConsent: 'consentString' } const requests = qcSpec.buildRequests([bidRequest], bidderRequest); @@ -357,6 +604,50 @@ describe('Quantcast adapter', function () { expect(parsed.uspConsent).to.equal('consentString'); }); + describe('propagates coppa', function() { + let sandbox; + beforeEach(() => { + sandbox = sinon.sandbox.create(); + }); + + afterEach(() => { + sandbox.restore(); + }); + + it('propagates coppa as 1 if coppa param is set to true in the bid request', function () { + bidRequest.params = { + publisherId: 'test_publisher_id', + coppa: true + }; + sandbox.stub(config, 'getConfig').callsFake((key) => { + const config = { + 'coppa': true + }; + return config[key]; + }); + const requests = qcSpec.buildRequests([bidRequest], bidderRequest); + expect(JSON.parse(requests[0].data).coppa).to.equal(1); + }); + + it('propagates coppa as 0 if there is no coppa param or coppa is set to false in the bid request', function () { + const requestsWithoutCoppa = qcSpec.buildRequests([bidRequest], bidderRequest); + expect(JSON.parse(requestsWithoutCoppa[0].data).coppa).to.equal(0); + + bidRequest.params = { + publisherId: 'test_publisher_id', + coppa: false + }; + sandbox.stub(config, 'getConfig').callsFake((key) => { + const config = { + 'coppa': false + }; + return config[key]; + }); + const requestsWithFalseCoppa = qcSpec.buildRequests([bidRequest], bidderRequest); + expect(JSON.parse(requestsWithFalseCoppa[0].data).coppa).to.equal(0); + }); + }); + describe('`interpretResponse`', function () { // The sample response is from https://wiki.corp.qc/display/adinf/QCX const body = { @@ -492,5 +783,67 @@ describe('Quantcast adapter', function () { expect(interpretedResponse.length).to.equal(0); }); + + it('should return pixel url when available userSync available', function () { + const syncOptions = { + pixelEnabled: true + }; + const serverResponses = [ + { + body: { + userSync: { + url: 'http://quantcast.com/pixelUrl' + } + } + }, + { + body: { + + } + } + ]; + + const actualSyncs = qcSpec.getUserSyncs(syncOptions, serverResponses); + const expectedSync = { + type: 'image', + url: 'http://quantcast.com/pixelUrl' + }; + expect(actualSyncs.length).to.equal(1); + expect(actualSyncs[0]).to.deep.equal(expectedSync); + qcSpec.resetUserSync(); + }); + + it('should not return user syncs if done already', function () { + const syncOptions = { + pixelEnabled: true + }; + const serverResponses = [ + { + body: { + userSync: { + url: 'http://quantcast.com/pixelUrl' + } + } + }, + { + body: { + + } + } + ]; + + let actualSyncs = qcSpec.getUserSyncs(syncOptions, serverResponses); + const expectedSync = { + type: 'image', + url: 'http://quantcast.com/pixelUrl' + }; + expect(actualSyncs.length).to.equal(1); + expect(actualSyncs[0]).to.deep.equal(expectedSync); + + actualSyncs = qcSpec.getUserSyncs(syncOptions, serverResponses); + expect(actualSyncs.length).to.equal(0); + + qcSpec.resetUserSync(); + }); }); }); diff --git a/test/spec/modules/quantumBidAdapter_spec.js b/test/spec/modules/quantumBidAdapter_spec.js index d14d24ebfe1..c03d74ea52e 100644 --- a/test/spec/modules/quantumBidAdapter_spec.js +++ b/test/spec/modules/quantumBidAdapter_spec.js @@ -1,8 +1,8 @@ import { expect } from 'chai' -import { spec } from 'modules/quantumBidAdapter' -import { newBidder } from 'src/adapters/bidderFactory' +import { spec } from 'modules/quantumBidAdapter.js' +import { newBidder } from 'src/adapters/bidderFactory.js' -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/radsBidAdapter_spec.js b/test/spec/modules/radsBidAdapter_spec.js index 6981955f261..c629daf3da5 100644 --- a/test/spec/modules/radsBidAdapter_spec.js +++ b/test/spec/modules/radsBidAdapter_spec.js @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import { spec } from 'modules/radsBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; +import { spec } from 'modules/radsBidAdapter.js'; +import { newBidder } from 'src/adapters/bidderFactory.js'; const RADS_ENDPOINT_URL = 'https://rads.recognified.net/md.request.php'; diff --git a/test/spec/modules/rdnBidAdapter_spec.js b/test/spec/modules/rdnBidAdapter_spec.js deleted file mode 100755 index 8f53502bc44..00000000000 --- 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 index 5fcdf9b5836..eb9077fac39 100644 --- a/test/spec/modules/readpeakBidAdapter_spec.js +++ b/test/spec/modules/readpeakBidAdapter_spec.js @@ -1,25 +1,32 @@ import { expect } from 'chai'; -import { spec, ENDPOINT } from 'modules/readpeakBidAdapter'; -import * as utils from 'src/utils'; -import {config} from 'src/config'; +import { spec, ENDPOINT } from 'modules/readpeakBidAdapter.js'; +import { config } from 'src/config.js'; +import { parseUrl } from 'src/utils.js'; -describe('ReadPeakAdapter', function () { - let bidRequest - let serverResponse - let serverRequest +describe('ReadPeakAdapter', function() { + let bidRequest; + let serverResponse; + let serverRequest; + let bidderRequest; + + beforeEach(function() { + bidderRequest = { + refererInfo: { + referer: 'https://publisher.com/home' + } + }; - beforeEach(function () { bidRequest = { bidder: 'readpeak', nativeParams: { title: { required: true, len: 200 }, image: { wmin: 100 }, - sponsoredBy: { }, - body: {required: false}, - cta: {required: false}, + sponsoredBy: {}, + body: { required: false }, + cta: { required: false } }, params: { - bidfloor: 5.00, + bidfloor: 5.0, publisherId: '11bc5dd5-7421-4dd8-c926-40fa653bec76', siteId: '11bc5dd5-7421-4dd8-c926-40fa653bec77' }, @@ -27,166 +34,177 @@ describe('ReadPeakAdapter', function () { 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', - }, - }, + seatbid: [ + { + bid: [ { - 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' - ], - } - }], - }], - } + 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: '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' + 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' + bidfloor: 5, + bidfloorcur: 'USD' } ], - 'site': { - 'publisher': { - 'id': '11bc5dd5-7421-4dd8-c926-40fa653bec76' + site: { + publisher: { + id: '11bc5dd5-7421-4dd8-c926-40fa653bec76' }, - 'id': '11bc5dd5-7421-4dd8-c926-40fa653bec77', - 'ref': '', - 'page': 'http://localhost', - 'domain': 'localhost' + 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' + 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 + isPrebid: true }) - } + }; }); - describe('spec.isBidRequestValid', function () { - it('should return true when the required params are passed', function () { + 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 () { + 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 () { + it('should return false when the "publisherId" param is missing', function() { bidRequest.params = { - bidfloor: 5.00 + bidfloor: 5.0 }; expect(spec.isBidRequestValid(bidRequest)).to.equal(false); }); - it('should return false when no bid params are passed', function () { + 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 () { + 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 ]); + describe('spec.buildRequests', function() { + it('should create a POST request for every bid', function() { + const request = spec.buildRequests([bidRequest], bidderRequest); expect(request.method).to.equal('POST'); expect(request.url).to.equal(ENDPOINT); }); - it('should attach request data', function () { + it('should attach request data', function() { config.setConfig({ currency: { adServerCurrency: 'EUR' } }); - const request = spec.buildRequests([ bidRequest ]); + const request = spec.buildRequests([bidRequest], bidderRequest); const data = JSON.parse(request.data); expect(data.source.ext.prebid).to.equal('$prebid.version$'); - expect(data.id).to.equal(bidRequest.bidderRequestId) + 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', + domain: 'http://localhost:9876' }, id: bidRequest.params.siteId, - ref: window.top.document.referrer, - page: utils.getTopWindowLocation().href, - domain: utils.getTopWindowLocation().hostname, + page: bidderRequest.refererInfo.referer, + domain: parseUrl(bidderRequest.refererInfo.referer).hostname + }); + expect(data.device).to.deep.contain({ + ua: navigator.userAgent, + language: navigator.language }); - 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 () { + 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]; + 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, @@ -197,11 +215,19 @@ describe('ReadPeakAdapter', function () { 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') + 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/realTimeModule_spec.js b/test/spec/modules/realTimeModule_spec.js index 807781d5a9c..27440a3ec23 100644 --- a/test/spec/modules/realTimeModule_spec.js +++ b/test/spec/modules/realTimeModule_spec.js @@ -3,19 +3,23 @@ import { requestBidsHook, setTargetsAfterRequestBids, deepMerge -} from 'modules/rtdModule/index'; +} from 'modules/rtdModule/index.js'; import { init as browsiInit, addBrowsiTag, isIdMatchingAdUnit, setData -} from 'modules/browsiRtdProvider'; -import {config} from 'src/config'; -import {makeSlot} from '../integration/faker/googletag'; +} from 'modules/browsiRtdProvider.js'; +import { + init as audigentInit, + setData as setAudigentData +} from 'modules/audigentRtdProvider.js'; +import { config } from 'src/config.js'; +import { makeSlot } from '../integration/faker/googletag.js'; let expect = require('chai').expect; -describe('Real time module', function() { +describe('Real time module', function () { const conf = { 'realTimeData': { 'auctionDelay': 250, @@ -27,13 +31,14 @@ describe('Real time module', function() { 'pubKey': 'testPub', 'keyName': 'bv' } + }, { + 'name': 'audigent' }] - } }; - const predictions = - {p: { + const predictions = { + p: { 'browsiAd_2': { 'w': [ '/57778053/Browsi_Demo_Low', @@ -56,27 +61,35 @@ describe('Real time module', function() { 'p': 0.85 } } - }; + }; + + const audigentSegments = { + audigent_segments: { 'a': 1, 'b': 2 } + } function getAdUnitMock(code = 'adUnit-code') { return { code, - mediaTypes: {banner: {}, native: {}}, + mediaTypes: { banner: {}, native: {} }, sizes: [[300, 200], [300, 600]], - bids: [{bidder: 'sampleBidder', params: {placementId: 'banner-only-bidder'}}] + bids: [{ bidder: 'sampleBidder', params: { placementId: 'banner-only-bidder' } }] }; } function createSlots() { - const slot1 = makeSlot({code: '/57778053/Browsi_Demo_300x250', divId: 'browsiAd_1'}); + const slot1 = makeSlot({ code: '/57778053/Browsi_Demo_300x250', divId: 'browsiAd_1' }); return [slot1]; } - describe('Real time module with browsi provider', function() { + describe('Real time module with browsi provider', function () { afterEach(function () { $$PREBID_GLOBAL$$.requestBids.removeAll(); }); + after(function () { + config.resetConfig(); + }); + it('check module using bidsBackCallback', function () { let adUnits1 = [getAdUnitMock('browsiAd_1')]; let targeting = []; @@ -96,16 +109,13 @@ describe('Real time module', function() { targeting.push(Object.keys(value).toString()); }); }); - } - setTargetsAfterRequestBids(afterBidHook, adUnits1, true); - setTimeout(() => { expect(targeting.indexOf('bv')).to.be.greaterThan(-1); - }, 200); + } + setTargetsAfterRequestBids(afterBidHook, adUnits1, true); }); it('check module using requestBidsHook', function () { - console.log('entrance', new Date().getMinutes() + ':' + new Date().getSeconds()); let adUnits1 = [getAdUnitMock('browsiAd_1')]; let targeting = []; let dataReceived = null; @@ -122,16 +132,15 @@ describe('Real time module', function() { targeting.push(Object.keys(value).toString()); }); }); - } - requestBidsHook(afterBidHook, {adUnits: adUnits1}); - setTimeout(() => { + expect(targeting.indexOf('bv')).to.be.greaterThan(-1); dataReceived.adUnits.forEach(unit => { unit.bids.forEach(bid => { expect(bid.realTimeData).to.have.property('bv'); }); }); - }, 200); + } + requestBidsHook(afterBidHook, { adUnits: adUnits1 }); }); it('check object deep merge', function () { @@ -179,10 +188,10 @@ describe('Real time module', function() { expect(script.async).to.equal(true); const slots = createSlots(); - const test1 = isIdMatchingAdUnit('browsiAd_1', slots, ['/57778053/Browsi_Demo_300x250']); // true - const test2 = isIdMatchingAdUnit('browsiAd_1', slots, ['/57778053/Browsi_Demo_300x250', '/57778053/Browsi']); // true - const test3 = isIdMatchingAdUnit('browsiAd_1', slots, ['/57778053/Browsi_Demo_Low']); // false - const test4 = isIdMatchingAdUnit('browsiAd_1', slots, []); // true + const test1 = isIdMatchingAdUnit('browsiAd_1', slots[0], ['/57778053/Browsi_Demo_300x250']); // true + const test2 = isIdMatchingAdUnit('browsiAd_1', slots[0], ['/57778053/Browsi_Demo_300x250', '/57778053/Browsi']); // true + const test3 = isIdMatchingAdUnit('browsiAd_1', slots[0], ['/57778053/Browsi_Demo_Low']); // false + const test4 = isIdMatchingAdUnit('browsiAd_1', slots[0], []); // true expect(test1).to.equal(true); expect(test2).to.equal(true); @@ -190,4 +199,47 @@ describe('Real time module', function() { expect(test4).to.equal(true); }) }); + + describe('Real time module with Audigent provider', function () { + before(function () { + init(config); + audigentInit(config); + config.setConfig(conf); + setAudigentData(audigentSegments); + }); + + afterEach(function () { + $$PREBID_GLOBAL$$.requestBids.removeAll(); + config.resetConfig(); + }); + + it('check module using requestBidsHook', function () { + let adUnits1 = [getAdUnitMock('audigentAd_1')]; + let targeting = []; + let dataReceived = null; + + // set slot + const slotsB = createSlots(); + window.googletag.pubads().setSlots(slotsB); + + function afterBidHook(data) { + dataReceived = data; + slotsB.map(s => { + targeting = []; + s.getTargeting().map(value => { + targeting.push(Object.keys(value).toString()); + }); + }); + + dataReceived.adUnits.forEach(unit => { + unit.bids.forEach(bid => { + expect(bid.realTimeData).to.have.property('audigent_segments'); + expect(bid.realTimeData.audigent_segments).to.deep.equal(audigentSegments.audigent_segments); + }); + }); + } + + requestBidsHook(afterBidHook, { adUnits: adUnits1 }); + }); + }); }); diff --git a/test/spec/modules/realvuAnalyticsAdapter_spec.js b/test/spec/modules/realvuAnalyticsAdapter_spec.js index 359fb329359..e51a4e2e3a2 100644 --- a/test/spec/modules/realvuAnalyticsAdapter_spec.js +++ b/test/spec/modules/realvuAnalyticsAdapter_spec.js @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import realvuAnalyticsAdapter, { lib } from 'modules/realvuAnalyticsAdapter'; +import realvuAnalyticsAdapter, { lib } from 'modules/realvuAnalyticsAdapter.js'; import CONSTANTS from 'src/constants.json'; function addDiv(id) { @@ -71,7 +71,7 @@ describe('RealVu', function() { ] }; let result = realvuAnalyticsAdapter.checkIn(bid, '1Y'); - const b = window.top1.realvu_aa; + const b = Object.assign({}, window.top1.realvu_aa); let a = b.ads[0]; // console.log('a: ' + a.x + ', ' + a.y + ', ' + a.w + ', ' + a.h); // console.log('b: ' + b.x1 + ', ' + b.y1 + ', ' + b.x2 + ', ' + b.y2); @@ -116,7 +116,7 @@ describe('RealVu', function() { eventType: CONSTANTS.EVENTS.BID_RESPONSE, args: args }); - const boost = window.top1.realvu_aa; + const boost = Object.assign({}, window.top1.realvu_aa); expect(boost.ads[boost.len - 1].bids.length).to.equal(1); realvuAnalyticsAdapter.track({ @@ -128,8 +128,11 @@ describe('RealVu', function() { }); describe('Boost.', function () { - const boost = window.top1.realvu_aa; - + // const boost = window.top1.realvu_aa; + let boost; + beforeEach(function() { + boost = Object.assign({}, window.top1.realvu_aa); + }); it('brd', function () { let a1 = document.getElementById('ad1'); let p = boost.brd(a1, 'Left'); diff --git a/test/spec/modules/reklamstoreBidAdapter_spec.js b/test/spec/modules/reklamstoreBidAdapter_spec.js index 3ac40e20eaf..1dcd6c17ca4 100644 --- a/test/spec/modules/reklamstoreBidAdapter_spec.js +++ b/test/spec/modules/reklamstoreBidAdapter_spec.js @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import { spec } from 'modules/reklamstoreBidAdapter'; +import { spec } from 'modules/reklamstoreBidAdapter.js'; describe('reklamstoreBidAdapterTests', function() { let bidRequestData = { @@ -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/relaidoBidAdapter_spec.js b/test/spec/modules/relaidoBidAdapter_spec.js new file mode 100644 index 00000000000..f0d3a2fb6d8 --- /dev/null +++ b/test/spec/modules/relaidoBidAdapter_spec.js @@ -0,0 +1,323 @@ +import { expect } from 'chai'; +import { spec } from 'modules/relaidoBidAdapter.js'; +import * as utils from 'src/utils.js'; + +const UUID_KEY = 'relaido_uuid'; +const DEFAULT_USER_AGENT = window.navigator.userAgent; +const MOBILE_USER_AGENT = 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.5 Mobile/15E148 Safari/604.1'; + +const setUADefault = () => { window.navigator.__defineGetter__('userAgent', function () { return DEFAULT_USER_AGENT }) }; +const setUAMobile = () => { window.navigator.__defineGetter__('userAgent', function () { return MOBILE_USER_AGENT }) }; + +describe('RelaidoAdapter', function () { + const relaido_uuid = 'hogehoge'; + let bidRequest; + let bidderRequest; + let serverResponse; + let serverRequest; + + beforeEach(function () { + bidRequest = { + bidder: 'relaido', + params: { + placementId: '100000', + }, + mediaTypes: { + video: { + context: 'outstream', + playerSize: [ + [640, 360] + ] + } + }, + adUnitCode: 'test', + bidId: '2ed93003f7bb99', + bidderRequestId: '1c50443387a1f2', + auctionId: '413ed000-8c7a-4ba1-a1fa-9732e006f8c3', + transactionId: '5c2d064c-7b76-42e8-a383-983603afdc45', + bidRequestsCount: 1, + bidderRequestsCount: 1, + bidderWinsCount: 0 + }; + bidderRequest = { + timeout: 1000, + refererInfo: { + referer: 'https://publisher.com/home' + } + }; + serverResponse = { + body: { + status: 'ok', + price: 500, + model: 'vcpm', + currency: 'JPY', + creativeId: 1000, + uuid: relaido_uuid, + vast: '', + playerUrl: 'https://relaido/player.js', + syncUrl: 'https://relaido/sync.html' + } + }; + serverRequest = { + method: 'GET', + bidId: bidRequest.bidId, + width: bidRequest.mediaTypes.video.playerSize[0][0], + height: bidRequest.mediaTypes.video.playerSize[0][1], + mediaType: 'video', + }; + localStorage.setItem(UUID_KEY, relaido_uuid); + }); + + describe('spec.isBidRequestValid', function () { + it('should return true when the required params are passed by video', function () { + expect(spec.isBidRequestValid(bidRequest)).to.equal(true); + }); + + it('should return true when the required params are passed by banner', function () { + setUAMobile(); + bidRequest.mediaTypes = { + banner: { + sizes: [ + [300, 250] + ] + } + }; + expect(spec.isBidRequestValid(bidRequest)).to.equal(true); + setUADefault(); + }); + + it('should return false when the uuid are missing', function () { + localStorage.removeItem(UUID_KEY); + const result = !!(utils.isSafariBrowser()); + expect(spec.isBidRequestValid(bidRequest)).to.equal(result); + }); + + it('should return false when the placementId params are missing', function () { + bidRequest.params.placementId = undefined; + expect(spec.isBidRequestValid(bidRequest)).to.equal(false); + }); + + it('should return false when the mediaType video params are missing', function () { + bidRequest.mediaTypes = { + video: {} + }; + expect(spec.isBidRequestValid(bidRequest)).to.equal(false); + }); + + it('should return false when the mediaType banner params are missing', function () { + setUAMobile(); + bidRequest.mediaTypes = { + banner: {} + }; + expect(spec.isBidRequestValid(bidRequest)).to.equal(false); + setUADefault(); + }); + + it('should return false when the non-mobile', function () { + bidRequest.mediaTypes = { + banner: { + sizes: [ + [300, 250] + ] + } + }; + expect(spec.isBidRequestValid(bidRequest)).to.equal(false); + }); + + it('should return false when the mediaTypes params are missing', function () { + bidRequest.mediaTypes = {}; + expect(spec.isBidRequestValid(bidRequest)).to.equal(false); + }); + }); + + describe('spec.buildRequests', function () { + it('should build bid requests by video', function () { + const bidRequests = spec.buildRequests([bidRequest], bidderRequest); + expect(bidRequests).to.have.lengthOf(1); + const request = bidRequests[0]; + expect(request.method).to.equal('GET'); + expect(request.url).to.equal('https://api.relaido.jp/vast/v1/out/bid/100000'); + expect(request.bidId).to.equal(bidRequest.bidId); + expect(request.width).to.equal(bidRequest.mediaTypes.video.playerSize[0][0]); + expect(request.height).to.equal(bidRequest.mediaTypes.video.playerSize[0][1]); + expect(request.mediaType).to.equal('video'); + expect(request.data.ref).to.equal(bidderRequest.refererInfo.referer); + expect(request.data.timeout_ms).to.equal(bidderRequest.timeout); + expect(request.data.ad_unit_code).to.equal(bidRequest.adUnitCode); + expect(request.data.auction_id).to.equal(bidRequest.auctionId); + expect(request.data.bidder).to.equal(bidRequest.bidder); + expect(request.data.bidder_request_id).to.equal(bidRequest.bidderRequestId); + expect(request.data.bid_requests_count).to.equal(bidRequest.bidRequestsCount); + expect(request.data.bid_id).to.equal(bidRequest.bidId); + expect(request.data.transaction_id).to.equal(bidRequest.transactionId); + expect(request.data.media_type).to.equal('video'); + expect(request.data.uuid).to.equal(relaido_uuid); + expect(request.data.width).to.equal(bidRequest.mediaTypes.video.playerSize[0][0]); + expect(request.data.height).to.equal(bidRequest.mediaTypes.video.playerSize[0][1]); + }); + + it('should build bid requests by banner', function () { + bidRequest.mediaTypes = { + banner: { + sizes: [ + [640, 360] + ] + } + }; + const bidRequests = spec.buildRequests([bidRequest], bidderRequest); + expect(bidRequests).to.have.lengthOf(1); + const request = bidRequests[0]; + expect(request.mediaType).to.equal('banner'); + }); + }); + + describe('spec.interpretResponse', function () { + it('should build bid response by video', function () { + const bidResponses = spec.interpretResponse(serverResponse, serverRequest); + expect(bidResponses).to.have.lengthOf(1); + const response = bidResponses[0]; + expect(response.requestId).to.equal(serverRequest.bidId); + expect(response.width).to.equal(serverRequest.width); + expect(response.height).to.equal(serverRequest.height); + expect(response.cpm).to.equal(serverResponse.body.price); + expect(response.currency).to.equal(serverResponse.body.currency); + expect(response.creativeId).to.equal(serverResponse.body.creativeId); + expect(response.vastXml).to.equal(serverResponse.body.vast); + expect(response.ad).to.be.undefined; + }); + + it('should build bid response by banner', function () { + serverRequest.mediaType = 'banner'; + const bidResponses = spec.interpretResponse(serverResponse, serverRequest); + expect(bidResponses).to.have.lengthOf(1); + const response = bidResponses[0]; + expect(response.requestId).to.equal(serverRequest.bidId); + expect(response.width).to.equal(serverRequest.width); + expect(response.height).to.equal(serverRequest.height); + expect(response.cpm).to.equal(serverResponse.body.price); + expect(response.currency).to.equal(serverResponse.body.currency); + expect(response.creativeId).to.equal(serverResponse.body.creativeId); + expect(response.vastXml).to.be.undefined; + expect(response.ad).to.include(`
`); + expect(response.ad).to.include(``); + expect(response.ad).to.include(`window.RelaidoPlayer.renderAd`); + }); + + it('should not build bid response', function () { + serverResponse = {}; + const bidResponses = spec.interpretResponse(serverResponse, serverRequest); + expect(bidResponses).to.have.lengthOf(0); + }); + + it('should not build bid response', function () { + serverResponse = { + body: { + status: 'no_ad', + } + }; + const bidResponses = spec.interpretResponse(serverResponse, serverRequest); + expect(bidResponses).to.have.lengthOf(0); + }); + }); + + describe('spec.getUserSyncs', function () { + it('should choose iframe sync urls', function () { + let userSyncs = spec.getUserSyncs({iframeEnabled: true}, [serverResponse]); + expect(userSyncs).to.deep.equal([{ + type: 'iframe', + url: serverResponse.body.syncUrl + }]); + }); + + it('should choose iframe sync urls if serverResponse are empty', function () { + let userSyncs = spec.getUserSyncs({iframeEnabled: true}, []); + expect(userSyncs).to.deep.equal([{ + type: 'iframe', + url: 'https://api.relaido.jp/tr/v1/prebid/sync.html' + }]); + }); + + it('should choose iframe sync urls if syncUrl are undefined', function () { + serverResponse.body.syncUrl = undefined; + let userSyncs = spec.getUserSyncs({iframeEnabled: true}, [serverResponse]); + expect(userSyncs).to.deep.equal([{ + type: 'iframe', + url: 'https://api.relaido.jp/tr/v1/prebid/sync.html' + }]); + }); + + it('should return empty if iframeEnabled are false', function () { + let userSyncs = spec.getUserSyncs({iframeEnabled: false}, [serverResponse]); + expect(userSyncs).to.have.lengthOf(0); + }); + }); + + describe('spec.onBidWon', function () { + let stub; + beforeEach(() => { + stub = sinon.stub(utils, 'triggerPixel'); + }); + afterEach(() => { + stub.restore(); + }); + + it('Should create nurl pixel if bid nurl', function () { + let bid = { + bidder: bidRequest.bidder, + creativeId: serverResponse.body.creativeId, + cpm: serverResponse.body.price, + params: [bidRequest.params], + auctionId: bidRequest.auctionId, + requestId: bidRequest.bidId, + adId: '3b286a4db7031f', + adUnitCode: bidRequest.adUnitCode, + ref: window.location.href, + } + spec.onBidWon(bid); + const parser = utils.parseUrl(stub.getCall(0).args[0]); + const query = parser.search; + expect(parser.hostname).to.equal('api.relaido.jp'); + expect(parser.pathname).to.equal('/tr/v1/prebid/win.gif'); + expect(query.placement_id).to.equal('100000'); + expect(query.creative_id).to.equal('1000'); + expect(query.price).to.equal('500'); + expect(query.auction_id).to.equal('413ed000-8c7a-4ba1-a1fa-9732e006f8c3'); + expect(query.bid_id).to.equal('2ed93003f7bb99'); + expect(query.ad_id).to.equal('3b286a4db7031f'); + expect(query.ad_unit_code).to.equal('test'); + expect(query.ref).to.include(window.location.href); + }); + }); + + describe('spec.onTimeout', function () { + let stub; + beforeEach(() => { + stub = sinon.stub(utils, 'triggerPixel'); + }); + afterEach(() => { + stub.restore(); + }); + + it('Should create nurl pixel if bid nurl', function () { + const data = [{ + bidder: bidRequest.bidder, + bidId: bidRequest.bidId, + adUnitCode: bidRequest.adUnitCode, + auctionId: bidRequest.auctionId, + params: [bidRequest.params], + timeout: bidderRequest.timeout, + }]; + spec.onTimeout(data); + const parser = utils.parseUrl(stub.getCall(0).args[0]); + const query = parser.search; + expect(parser.hostname).to.equal('api.relaido.jp'); + expect(parser.pathname).to.equal('/tr/v1/prebid/timeout.gif'); + expect(query.placement_id).to.equal('100000'); + expect(query.timeout).to.equal('1000'); + expect(query.auction_id).to.equal('413ed000-8c7a-4ba1-a1fa-9732e006f8c3'); + expect(query.bid_id).to.equal('2ed93003f7bb99'); + expect(query.ad_unit_code).to.equal('test'); + expect(query.ref).to.include(window.location.href); + }); + }); +}); diff --git a/test/spec/modules/reloadBidAdapter_spec.js b/test/spec/modules/reloadBidAdapter_spec.js index 674c810d48a..b22dd9e7b92 100644 --- a/test/spec/modules/reloadBidAdapter_spec.js +++ b/test/spec/modules/reloadBidAdapter_spec.js @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import { spec } from 'modules/reloadBidAdapter'; +import { spec } from 'modules/reloadBidAdapter.js'; let getParams = () => { return JSON.parse(JSON.stringify({ diff --git a/test/spec/modules/resultsmediaBidAdapter_spec.js b/test/spec/modules/resultsmediaBidAdapter_spec.js new file mode 100644 index 00000000000..0e2d4c0013a --- /dev/null +++ b/test/spec/modules/resultsmediaBidAdapter_spec.js @@ -0,0 +1,574 @@ +import {spec} from '../../../modules/resultsmediaBidAdapter.js'; +import * as utils from '../../../src/utils.js'; +import * as sinon from 'sinon'; + +var r1adapter = spec; + +describe('resultsmedia adapter tests', function () { + beforeEach(function() { + this.defaultBidderRequest = { + 'refererInfo': { + 'referer': 'Reference Page', + 'stack': [ + 'aodomain.dvl', + 'page.dvl' + ] + } + }; + }); + + describe('Verify 1.0 POST Banner Bid Request', function () { + it('buildRequests works', function () { + var bidRequestList = [ + { + 'bidder': 'resultsmedia', + 'params': { + 'zoneId': 9999 + }, + 'mediaType': 'banner', + 'adUnitCode': 'div-gpt-ad-1438287399331-0', + 'sizes': [[300, 250]], + 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', + 'bidderRequestId': '418b37f85e772c', + 'auctionId': '18fd8b8b0bd757', + 'bidRequestsCount': 1, + 'bidId': '51ef8751f9aead' + } + ]; + + var bidRequest = r1adapter.buildRequests(bidRequestList, this.defaultBidderRequest); + + expect(bidRequest.url).to.have.string('https://bid306.rtbsrv.com/bidder/?bid=3mhdom&zoneId=9999&hbv='); + expect(bidRequest.method).to.equal('POST'); + const openrtbRequest = JSON.parse(bidRequest.data); + expect(openrtbRequest.site).to.not.equal(null); + expect(openrtbRequest.site.ref).to.equal('Reference Page'); + expect(openrtbRequest.device).to.not.equal(null); + expect(openrtbRequest.device.ua).to.equal(navigator.userAgent); + expect(openrtbRequest.device.dnt).to.equal(0); + expect(openrtbRequest.imp[0].banner).to.not.equal(null); + expect(openrtbRequest.imp[0].banner.format[0].w).to.equal(300); + expect(openrtbRequest.imp[0].banner.format[0].h).to.equal(250); + expect(openrtbRequest.imp[0].ext.bidder.zoneId).to.equal(9999); + }); + + it('interpretResponse works', function() { + var bidList = { + 'body': [ + { + 'impid': 'div-gpt-ad-1438287399331-0', + 'w': 300, + 'h': 250, + 'adm': '
My Compelling Ad
', + 'price': 1, + 'crid': 'cr-cfy24' + } + ] + }; + + var bannerBids = r1adapter.interpretResponse(bidList); + + expect(bannerBids.length).to.equal(1); + const bid = bannerBids[0]; + expect(bid.width).to.equal(300); + expect(bid.height).to.equal(250); + expect(bid.creativeId).to.equal('cr-cfy24'); + expect(bid.currency).to.equal('USD'); + expect(bid.netRevenue).to.equal(true); + expect(bid.cpm).to.equal(1.0); + expect(bid.ttl).to.equal(350); + }); + }); + + describe('Verify POST Video Bid Request', function() { + it('buildRequests works', function () { + var bidRequestList = [ + { + 'bidder': 'resultsmedia', + 'params': { + 'zoneId': 9999 + }, + 'mediaTypes': { + 'video': { + 'playerSize': [640, 480], + 'context': 'instream' + } + }, + 'adUnitCode': 'div-gpt-ad-1438287399331-1', + 'sizes': [ + [300, 250] + ], + 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', + 'bidderRequestId': '418b37f85e772c', + 'auctionId': '18fd8b8b0bd757', + 'bidRequestsCount': 1, + 'bidId': '51ef8751f9aead' + } + ]; + + var bidRequest = r1adapter.buildRequests(bidRequestList, this.defaultBidderRequest); + + expect(bidRequest.url).to.have.string('https://bid306.rtbsrv.com/bidder/?bid=3mhdom&zoneId=9999&hbv='); + expect(bidRequest.method).to.equal('POST'); + const openrtbRequest = JSON.parse(bidRequest.data); + expect(openrtbRequest.site).to.not.equal(null); + expect(openrtbRequest.device).to.not.equal(null); + expect(openrtbRequest.device.ua).to.equal(navigator.userAgent); + expect(openrtbRequest.device).to.have.property('dnt'); + expect(openrtbRequest.imp[0].video).to.not.equal(null); + expect(openrtbRequest.imp[0].video.w).to.equal(640); + expect(openrtbRequest.imp[0].video.h).to.equal(480); + expect(openrtbRequest.imp[0].video.mimes[0]).to.equal('video/mp4'); + expect(openrtbRequest.imp[0].video.protocols).to.eql([2, 3, 5, 6]); + expect(openrtbRequest.imp[0].video.startdelay).to.equal(0); + expect(openrtbRequest.imp[0].video.skip).to.equal(0); + expect(openrtbRequest.imp[0].video.playbackmethod).to.eql([1, 2, 3, 4]); + expect(openrtbRequest.imp[0].video.delivery[0]).to.equal(1); + expect(openrtbRequest.imp[0].video.api).to.eql([1, 2, 5]); + }); + + it('interpretResponse works', function() { + var bidList = { + 'body': [ + { + 'impid': 'div-gpt-ad-1438287399331-1', + 'price': 1, + 'adm': 'https://example.com/', + 'adomain': [ + 'test.com' + ], + 'cid': '467415', + 'crid': 'cr-vid', + 'w': 800, + 'h': 600 + } + ] + }; + + var videoBids = r1adapter.interpretResponse(bidList); + + expect(videoBids.length).to.equal(1); + const bid = videoBids[0]; + expect(bid.width).to.equal(800); + expect(bid.height).to.equal(600); + expect(bid.vastUrl).to.equal('https://example.com/'); + expect(bid.mediaType).to.equal('video'); + expect(bid.creativeId).to.equal('cr-vid'); + expect(bid.currency).to.equal('USD'); + expect(bid.netRevenue).to.equal(true); + expect(bid.cpm).to.equal(1.0); + expect(bid.ttl).to.equal(600); + }); + }); + + describe('misc buildRequests', function() { + it('should send GDPR Consent data to resultsmedia tag', function () { + var bidRequestList = [ + { + 'bidder': 'resultsmedia', + 'params': { + 'zoneId': 9999 + }, + 'mediaTypes': { + 'banner': { + 'sizes': [[300, 250]] + } + }, + 'adUnitCode': 'div-gpt-ad-1438287399331-3', + 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', + 'bidderRequestId': '418b37f85e772c', + 'auctionId': '18fd8b8b0bd757', + 'bidRequestsCount': 1, + 'bidId': '51ef8751f9aead' + } + ]; + + var consentString = 'testConsentString'; + var gdprBidderRequest = this.defaultBidderRequest; + gdprBidderRequest.gdprConsent = { + 'gdprApplies': true, + 'consentString': consentString + }; + + var bidRequest = r1adapter.buildRequests(bidRequestList, gdprBidderRequest); + + const openrtbRequest = JSON.parse(bidRequest.data); + expect(openrtbRequest.user.ext.consent).to.equal(consentString); + expect(openrtbRequest.regs.ext.gdpr).to.equal(true); + }); + + it('prefer 2.0 sizes', function () { + var bidRequestList = [ + { + 'bidder': 'resultsmedia', + 'params': { + 'zoneId': 9999 + }, + 'mediaTypes': { + 'banner': { + 'sizes': [[300, 600]] + } + }, + 'adUnitCode': 'div-gpt-ad-1438287399331-0', + 'sizes': [[300, 250]], + 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', + 'bidderRequestId': '418b37f85e772c', + 'auctionId': '18fd8b8b0bd757', + 'bidRequestsCount': 1, + 'bidId': '51ef8751f9aead' + } + ]; + + var bidRequest = r1adapter.buildRequests(bidRequestList, this.defaultBidderRequest); + + const openrtbRequest = JSON.parse(bidRequest.data); + expect(openrtbRequest.imp[0].banner.format[0].w).to.equal(300); + expect(openrtbRequest.imp[0].banner.format[0].h).to.equal(600); + }); + + it('does not return request for invalid banner size configuration', function () { + var bidRequestList = [ + { + 'bidder': 'resultsmedia', + 'params': { + 'zoneId': 9999 + }, + 'mediaTypes': { + 'banner': { + 'sizes': [[300]] + } + }, + 'adUnitCode': 'div-gpt-ad-1438287399331-0', + 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', + 'bidderRequestId': '418b37f85e772c', + 'auctionId': '18fd8b8b0bd757', + 'bidRequestsCount': 1, + 'bidId': '51ef8751f9aead' + } + ]; + + var bidRequest = r1adapter.buildRequests(bidRequestList, this.defaultBidderRequest); + expect(bidRequest.method).to.be.undefined; + }); + + it('does not return request for missing banner size configuration', function () { + var bidRequestList = [ + { + 'bidder': 'resultsmedia', + 'params': { + 'zoneId': 9999 + }, + 'mediaTypes': { + 'banner': {} + }, + 'adUnitCode': 'div-gpt-ad-1438287399331-0', + 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', + 'bidderRequestId': '418b37f85e772c', + 'auctionId': '18fd8b8b0bd757', + 'bidRequestsCount': 1, + 'bidId': '51ef8751f9aead' + } + ]; + + var bidRequest = r1adapter.buildRequests(bidRequestList, this.defaultBidderRequest); + expect(bidRequest.method).to.be.undefined; + }); + + it('reject bad sizes', function () { + var bidRequestList = [ + { + 'bidder': 'resultsmedia', + 'params': { + 'zoneId': 9999 + }, + 'mediaTypes': { + 'banner': {'sizes': [['400', '500'], ['4n0', '5g0']]} + }, + 'adUnitCode': 'div-gpt-ad-1438287399331-0', + 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', + 'bidderRequestId': '418b37f85e772c', + 'auctionId': '18fd8b8b0bd757', + 'bidRequestsCount': 1, + 'bidId': '51ef8751f9aead' + } + ]; + + var bidRequest = r1adapter.buildRequests(bidRequestList, this.defaultBidderRequest); + const openrtbRequest = JSON.parse(bidRequest.data); + expect(openrtbRequest.imp[0].banner.format.length).to.equal(1); + }); + + it('dnt is correctly set to 1', function () { + var bidRequestList = [ + { + 'bidder': 'resultsmedia', + 'params': { + 'zoneId': 9999 + }, + 'mediaTypes': { + 'banner': { + 'sizes': [[300, 600]] + } + }, + 'adUnitCode': 'div-gpt-ad-1438287399331-0', + 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', + 'bidderRequestId': '418b37f85e772c', + 'auctionId': '18fd8b8b0bd757', + 'bidRequestsCount': 1, + 'bidId': '51ef8751f9aead' + } + ]; + + var dntStub = sinon.stub(utils, 'getDNT').returns(1); + + var bidRequest = r1adapter.buildRequests(bidRequestList, this.defaultBidderRequest); + + dntStub.restore(); + + const openrtbRequest = JSON.parse(bidRequest.data); + expect(openrtbRequest.device.dnt).to.equal(1); + }); + + it('supports string video sizes', function () { + var bidRequestList = [ + { + 'bidder': 'resultsmedia', + 'params': { + 'zoneId': 9999 + }, + 'mediaTypes': { + 'video': { + 'context': 'instream', + 'playerSize': ['600', '300'] + } + }, + 'adUnitCode': 'div-gpt-ad-1438287399331-1', + 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', + 'bidderRequestId': '418b37f85e772c', + 'auctionId': '18fd8b8b0bd757', + 'bidRequestsCount': 1, + 'bidId': '51ef8751f9aead' + } + ]; + + var bidRequest = r1adapter.buildRequests(bidRequestList, this.defaultBidderRequest); + + const openrtbRequest = JSON.parse(bidRequest.data); + expect(openrtbRequest.imp[0].video.w).to.equal(600); + expect(openrtbRequest.imp[0].video.h).to.equal(300); + }); + + it('rejects bad video sizes', function () { + var bidRequestList = [ + { + 'bidder': 'resultsmedia', + 'params': { + 'zoneId': 9999 + }, + 'mediaTypes': { + 'video': { + 'context': 'instream', + 'playerSize': ['badWidth', 'badHeight'] + } + }, + 'adUnitCode': 'div-gpt-ad-1438287399331-1', + 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', + 'bidderRequestId': '418b37f85e772c', + 'auctionId': '18fd8b8b0bd757', + 'bidRequestsCount': 1, + 'bidId': '51ef8751f9aead' + } + ]; + + var bidRequest = r1adapter.buildRequests(bidRequestList, this.defaultBidderRequest); + + const openrtbRequest = JSON.parse(bidRequest.data); + expect(openrtbRequest.imp[0].video.w).to.be.undefined; + expect(openrtbRequest.imp[0].video.h).to.be.undefined; + }); + + it('supports missing video size', function () { + var bidRequestList = [ + { + 'bidder': 'resultsmedia', + 'params': { + 'zoneId': 9999 + }, + 'mediaTypes': { + 'video': { + 'context': 'instream' + } + }, + 'adUnitCode': 'div-gpt-ad-1438287399331-1', + 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', + 'bidderRequestId': '418b37f85e772c', + 'auctionId': '18fd8b8b0bd757', + 'bidRequestsCount': 1, + 'bidId': '51ef8751f9aead' + } + ]; + + var bidRequest = r1adapter.buildRequests(bidRequestList, this.defaultBidderRequest); + + const openrtbRequest = JSON.parse(bidRequest.data); + expect(openrtbRequest.imp[0].video.w).to.be.undefined; + expect(openrtbRequest.imp[0].video.h).to.be.undefined; + }); + + it('should return empty site data when refererInfo is missing', function() { + delete this.defaultBidderRequest.refererInfo; + var bidRequestList = [ + { + 'bidder': 'resultsmedia', + 'params': { + 'zoneId': 9999 + }, + 'mediaType': 'banner', + 'adUnitCode': 'div-gpt-ad-1438287399331-0', + 'sizes': [[300, 250]], + 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', + 'bidderRequestId': '418b37f85e772c', + 'auctionId': '18fd8b8b0bd757', + 'bidRequestsCount': 1, + 'bidId': '51ef8751f9aead' + } + ]; + + var bidRequest = r1adapter.buildRequests(bidRequestList, this.defaultBidderRequest); + const openrtbRequest = JSON.parse(bidRequest.data); + + expect(openrtbRequest.site.domain).to.equal(''); + expect(openrtbRequest.site.page).to.equal(''); + expect(openrtbRequest.site.ref).to.equal(''); + }); + }); + + it('should return empty site.domain and site.page when refererInfo.stack is empty', function() { + this.defaultBidderRequest.refererInfo.stack = []; + var bidRequestList = [ + { + 'bidder': 'resultsmedia', + 'params': { + 'zoneId': 9999 + }, + 'mediaType': 'banner', + 'adUnitCode': 'div-gpt-ad-1438287399331-0', + 'sizes': [[300, 250]], + 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', + 'bidderRequestId': '418b37f85e772c', + 'auctionId': '18fd8b8b0bd757', + 'bidRequestsCount': 1, + 'bidId': '51ef8751f9aead' + } + ]; + + var bidRequest = r1adapter.buildRequests(bidRequestList, this.defaultBidderRequest); + const openrtbRequest = JSON.parse(bidRequest.data); + + expect(openrtbRequest.site.domain).to.equal(''); + expect(openrtbRequest.site.page).to.equal(''); + expect(openrtbRequest.site.ref).to.equal('Reference Page'); + }); + + it('should secure correctly', function() { + this.defaultBidderRequest.refererInfo.stack[0] = ['https://securesite.dvl']; + var bidRequestList = [ + { + 'bidder': 'resultsmedia', + 'params': { + 'zoneId': 9999 + }, + 'mediaType': 'banner', + 'adUnitCode': 'div-gpt-ad-1438287399331-0', + 'sizes': [[300, 250]], + 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', + 'bidderRequestId': '418b37f85e772c', + 'auctionId': '18fd8b8b0bd757', + 'bidRequestsCount': 1, + 'bidId': '51ef8751f9aead' + } + ]; + + var bidRequest = r1adapter.buildRequests(bidRequestList, this.defaultBidderRequest); + const openrtbRequest = JSON.parse(bidRequest.data); + + expect(openrtbRequest.imp[0].secure).to.equal(1); + }); + + it('should pass schain', function() { + var schain = { + 'ver': '1.0', + 'complete': 1, + 'nodes': [{ + 'asi': 'indirectseller.com', + 'sid': '00001', + 'hp': 1 + }, { + 'asi': 'indirectseller-2.com', + 'sid': '00002', + 'hp': 1 + }] + }; + var bidRequestList = [ + { + 'bidder': 'resultsmedia', + 'params': { + 'zoneId': 9999 + }, + 'mediaType': 'banner', + 'adUnitCode': 'div-gpt-ad-1438287399331-0', + 'sizes': [[300, 250]], + 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', + 'bidderRequestId': '418b37f85e772c', + 'auctionId': '18fd8b8b0bd757', + 'bidRequestsCount': 1, + 'bidId': '51ef8751f9aead', + 'schain': schain + } + ]; + + var bidRequest = r1adapter.buildRequests(bidRequestList, this.defaultBidderRequest); + const openrtbRequest = JSON.parse(bidRequest.data); + + expect(openrtbRequest.source.ext.schain).to.deep.equal(schain); + }); + + describe('misc interpretResponse', function () { + it('No bid response', function() { + var noBidResponse = r1adapter.interpretResponse({ + 'body': '' + }); + expect(noBidResponse.length).to.equal(0); + }); + }); + + describe('isBidRequestValid', function () { + var bid = { + 'bidder': 'resultsmedia', + 'params': { + 'zoneId': 9999 + }, + 'mediaTypes': { + 'banner': { + 'sizes': [[300, 250]] + } + }, + 'adUnitCode': 'bannerDiv' + }; + + it('should return true when required params found', function () { + expect(r1adapter.isBidRequestValid(bid)).to.equal(true); + }); + + it('should return false when placementId missing', function () { + delete bid.params.zoneId; + expect(r1adapter.isBidRequestValid(bid)).to.equal(false); + }); + }); + + describe('getUserSyncs', function () { + it('returns an empty string', function () { + expect(r1adapter.getUserSyncs()).to.deep.equal([]); + }); + }); +}); diff --git a/test/spec/modules/revcontentBidAdapter_spec.js b/test/spec/modules/revcontentBidAdapter_spec.js new file mode 100644 index 00000000000..1aa08d9469e --- /dev/null +++ b/test/spec/modules/revcontentBidAdapter_spec.js @@ -0,0 +1,330 @@ +// jshint esversion: 6, es3: false, node: true +import {assert, expect} from 'chai'; +import {spec} from 'modules/revcontentBidAdapter.js'; +import { NATIVE } from 'src/mediaTypes.js'; +import { config } from 'src/config.js'; + +describe('revcontent adapter', function () { + let serverResponse, bidRequest, bidResponses; + let bids = []; + + describe('isBidRequestValid', function () { + let bid = { + bidder: 'revcontent', + nativeParams: {}, + params: { + size: {width: 300, height: 250}, + apiKey: '8a33fa9cf220ae685dcc3544f847cdda858d3b1c', + userId: 673, + domain: 'test.com', + endpoint: 'trends-s0.revcontent.com' + } + }; + + it('should return true when required params found', function () { + assert(spec.isBidRequestValid(bid)); + }); + + it('should return false when required params are missing', function () { + bid.params.apiKey = undefined; + assert.isFalse(spec.isBidRequestValid(bid)); + }); + }); + + describe('buildRequests', function () { + it('should send request with correct structure', function () { + let validBidRequests = [{ + bidder: 'revcontent', + nativeParams: {}, + params: { + size: {width: 300, height: 250}, + apiKey: '8a33fa9cf220ae685dcc3544f847cdda858d3b1c', + userId: 673, + widgetId: 33861, + endpoint: 'trends-s0.revcontent.com' + } + }]; + let request = spec.buildRequests(validBidRequests, {refererInfo: {referer: 'page'}}); + request = request[0]; + assert.equal(request.method, 'POST'); + assert.equal(request.url, 'https://trends-s0.revcontent.com/rtb?apiKey=8a33fa9cf220ae685dcc3544f847cdda858d3b1c&userId=673&widgetId=33861'); + assert.deepEqual(request.options, {contentType: 'application/json'}); + assert.ok(request.data); + }); + + it('should have default request structure', function () { + let keys = 'method,options,url,data,bid'.split(','); + let validBidRequests = [{ + bidder: 'revcontent', + nativeParams: {}, + params: { + size: {width: 300, height: 250}, + apiKey: '8a33fa9cf220ae685dcc3544f847cdda858d3b1c', + userId: 673, + domain: 'test.com', + endpoint: 'trends-s0.revcontent.com' + } + }]; + let request = spec.buildRequests(validBidRequests, {refererInfo: {referer: 'page'}}); + + request = request[0]; + let data = Object.keys(request); + + assert.deepEqual(keys, data); + }); + + it('should send info about device and unique bidfloor', function () { + let validBidRequests = [{ + bidder: 'revcontent', + nativeParams: {}, + params: { + size: {width: 300, height: 250}, + apiKey: '8a33fa9cf220ae685dcc3544f847cdda858d3b1c', + userId: 673, + domain: 'test.com', + endpoint: 'trends-s0.revcontent.com', + bidfloor: 0.05 + } + }]; + let request = spec.buildRequests(validBidRequests, {refererInfo: {referer: 'page'}}); + request = JSON.parse(request[0].data); + assert.equal(request.imp[0].bidfloor, 0.05); + assert.equal(request.device.ua, navigator.userAgent); + }); + + it('should send info about the site and default bidfloor', function () { + let validBidRequests = [{ + bidder: 'revcontent', + nativeParams: { + image: { + required: false + }, + 'title': { + required: false, + len: 140 + }, + clickUrl: { + required: false + }, + sponsoredBy: { + id: 5, + name: 'data', + type: 1 + } + }, + params: { + size: {width: 300, height: 250}, + apiKey: '8a33fa9cf220ae685dcc3544f847cdda858d3b1c', + userId: 673, + domain: 'test.com', + endpoint: 'trends-s0.revcontent.com' + } + }]; + let refererInfo = {referer: 'page'}; + let request = spec.buildRequests(validBidRequests, {refererInfo}); + + request = JSON.parse(request[0].data); + assert.equal(request.imp[0].bidfloor, 0.1); + assert.deepEqual(request.site, { + domain: 'test.com', + page: 'page', + cat: ['IAB17'], + publisher: {id: 673, domain: 'test.com'} + }); + }); + }); + + describe('interpretResponse', function () { + it('should return if no body in response', function () { + let serverResponse = {}; + let bidRequest = {}; + + assert.ok(!spec.interpretResponse(serverResponse, bidRequest)); + }); + + const serverResponse = { + body: { + id: '5d61ca27-1b7a-4d5a-90ad-bbfc93e53f58', + seatbid: [ + { + bid: [ + { + id: '6bbe3eed-f443-4e2b-a8da-57fd6327b37d', + impid: '1', + price: 0.1, + adid: '4162547', + nurl: 'https://trends-s0.revcontent.com/push/track/?p=${AUCTION_PRICE}&d=nTCdHIfsgKOLFuV7DS1LF%2FnTk5HiFduGU65BgKgB%2BvKyG9YV7ceQWN76HMbBE0C6gwQeXUjravv3Hq5x9TT8CM6r2oUNgkGC9mhgv2yroTH9i3cSoH%2BilxyY19fMXFirtBz%2BF%2FEXKi4bsNh%2BDMPfj0L4elo%2FJEZmx4nslvOneJJjsFjJJtUJc%2F3UPivOisSCa%2B36mAgFQqt%2FSWBriYB%2BVAufz70LaGspF6T6jDzuIyVFJUpLhZVDtLRSJEzh7Lyzzw1FmYarp%2FPg0gZDY48aDdjw5A3Tlj%2Bap0cPHLDprNOyF0dmHDn%2FOVJEDRTWvrQ2JNK1t%2Fg1bGHIih0ec6XBVIBNurqRpLFBuUY6LgXCt0wRZWTByTEZ8AEv8IoYVILJAL%2BXL%2F9IyS4eTcdOUfn5X7gT8QBghCrAFrsCg8ZXKgWddTEXbpN1lU%2FzHdI5eSHkxkJ6WcYxSkY9PyripaIbmKiyb98LQMgTD%2B20RJO5dAmXTQTAcauw6IUPTjgSPEU%2Bd6L5Txd3CM00Hbd%2Bw1bREIQcpKEmlMwrRSwe4bu1BCjlh5A9gvU9Xc2sf7ekS3qPPmtp059r5IfzdNFQJB5aH9HqeDEU%2FxbMHx4ggMgojLBBL1fKrCKLAteEDQxd7PVmFJv7GHU2733vt5TnjKiEhqxHVFyi%2B0MIYMGIziM5HfUqfq3KUf%2F%2FeiCtJKXjg7FS6hOambdimSt7BdGDIZq9QECWdXsXcQqqVLwli27HYDMFVU3TWWRyjkjbhnQID9gQJlcpwIi87jVAODb6qP%2FKGQ%3D%3D', + adm: '{"ver":"1.1","assets":[{"id":3,"required":1,"img":{"url":"//img.revcontent.com/?url=https://revcontent-p0.s3.amazonaws.com/content/images/15761052960288727821.jpg&static=true"}},{"id":0,"required":1,"title":{"text":"Do You Eat Any of These Craving-trigger Foods?"}},{"id":5,"required":1,"data":{"value":""}}],"link":{"url":"https://trends-s0.revcontent.com/click.php?d=A7EVbNYBVyonty19Ak08zCr9J54qg%2Bmduq6p0Zyn5%2F%2Bapm4deUo9VAXmOGEIbUBf6i7m3%2F%2FWJm%2FzTha8SJ%2Br9MZL9jhhUxDeiKb6aRY1biLrvr6tFUd1phvtKqVmPd76l9VBLFMxS1brSzKjRCJlIGmyGJg7ueFvxpE9X%2BpHmdbE2uqUdRC49ENO3XZyHCCKMAZ8XD29fasX9Kli9mKpZTqw8vayFlXbVYSUwB8wfSwCt1sIUrt0aICYc0jcyWU3785GTS1xXzQj%2FIVszFYYrdTWd%2BDijjNZtFny0OomPHp8lRy5VcQVCuLpw0Fks4myvsE38XcNvs4wO3tWTNrI%2BMqcW1%2BD2OnMSq5nN5FCbmi2ly%2F1LbN9fibaFvW%2FQbzQhN9ZsAwmhm409UTtdmSA6hd96vDxDWLeUJhVO3UQyI0yq2TtVnB9tEICD8mZNWwYehOab%2BQ1EWmTerF6ZCDx8RyZus1UrsDfRwvTCyUjCmkZhmeo4QVJkpPy6QobCsngSaxkkKhH%2Fb7coZyBXXEt3ORoYBLUbfRO6nR8GdIt8413vrYr4gTAroh46VcWK0ls0gFNe2u3%2FqP%2By1yLKbzDVaR%2Fa02G%2Biiqbw86sCYfsy7qK9atyjNTm8RkH6JLESUzxc6IEazu4iwHKGnu5phTacmseXCi8y9Y5AdBZn8VnLP%2F2a%2FyAqq93xEH%2BIrkAdhGRY1tY39rBYAtvH%2FVyNFZcong%2FutUMYbp0WhDNyfl6iWxmpE28Cx9KDcqXss0NIwQm0AWeu8ogJCIG3faAkm5PdFsUdf2X9h3HuFDbnbvnXW27ml6z9GykEzv%2F8aSZlMZ"}}' + } + ] + } + ], + bidid: '7f729368-edb2-427a-bde7-a55b3bf8837c' + }, + headers: {} + }; + + const bidRequest = { + method: 'POST', + options: { + contentType: 'application/json' + }, + url: 'https://trends-s0.revcontent.com/rtb?apiKey=8a33fa9cf220ae685dcc3544f847cdda858d3b1c&userId=673', + data: '{"id":"5d61ca27-1b7a-4d5a-90ad-bbfc93e53f58","imp":[{"id":1,"bidderRequestId":"14e4dab7b5396e8","auctionId":"5d61ca27-1b7a-4d5a-90ad-bbfc93e53f58","transactionId":"69e69abf-a3ea-484d-a81c-d48dd0d5eaa3","native":{"request":{"ver":"1.1","context":2,"contextsubtype":21,"plcmttype":4,"plcmtcnt":4,"assets":[{"required":0,"id":3,"img":{"type":3}},{"required":0,"id":0,"title":{"len":140}},{"required":0,"id":5,"data":{"type":1}}]},"ver":"1.1","battr":[1,3,8,11,17]},"instl":0,"bidfloor":0.1,"secure":"1"}],"site":{"domain":"test.com","page":"https://feudfun.com/test22/revcontent_example.php","cat":["IAB17"],"publisher":{"id":673,"domain":"test.com"}},"device":{"ua":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:71.0) Gecko/20100101 Firefox/71.0","language":"en"},"user":{"id":1},"at":2,"bcat":["IAB24","IAB25","IAB25-1","IAB25-2","IAB25-3","IAB25-4","IAB25-5","IAB25-6","IAB25-7","IAB26","IAB26-1","IAB26-2","IAB26-3","IAB26-4"]}', + bid: [ + { + bidder: 'revcontent', + params: { + size: { + width: 300, + height: 250 + }, + apiKey: '8a33fa9cf220ae685dcc3544f847cdda858d3b1c', + userId: 673, + domain: 'test.com', + endpoint: 'trends-s0.revcontent.com' + }, + crumbs: { + pubcid: '7a0b4adc-c109-49f0-aadc-4a4b62ebe269' + }, + nativeParams: { + image: { + required: false + }, + 'title': { + required: false, + len: 140 + }, + clickUrl: { + required: false + }, + sponsoredBy: { + id: 5, + name: 'data', + type: 1 + } + }, + mediaTypes: { + native: { + image: { + required: false + }, + title: { + required: false, + len: 140 + }, + clickUrl: { + required: false + }, + sponsoredBy: { + id: 5, + name: 'data', + type: 1 + } + } + }, + adUnitCode: '/19968336/header-bid-tag-1', + transactionId: '69e69abf-a3ea-484d-a81c-d48dd0d5eaa3', + sizes: [], + bidId: '294a7f446202848', + bidderRequestId: '14e4dab7b5396e8', + auctionId: '5d61ca27-1b7a-4d5a-90ad-bbfc93e53f58', + src: 'client', + bidRequestsCount: 1, + bidderRequestsCount: 1, + bidderWinsCount: 0 + } + ] + }; + + it('should set correct native params', function () { + const result = spec.interpretResponse(serverResponse, bidRequest)[0]; + + assert.equal(result.bidder, 'revcontent'); + assert.equal(result.bidderCode, 'revcontent'); + assert.equal(result.mediaType, 'native'); + assert.equal(result.requestId, '294a7f446202848'); + assert.equal(result.cpm, '0.1'); + assert.equal(result.creativeId, '4162547'); + }); + + it('validate template 728x90', function () { + bidRequest.bid[0].params.size.width = 728; + bidRequest.bid[0].params.size.height = 90; + + const result = spec.interpretResponse(serverResponse, bidRequest)[0]; + assert.equal(result.bidder, 'revcontent'); + assert.equal(result.bidderCode, 'revcontent'); + assert.equal(result.mediaType, 'native'); + assert.equal(result.requestId, '294a7f446202848'); + assert.equal(result.cpm, '0.1'); + assert.equal(result.creativeId, '4162547'); + }); + + it('validate template 300x600', function () { + bidRequest.bid[0].params.size.width = 300; + bidRequest.bid[0].params.size.height = 600; + + const result = spec.interpretResponse(serverResponse, bidRequest)[0]; + assert.equal(result.bidder, 'revcontent'); + assert.equal(result.bidderCode, 'revcontent'); + assert.equal(result.mediaType, 'native'); + assert.equal(result.requestId, '294a7f446202848'); + assert.equal(result.cpm, '0.1'); + assert.equal(result.creativeId, '4162547'); + }); + + it('validate template custom template', function () { + bidRequest.bid[0].params.template = '

{title}

SEE MORE
'; + + const result = spec.interpretResponse(serverResponse, bidRequest)[0]; + assert.equal(result.bidder, 'revcontent'); + assert.equal(result.bidderCode, 'revcontent'); + assert.equal(result.mediaType, 'native'); + assert.equal(result.requestId, '294a7f446202848'); + assert.equal(result.cpm, '0.1'); + assert.equal(result.creativeId, '4162547'); + }); + + it('validate template custom invalid template', function () { + bidRequest.bid[0].params.size.width = 100; + bidRequest.bid[0].params.size.height = 200; + + const result = spec.interpretResponse(serverResponse, bidRequest)[0]; + assert.equal(result.bidder, 'revcontent'); + assert.equal(result.bidderCode, 'revcontent'); + assert.equal(result.mediaType, 'native'); + assert.equal(result.requestId, '294a7f446202848'); + assert.equal(result.cpm, '0.1'); + assert.equal(result.creativeId, '4162547'); + }); + + it('should return empty when there is no bids in response', function () { + const serverResponse = { + body: { + id: null, + bidid: null, + seatbid: [{bid: []}], + cur: 'USD' + } + }; + let bidRequest = { + data: {}, + bids: [{bidId: 'bidId1'}] + }; + const result = spec.interpretResponse(serverResponse, bidRequest)[0]; + assert.ok(!result); + }); + }); + + describe('onBidWon', function () { + it('default bid won', function () { + const bid = { + nurl: 'https://trends-s0.revcontent.com/push/track/?p=${AUCTION_PRICE}&d=nTCdHIfsgKOLFuV7DS1LF%2FnTk5HiFduGU65BgKgB%2BvKyG9YV7ceQWN76HMbBE0C6gwQeXUjravv3Hq5x9TT8CM6r2oUNgkGC9mhgv2yroTH9i3cSoH%2BilxyY19fMXFirtBz%2BF%2FEXKi4bsNh%2BDMPfj0L4elo%2FJEZmx4nslvOneJJjsFjJJtUJc%2F3UPivOisSCa%2B36mAgFQqt%2FSWBriYB%2BVAufz70LaGspF6T6jDzuIyVFJUpLhZVDtLRSJEzh7Lyzzw1FmYarp%2FPg0gZDY48aDdjw5A3Tlj%2Bap0cPHLDprNOyF0dmHDn%2FOVJEDRTWvrQ2JNK1t%2Fg1bGHIih0ec6XBVIBNurqRpLFBuUY6LgXCt0wRZWTByTEZ8AEv8IoYVILJAL%2BXL%2F9IyS4eTcdOUfn5X7gT8QBghCrAFrsCg8ZXKgWddTEXbpN1lU%2FzHdI5eSHkxkJ6WcYxSkY9PyripaIbmKiyb98LQMgTD%2B20RJO5dAmXTQTAcauw6IUPTjgSPEU%2Bd6L5Txd3CM00Hbd%2Bw1bREIQcpKEmlMwrRSwe4bu1BCjlh5A9gvU9Xc2sf7ekS3qPPmtp059r5IfzdNFQJB5aH9HqeDEU%2FxbMHx4ggMgojLBBL1fKrCKLAteEDQxd7PVmFJv7GHU2733vt5TnjKiEhqxHVFyi%2B0MIYMGIziM5HfUqfq3KUf%2F%2FeiCtJKXjg7FS6hOambdimSt7BdGDIZq9QECWdXsXcQqqVLwli27HYDMFVU3TWWRyjkjbhnQID9gQJlcpwIi87jVAODb6qP%2FKGQ%3D%3D', + cpm: '0.1' + }; + const result = spec.onBidWon(bid); + assert.ok(result); + }); + }); +}); diff --git a/test/spec/modules/rexrtbBidAdapter_spec.js b/test/spec/modules/rexrtbBidAdapter_spec.js deleted file mode 100644 index b35e05bbf46..00000000000 --- 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 29c8de43c16..d9342332e61 100644 --- a/test/spec/modules/rhythmoneBidAdapter_spec.js +++ b/test/spec/modules/rhythmoneBidAdapter_spec.js @@ -1,5 +1,5 @@ -import {spec} from '../../../modules/rhythmoneBidAdapter'; -import * as utils from '../../../src/utils'; +import {spec} from '../../../modules/rhythmoneBidAdapter.js'; +import * as utils from '../../../src/utils.js'; import * as sinon from 'sinon'; var r1adapter = spec; @@ -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 82d4bf0d6c6..9772e8d717a 100644 --- a/test/spec/modules/richaudienceBidAdapter_spec.js +++ b/test/spec/modules/richaudienceBidAdapter_spec.js @@ -2,9 +2,10 @@ import {expect} from 'chai'; // may prefer 'assert' in place of 'expect' import { spec -} from 'modules/richaudienceBidAdapter'; -import {config} from 'src/config'; -import * as utils from 'src/utils'; +} from 'modules/richaudienceBidAdapter.js'; +import {config} from 'src/config.js'; +import * as utils from 'src/utils.js'; +import { getGlobal } from 'src/prebidGlobal.js'; describe('Richaudience adapter tests', function () { var DEFAULT_PARAMS = [{ @@ -181,7 +182,7 @@ describe('Richaudience adapter tests', function () { gdprApplies: true }, refererInfo: { - referer: 'http://domain.com', + referer: 'https://domain.com', numIframes: 0 } }); @@ -197,7 +198,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 +226,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 +270,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 } }); @@ -262,7 +280,7 @@ describe('Richaudience adapter tests', function () { }); describe('UID test', function () { - owpbjs.setConfig({ + getGlobal().setConfig({ consentManagement: { cmpApi: 'iab', timeout: 5000, @@ -486,7 +504,7 @@ describe('Richaudience adapter tests', function () { gdprApplies: true }, refererInfo: { - referer: 'http://domain.com', + referer: 'https://domain.com', numIframes: 0 } }); @@ -513,7 +531,7 @@ describe('Richaudience adapter tests', function () { gdprApplies: true }, refererInfo: { - referer: 'http://domain.com', + referer: 'https://domain.com', numIframes: 0 } }); @@ -622,7 +640,7 @@ describe('Richaudience adapter tests', function () { }, [], {consentString: '', gdprApplies: true}); expect(syncs).to.have.lengthOf(0); - owpbjs.setConfig({ + getGlobal().setConfig({ consentManagement: { cmpApi: 'iab', timeout: 5000, @@ -650,5 +668,15 @@ describe('Richaudience adapter tests', function () { }) expect(syncs).to.have.lengthOf(1); expect(syncs[0].type).to.equal('image'); + + syncs = spec.getUserSyncs({ + pixelEnabled: true + }, [], { + consentString: null, + referer: 'http://domain.com', + gdprApplies: true + }) + expect(syncs).to.have.lengthOf(1); + expect(syncs[0].type).to.equal('image'); }); }); diff --git a/test/spec/modules/rivrAnalyticsAdapter_spec.js b/test/spec/modules/rivrAnalyticsAdapter_spec.js index 2676c3a59b6..9add7ed5f7d 100644 --- a/test/spec/modules/rivrAnalyticsAdapter_spec.js +++ b/test/spec/modules/rivrAnalyticsAdapter_spec.js @@ -1,5 +1,5 @@ -import * as utils from 'src/utils'; -import analyticsAdapter from 'modules/rivrAnalyticsAdapter'; +import * as utils from 'src/utils.js'; +import analyticsAdapter from 'modules/rivrAnalyticsAdapter.js'; import { sendImpressions, handleClickEventWithClosureScope, @@ -15,10 +15,10 @@ import { storeAndReturnRivrUsrIdCookie, arrayDifference, activelyWaitForBannersToRender, -} from 'modules/rivrAnalyticsAdapter'; +} from 'modules/rivrAnalyticsAdapter.js'; import {expect} from 'chai'; -import adapterManager from 'src/adapterManager'; -import * as ajax from 'src/ajax'; +import adapterManager from 'src/adapterManager.js'; +import * as ajax from 'src/ajax.js'; import CONSTANTS from 'src/constants.json'; const events = require('../../../src/events'); diff --git a/test/spec/modules/rockyouBidAdapter_spec.js b/test/spec/modules/rockyouBidAdapter_spec.js deleted file mode 100644 index 65d87566c26..00000000000 --- 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 cd48cb7f37d..79c58e36735 100644 --- a/test/spec/modules/roxotAnalyticsAdapter_spec.js +++ b/test/spec/modules/roxotAnalyticsAdapter_spec.js @@ -1,13 +1,11 @@ -import roxotAnalytic from 'modules/roxotAnalyticsAdapter'; +import roxotAnalytic from 'modules/roxotAnalyticsAdapter.js'; import {expect} from 'chai'; +import {server} from 'test/mocks/xhr.js'; let events = require('src/events'); let constants = require('src/constants.json'); describe('Roxot Prebid Analytic', function () { - let xhr; - let requests; - let roxotConfigServerUrl = 'config-server'; let roxotEventServerUrl = 'event-server'; let publisherId = 'test_roxot_prebid_analytics_publisher_id'; @@ -161,17 +159,8 @@ describe('Roxot Prebid Analytic', function () { let bidderDone = bidRequested; let bidWon = bidAdjustmentWithBid; - before(function () { - xhr = sinon.useFakeXMLHttpRequest(); - xhr.onCreate = request => requests.push(request); - }); - after(function () { - xhr.restore(); - }); - describe('correct build and send events', function () { beforeEach(function () { - requests = []; sinon.stub(events, 'getEvents').returns([]); }); afterEach(function () { @@ -188,9 +177,9 @@ describe('Roxot Prebid Analytic', function () { } }); - expect(requests.length).to.equal(1); - expect(requests[0].url).to.equal('//' + roxotConfigServerUrl + '/c?publisherId=' + publisherId + '&host=localhost'); - requests[0].respond(200, {'Content-Type': 'application/json'}, '{"a": 1, "i": 1, "bat": 1}'); + expect(server.requests.length).to.equal(1); + expect(server.requests[0].url).to.equal('https://' + roxotConfigServerUrl + '/c?publisherId=' + publisherId + '&host=localhost'); + server.requests[0].respond(200, {'Content-Type': 'application/json'}, '{"a": 1, "i": 1, "bat": 1}'); events.emit(constants.EVENTS.AUCTION_INIT, auctionInit); events.emit(constants.EVENTS.BID_REQUESTED, bidRequested); @@ -205,13 +194,13 @@ describe('Roxot Prebid Analytic', function () { events.emit(constants.EVENTS.BIDDER_DONE, bidderDone); events.emit(constants.EVENTS.BID_WON, bidWon); - expect(requests.length).to.equal(4); + expect(server.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(server.requests[1].url).to.equal('https://' + roxotEventServerUrl + '/a?publisherId=' + publisherId + '&host=localhost'); + expect(server.requests[2].url).to.equal('https://' + roxotEventServerUrl + '/bat?publisherId=' + publisherId + '&host=localhost'); + expect(server.requests[3].url).to.equal('https://' + roxotEventServerUrl + '/i?publisherId=' + publisherId + '&host=localhost'); - let auction = JSON.parse(requests[1].requestBody); + let auction = JSON.parse(server.requests[1].requestBody); expect(auction).to.include.all.keys('event', 'eventName', 'options', 'data'); expect(auction.event).to.equal('a'); @@ -228,7 +217,7 @@ describe('Roxot Prebid Analytic', function () { expect(auction.data.adUnits[bidAfterTimeoutAdUnit].bidders[bidder].status).to.equal('timeout'); expect(auction.data.adUnits[noBidAdUnit].bidders[bidder].status).to.equal('noBid'); - let bidAfterTimeout = JSON.parse(requests[2].requestBody); + let bidAfterTimeout = JSON.parse(server.requests[2].requestBody); expect(bidAfterTimeout).to.include.all.keys('event', 'eventName', 'options', 'data'); expect(bidAfterTimeout.event).to.equal('bat'); @@ -237,7 +226,7 @@ describe('Roxot Prebid Analytic', function () { expect(bidAfterTimeout.data.bidder).to.equal(bidder); expect(bidAfterTimeout.data.cpm).to.equal(bidAdjustmentAfterTimeout.cpm); - let impression = JSON.parse(requests[3].requestBody); + let impression = JSON.parse(server.requests[3].requestBody); expect(impression).to.include.all.keys('event', 'eventName', 'options', 'data'); expect(impression.event).to.equal('i'); @@ -250,7 +239,6 @@ describe('Roxot Prebid Analytic', function () { describe('support ad unit filter', function () { beforeEach(function () { - requests = []; sinon.stub(events, 'getEvents').returns([]); }); afterEach(function () { @@ -268,9 +256,9 @@ describe('Roxot Prebid Analytic', function () { } }); - expect(requests.length).to.equal(1); - expect(requests[0].url).to.equal('//' + roxotConfigServerUrl + '/c?publisherId=' + publisherId + '&host=localhost'); - requests[0].respond(200, {'Content-Type': 'application/json'}, '{"a": 1, "i": 1, "bat": 1}'); + expect(server.requests.length).to.equal(1); + expect(server.requests[0].url).to.equal('https://' + roxotConfigServerUrl + '/c?publisherId=' + publisherId + '&host=localhost'); + server.requests[0].respond(200, {'Content-Type': 'application/json'}, '{"a": 1, "i": 1, "bat": 1}'); events.emit(constants.EVENTS.AUCTION_INIT, auctionInit); events.emit(constants.EVENTS.BID_REQUESTED, bidRequested); @@ -285,12 +273,12 @@ describe('Roxot Prebid Analytic', function () { events.emit(constants.EVENTS.BIDDER_DONE, bidderDone); events.emit(constants.EVENTS.BID_WON, bidWon); - expect(requests.length).to.equal(3); + expect(server.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(server.requests[1].url).to.equal('https://' + roxotEventServerUrl + '/a?publisherId=' + publisherId + '&host=localhost'); + expect(server.requests[2].url).to.equal('https://' + roxotEventServerUrl + '/bat?publisherId=' + publisherId + '&host=localhost'); - let auction = JSON.parse(requests[1].requestBody); + let auction = JSON.parse(server.requests[1].requestBody); expect(auction.data.adUnits).to.include.all.keys(noBidAdUnit, bidAfterTimeoutAdUnit); expect(auction.data.adUnits).to.not.include.all.keys(bidAdUnit); }); @@ -298,7 +286,6 @@ describe('Roxot Prebid Analytic', function () { describe('should correct parse config', function () { beforeEach(function () { - requests = []; sinon.stub(events, 'getEvents').returns([]); }); @@ -421,7 +408,7 @@ describe('Roxot Prebid Analytic', function () { options: publisherOptions }); - requests[0].respond(500); + server.requests[0].respond(500); expect(roxotAnalytic.getOptions().serverConfig).to.deep.equal({a: 1, i: 1, bat: 1, isError: 1}); }); diff --git a/test/spec/modules/rtbdemandBidAdapter_spec.js b/test/spec/modules/rtbdemandBidAdapter_spec.js index 25178c21d88..be9872ec01b 100644 --- a/test/spec/modules/rtbdemandBidAdapter_spec.js +++ b/test/spec/modules/rtbdemandBidAdapter_spec.js @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import { spec } from 'modules/rtbdemandBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; +import { spec } from 'modules/rtbdemandBidAdapter.js'; +import { newBidder } from 'src/adapters/bidderFactory.js'; describe('rtbdemandAdapter', function () { const adapter = newBidder(spec); @@ -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 c1fbd35d6c9..00000000000 --- 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 67845fa1983..93b9692d2e2 100644 --- a/test/spec/modules/rtbhouseBidAdapter_spec.js +++ b/test/spec/modules/rtbhouseBidAdapter_spec.js @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import { OPENRTB, spec } from 'modules/rtbhouseBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; +import { OPENRTB, spec } from 'modules/rtbhouseBidAdapter.js'; +import { newBidder } from 'src/adapters/bidderFactory.js'; describe('RTBHouseAdapter', () => { const adapter = newBidder(spec); @@ -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/rtbsolutionsBidAdapter_spec.js b/test/spec/modules/rtbsolutionsBidAdapter_spec.js new file mode 100644 index 00000000000..c47b086fe50 --- /dev/null +++ b/test/spec/modules/rtbsolutionsBidAdapter_spec.js @@ -0,0 +1,62 @@ +import { expect } from 'chai'; +import { spec } from 'modules/rtbsolutionsBidAdapter.js'; + +describe('rtbsolutionsBidAdapterTests', function () { + it('validate_pub_params_1', function () { + expect(spec.isBidRequestValid({ + bidder: 'rtbsolutions', + params: { + blockId: 777 + } + })).to.equal(true); + }); + it('validate_pub_params_2', function () { + expect(spec.isBidRequestValid({ + bidder: 'rtbsolutions', + params: { + s1: 'test' + } + })).to.equal(false); + }); + it('validate_generated_params', function () { + let bidderRequest = { + bids: [], + refererInfo: { + referer: '' + } + }; + bidderRequest.bids.push({ + bidId: 'bid1234', + bidder: 'rtbsolutions', + params: {blockId: 777}, + sizes: [[240, 400]] + }); + let request = spec.buildRequests(true, bidderRequest); + let req_data = request.data[0]; + expect(req_data.bid_id).to.equal('bid1234'); + }); + it('validate_response_params', function () { + let serverResponse = { + body: [{ + ad: 'Ad html', + bid_id: 'bid1234', + cpm: 1, + creative_id: 1, + height: 480, + nurl: 'http://test.test', + width: 640, + currency: 'USD', + }] + }; + let bids = spec.interpretResponse(serverResponse); + expect(bids).to.have.lengthOf(1); + let bid = bids[0]; + expect(bid.cpm).to.equal(1); + expect(bid.currency).to.equal('USD'); + expect(bid.width).to.equal(640); + expect(bid.height).to.equal(480); + expect(bid.netRevenue).to.equal(true); + expect(bid.requestId).to.equal('bid1234'); + expect(bid.ad).to.equal('Ad html'); + }); +}); diff --git a/test/spec/modules/rubiconAnalyticsAdapter_spec.js b/test/spec/modules/rubiconAnalyticsAdapter_spec.js index dd34245bd8e..9dc228ed288 100644 --- a/test/spec/modules/rubiconAnalyticsAdapter_spec.js +++ b/test/spec/modules/rubiconAnalyticsAdapter_spec.js @@ -1,11 +1,16 @@ -import rubiconAnalyticsAdapter, { SEND_TIMEOUT, parseBidResponse } from 'modules/rubiconAnalyticsAdapter'; +import rubiconAnalyticsAdapter, { + SEND_TIMEOUT, + parseBidResponse, + getHostNameFromReferer, +} from 'modules/rubiconAnalyticsAdapter.js'; import CONSTANTS from 'src/constants.json'; -import { config } from 'src/config'; +import { config } from 'src/config.js'; +import { server } from 'test/mocks/xhr.js'; import { setConfig, addBidResponseHook, -} from 'modules/currency'; +} from 'modules/currency.js'; let Ajv = require('ajv'); let schema = require('./rubiconAnalyticsSchema.json'); @@ -20,10 +25,9 @@ function validate(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'); +// using es6 "import * as events from 'src/events.js'" causes the events.getEvents stub not to work... +let events = require('src/events.js'); +let utils = require('src/utils.js'); const { EVENTS: { @@ -223,14 +227,16 @@ const MOCK = { '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 + 'start': 1519149562216, + 'refererInfo': { + 'referer': 'http://www.test.com/page.html', 'reachedTop': true, 'numIframes': 0, 'stack': ['http://www.test.com/page.html'] + } }, BID_RESPONSE: [ BID, @@ -271,6 +277,7 @@ const ANALYTICS_MESSAGE = { 'integration': 'pbjs', 'version': '$prebid.version$', 'referrerUri': 'http://www.test.com/page.html', + 'referrerHostname': 'www.test.com', 'auctions': [ { 'clientTimeoutMillis': 3000, @@ -473,24 +480,17 @@ function performStandardAuction() { 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); + rubiconAnalyticsAdapter.referrerHostname = ''; + config.setConfig({ s2sConfig: { timeout: 1000, @@ -553,7 +553,7 @@ describe('rubicon analytics adapter', function () { performStandardAuction(); - expect(requests.length).to.equal(1); + expect(server.requests.length).to.equal(1); }); it('should unsample', function () { @@ -567,7 +567,7 @@ describe('rubicon analytics adapter', function () { performStandardAuction(); - expect(requests.length).to.equal(0); + expect(server.requests.length).to.equal(0); }); it('should throw errors for invalid samplingFactor', function () { @@ -581,7 +581,7 @@ describe('rubicon analytics adapter', function () { performStandardAuction(); - expect(requests.length).to.equal(0); + expect(server.requests.length).to.equal(0); expect(utils.logError.called).to.equal(true); }); }); @@ -597,7 +597,7 @@ describe('rubicon analytics adapter', function () { performStandardAuction(); - expect(requests.length).to.equal(1); + expect(server.requests.length).to.equal(1); }); it('should unsample', function () { @@ -611,7 +611,7 @@ describe('rubicon analytics adapter', function () { performStandardAuction(); - expect(requests.length).to.equal(0); + expect(server.requests.length).to.equal(0); }); it('should throw errors for invalid samplingFactor', function () { @@ -625,7 +625,7 @@ describe('rubicon analytics adapter', function () { performStandardAuction(); - expect(requests.length).to.equal(0); + expect(server.requests.length).to.equal(0); expect(utils.logError.called).to.equal(true); }); }); @@ -648,8 +648,8 @@ describe('rubicon analytics adapter', function () { it('should build a batched message from prebid events', function () { performStandardAuction(); - expect(requests.length).to.equal(1); - let request = requests[0]; + expect(server.requests.length).to.equal(1); + let request = server.requests[0]; expect(request.url).to.equal('//localhost:9999/event'); @@ -659,6 +659,136 @@ describe('rubicon analytics adapter', function () { expect(message).to.deep.equal(ANALYTICS_MESSAGE); }); + it('should capture price floor information correctly', function () { + let auctionInit = utils.deepClone(MOCK.AUCTION_INIT); + auctionInit.bidderRequests[0].bids[0].floorData = { + skipped: false, + modelVersion: 'someModelName', + location: 'setConfig' + }; + let flooredResponse = { + ...BID, + floorData: { + floorValue: 4, + floorRule: '12345/sports|video', + floorCurrency: 'USD', + cpmAfterAdjustments: 2.1, + enforcements: { + enforceJS: true, + enforcePBS: false, + floorDeals: false, + bidAdjustment: true + }, + matchedFields: { + gptSlot: '12345/sports', + mediaType: 'video' + } + }, + status: 'bidRejected', + cpm: 0, + getStatusCode() { + return 2; + } + }; + + let notFlooredResponse = { + ...BID2, + floorData: { + floorValue: 1, + floorRule: '12345/news|banner', + floorCurrency: 'USD', + cpmAfterAdjustments: 1.55, + enforcements: { + enforceJS: true, + enforcePBS: false, + floorDeals: false, + bidAdjustment: true + }, + matchedFields: { + gptSlot: '12345/news', + mediaType: 'banner' + } + } + }; + + // spoof the auction with just our duplicates + events.emit(AUCTION_INIT, auctionInit); + events.emit(BID_REQUESTED, MOCK.BID_REQUESTED); + events.emit(BID_RESPONSE, flooredResponse); + events.emit(BID_RESPONSE, notFlooredResponse); + events.emit(AUCTION_END, MOCK.AUCTION_END); + events.emit(SET_TARGETING, MOCK.SET_TARGETING); + events.emit(BID_WON, MOCK.BID_WON[1]); + clock.tick(SEND_TIMEOUT + 1000); + + expect(server.requests.length).to.equal(1); + + let message = JSON.parse(server.requests[0].requestBody); + validate(message); + + // verify our floor stuff is passed + // top level floor info + expect(message.auctions[0].floors).to.deep.equal({ + location: 'setConfig', + modelName: 'someModelName', + skipped: false, + enforcement: true, + dealsEnforced: false + }); + // first adUnit's adSlot + expect(message.auctions[0].adUnits[0].adSlot).to.equal('12345/sports'); + // since no other bids, we set adUnit status to no-bid + expect(message.auctions[0].adUnits[0].status).to.equal('no-bid'); + // first adUnits bid is rejected + expect(message.auctions[0].adUnits[0].bids[0].status).to.equal('rejected'); + expect(message.auctions[0].adUnits[0].bids[0].bidResponse.floorValue).to.equal(4); + // if bid rejected should take cpmAfterAdjustments val + expect(message.auctions[0].adUnits[0].bids[0].bidResponse.bidPriceUSD).to.equal(2.1); + + // second adUnit's adSlot + expect(message.auctions[0].adUnits[1].adSlot).to.equal('12345/news'); + // top level adUnit status is success + expect(message.auctions[0].adUnits[1].status).to.equal('success'); + // second adUnits bid is success + expect(message.auctions[0].adUnits[1].bids[0].status).to.equal('success'); + expect(message.auctions[0].adUnits[1].bids[0].bidResponse.floorValue).to.equal(1); + expect(message.auctions[0].adUnits[1].bids[0].bidResponse.bidPriceUSD).to.equal(1.52); + }); + + it('should correctly overwrite bidId if seatBidId is on the bidResponse', 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 seatBidResponse = utils.deepClone(BID2); + seatBidResponse.seatBidId = 'abc-123-do-re-me'; + + const setTargeting = { + [seatBidResponse.adUnitCode]: seatBidResponse.adserverTargeting + }; + + const bidWon = Object.assign({}, seatBidResponse, { + 'status': 'rendered' + }); + + // spoof the auction with just our duplicates + events.emit(AUCTION_INIT, auctionInit); + events.emit(BID_REQUESTED, bidRequested); + events.emit(BID_RESPONSE, seatBidResponse); + events.emit(AUCTION_END, MOCK.AUCTION_END); + events.emit(SET_TARGETING, setTargeting); + events.emit(BID_WON, bidWon); + + let message = JSON.parse(server.requests[0].requestBody); + + validate(message); + expect(message.auctions[0].adUnits[0].bids[0].bidId).to.equal('abc-123-do-re-me'); + expect(message.bidsWon[0].bidId).to.equal('abc-123-do-re-me'); + }); + 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); @@ -698,7 +828,7 @@ describe('rubicon analytics adapter', function () { events.emit(SET_TARGETING, setTargeting); events.emit(BID_WON, bidWon); - let message = JSON.parse(requests[0].requestBody); + let message = JSON.parse(server.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'); @@ -723,15 +853,15 @@ describe('rubicon analytics adapter', function () { events.emit(BID_WON, MOCK.BID_WON[1]); - expect(requests.length).to.equal(2); + expect(server.requests.length).to.equal(2); - let message = JSON.parse(requests[0].requestBody); + let message = JSON.parse(server.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); + message = JSON.parse(server.requests[1].requestBody); validate(message); expect(message.bidsWon.length).to.equal(1); expect(message).to.not.have.property('auctions'); @@ -746,9 +876,9 @@ describe('rubicon analytics adapter', function () { clock.tick(SEND_TIMEOUT + 1000); - expect(requests.length).to.equal(1); + expect(server.requests.length).to.equal(1); - let message = JSON.parse(requests[0].requestBody); + let message = JSON.parse(server.requests[0].requestBody); validate(message); let timedOutBid = message.auctions[0].adUnits[0].bids[0]; expect(timedOutBid.status).to.equal('error'); @@ -803,12 +933,27 @@ describe('rubicon analytics adapter', function () { performStandardAuction(); - expect(requests.length).to.equal(1); - const request = requests[0]; + expect(server.requests.length).to.equal(1); + const request = server.requests[0]; const message = JSON.parse(request.requestBody); expect(message.integration).to.equal('testType'); rubiconAnalyticsAdapter.disableAnalytics(); }); }); + + it('getHostNameFromReferer correctly grabs hostname from an input URL', function () { + let inputUrl = 'https://www.prebid.org/some/path?pbjs_debug=true'; + expect(getHostNameFromReferer(inputUrl)).to.equal('www.prebid.org'); + inputUrl = 'https://www.prebid.com/some/path?pbjs_debug=true'; + expect(getHostNameFromReferer(inputUrl)).to.equal('www.prebid.com'); + inputUrl = 'https://prebid.org/some/path?pbjs_debug=true'; + expect(getHostNameFromReferer(inputUrl)).to.equal('prebid.org'); + inputUrl = 'http://xn--p8j9a0d9c9a.xn--q9jyb4c/'; + expect(typeof getHostNameFromReferer(inputUrl)).to.equal('string'); + + // not non-UTF char's in query / path which break if noDecodeWholeURL not set + inputUrl = 'https://prebid.org/search_results/%95x%8Em%92%CA/?category=000'; + expect(getHostNameFromReferer(inputUrl)).to.equal('prebid.org'); + }); }); diff --git a/test/spec/modules/rubiconAnalyticsSchema.json b/test/spec/modules/rubiconAnalyticsSchema.json index 686aced840f..16cca629d8c 100644 --- a/test/spec/modules/rubiconAnalyticsSchema.json +++ b/test/spec/modules/rubiconAnalyticsSchema.json @@ -292,7 +292,8 @@ "enum": [ "success", "no-bid", - "error" + "error", + "rejected" ] }, "error": { diff --git a/test/spec/modules/rubiconBidAdapter_spec.js b/test/spec/modules/rubiconBidAdapter_spec.js index c6941584652..29cc6cb2c0a 100644 --- a/test/spec/modules/rubiconBidAdapter_spec.js +++ b/test/spec/modules/rubiconBidAdapter_spec.js @@ -1,12 +1,12 @@ import {expect} from 'chai'; -import adapterManager from 'src/adapterManager'; -import {spec, getPriceGranularity, masSizeOrdering, resetUserSync, hasVideoMediaType, FASTLANE_ENDPOINT} from 'modules/rubiconBidAdapter'; +import adapterManager from 'src/adapterManager.js'; +import {spec, getPriceGranularity, masSizeOrdering, resetUserSync, hasVideoMediaType, FASTLANE_ENDPOINT} from 'modules/rubiconBidAdapter.js'; import {parse as parseQuery} from 'querystring'; -import {newBidder} from 'src/adapters/bidderFactory'; -import {userSync} from 'src/userSync'; -import {config} from 'src/config'; -import * as utils from 'src/utils'; -import find from 'core-js/library/fn/array/find'; +import {newBidder} from 'src/adapters/bidderFactory.js'; +import {userSync} from 'src/userSync.js'; +import {config} from 'src/config.js'; +import * as utils from 'src/utils.js'; +import find from 'core-js/library/fn/array/find.js'; var CONSTANTS = require('src/constants.json'); @@ -15,7 +15,8 @@ const INTEGRATION = `pbjs_lite_v$prebid.version$`; // $prebid.version$ will be s describe('the rubicon adapter', function () { let sandbox, bidderRequest, - sizeMap; + sizeMap, + getFloorResponse; /** * @typedef {Object} sizeMapConverted @@ -224,8 +225,10 @@ describe('the rubicon adapter', function () { lipb: { lipbid: '0000-1111-2222-3333', segments: ['segA', 'segB'] - } - } + }, + idl_env: '1111-2222-3333-4444' + }; + bid.storedAuctionResponse = 11111; } function createVideoBidderRequestNoVideo() { @@ -272,7 +275,7 @@ describe('the rubicon adapter', function () { beforeEach(function () { sandbox = sinon.sandbox.create(); - + getFloorResponse = {}; bidderRequest = { bidderCode: 'rubicon', auctionId: 'c45dd708-a418-42ec-b8a7-b70a6c6fab0a', @@ -409,6 +412,43 @@ describe('the rubicon adapter', function () { }); }); + it('should correctly send hard floors when getFloor function is present and returns valid floor', function () { + // default getFloor response is empty object so should not break and not send hard_floor + bidderRequest.bids[0].getFloor = () => getFloorResponse; + let [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); + let data = parseQuery(request.data); + expect(data.rp_hard_floor).to.be.undefined; + + // not an object should work and not send + getFloorResponse = undefined; + [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); + data = parseQuery(request.data); + expect(data.rp_hard_floor).to.be.undefined; + + // make it respond with a non USD floor should not send it + getFloorResponse = {currency: 'EUR', floor: 1.0}; + [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); + data = parseQuery(request.data); + expect(data.rp_hard_floor).to.be.undefined; + + // make it respond with a non USD floor should not send it + getFloorResponse = {currency: 'EUR'}; + [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); + data = parseQuery(request.data); + expect(data.rp_hard_floor).to.be.undefined; + + // make it respond with USD floor and string floor + getFloorResponse = {currency: 'USD', floor: '1.23'}; + [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); + data = parseQuery(request.data); + expect(data.rp_hard_floor).to.equal('1.23'); + + // make it respond with USD floor and num floor + getFloorResponse = {currency: 'USD', floor: 1.23}; + [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); + data = parseQuery(request.data); + expect(data.rp_hard_floor).to.equal('1.23'); + }); it('should not send p_pos to AE if not params.position specified', function() { var noposRequest = utils.deepClone(bidderRequest); delete noposRequest.bids[0].params.position; @@ -550,12 +590,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 +604,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 +612,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); @@ -979,6 +1019,51 @@ describe('the rubicon adapter', function () { expect(data[key]).to.equal(value); }); }); + + it('should use first party data from getConfig over the bid params, if present', () => { + const context = { + keywords: ['e', 'f'], + rating: '4-star' + }; + const user = { + keywords: ['d'], + gender: 'M', + yob: '1984', + geo: { country: 'ca' } + }; + + sandbox.stub(config, 'getConfig').callsFake(key => { + const config = { + fpd: { + context, + user + } + }; + return utils.deepAccess(config, key); + }); + + const expectedQuery = { + 'kw': 'a,b,c,d,e,f', + 'tg_v.ucat': 'new', + 'tg_v.lastsearch': 'iphone', + 'tg_v.likes': 'sports,video games', + 'tg_v.gender': 'M', + 'tg_v.yob': '1984', + 'tg_v.geo': '{"country":"ca"}', + 'tg_i.rating': '4-star', + 'tg_i.prodtype': 'tech,mobile', + }; + + // get the built request + let [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); + let data = parseQuery(request.data); + + // make sure that tg_v, tg_i, and kw values are correct + Object.keys(expectedQuery).forEach(key => { + let value = expectedQuery[key]; + expect(data[key]).to.deep.equal(value); + }); + }); }); describe('singleRequest config', function () { @@ -1259,7 +1344,91 @@ describe('the rubicon adapter', function () { expect(unescapedData.indexOf('&tg_v.LIseg=segD,segE&') !== -1).to.equal(true); }); }); + + describe('LiveRamp support', function () { + it('should send tpid_liveramp.com when userId defines idl_env', function () { + const clonedBid = utils.deepClone(bidderRequest.bids[0]); + clonedBid.userId = { + idl_env: '1111-2222-3333-4444' + }; + let [request] = spec.buildRequests([clonedBid], bidderRequest); + let data = parseQuery(request.data); + + expect(data['tpid_liveramp.com']).to.equal('1111-2222-3333-4444'); + }); + }); }) + + describe('Prebid AdSlot', function () { + beforeEach(function () { + // enforce that the bid at 0 does not have a 'context' property + if (bidderRequest.bids[0].hasOwnProperty('fpd')) { + delete bidderRequest.bids[0].fpd; + } + }); + + it('should not send \"tg_i.dfp_ad_unit_code\" if \"fpd.context\" object is not valid', function () { + const [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); + const data = parseQuery(request.data); + + expect(data).to.be.an('Object'); + expect(data).to.not.have.property('tg_i.dfp_ad_unit_code'); + }); + + it('should not send \"tg_i.dfp_ad_unit_code\" if \"fpd.context.pbAdSlot\" is undefined', function () { + bidderRequest.bids[0].fpd = {}; + + const [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); + const data = parseQuery(request.data); + + expect(data).to.be.an('Object'); + expect(data).to.not.have.property('tg_i.dfp_ad_unit_code'); + }); + + it('should not send \"tg_i.dfp_ad_unit_code\" if \"fpd.context.pbAdSlot\" value is an empty string', function () { + bidderRequest.bids[0].fpd = { + context: { + pbAdSlot: '' + } + }; + + const [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); + const data = parseQuery(request.data); + + expect(data).to.be.an('Object'); + expect(data).to.not.have.property('tg_i.dfp_ad_unit_code'); + }); + + it('should send \"tg_i.dfp_ad_unit_code\" if \"fpd.context.pbAdSlot\" value is a valid string', function () { + bidderRequest.bids[0].fpd = { + context: { + pbAdSlot: 'abc' + } + } + + const [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); + const data = parseQuery(request.data); + + expect(data).to.be.an('Object'); + expect(data).to.have.property('tg_i.dfp_ad_unit_code'); + expect(data['tg_i.dfp_ad_unit_code']).to.equal('abc'); + }); + + it('should send \"tg_i.dfp_ad_unit_code\" if \"fpd.context.pbAdSlot\" value is a valid string, but all leading slash characters should be removed', function () { + bidderRequest.bids[0].fpd = { + context: { + pbAdSlot: '/a/b/c' + } + }; + + const [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); + const data = parseQuery(request.data); + + expect(data).to.be.an('Object'); + expect(data).to.have.property('tg_i.dfp_ad_unit_code'); + expect(data['tg_i.dfp_ad_unit_code']).to.equal('a/b/c'); + }); + }); }); describe('for video requests', function () { @@ -1301,6 +1470,9 @@ describe('the rubicon adapter', function () { expect(post.user.ext.tpid).that.is.an('object'); expect(post.user.ext.tpid.source).to.equal('liveintent.com'); expect(post.user.ext.tpid.uid).to.equal('0000-1111-2222-3333'); + // LiveRamp should exist + expect(post.user.ext.eids[1].source).to.equal('liveramp.com'); + expect(post.user.ext.eids[1].uids[0].id).to.equal('1111-2222-3333-4444'); expect(post.rp).that.is.an('object'); expect(post.rp.target).that.is.an('object'); expect(post.rp.target.LIseg).that.is.an('array'); @@ -1316,6 +1488,39 @@ describe('the rubicon adapter', function () { expect(post.ext.prebid.cache.vastxml.returnCreative).to.equal(false) }); + it('should correctly set bidfloor on imp when getfloor in scope', function () { + createVideoBidderRequest(); + // default getFloor response is empty object so should not break and not send hard_floor + bidderRequest.bids[0].getFloor = () => getFloorResponse; + sandbox.stub(Date, 'now').callsFake(() => + bidderRequest.auctionStart + 100 + ); + + let [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); + + // not an object should work and not send + expect(request.data.imp[0].bidfloor).to.be.undefined; + + // make it respond with a non USD floor should not send it + getFloorResponse = {currency: 'EUR', floor: 1.0}; + [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); + expect(request.data.imp[0].bidfloor).to.be.undefined; + + // make it respond with a non USD floor should not send it + getFloorResponse = {currency: 'EUR'}; + [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); + expect(request.data.imp[0].bidfloor).to.be.undefined; + + // make it respond with USD floor and string floor + getFloorResponse = {currency: 'USD', floor: '1.23'}; + [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); + expect(request.data.imp[0].bidfloor).to.equal(1.23); + + // make it respond with USD floor and num floor + getFloorResponse = {currency: 'USD', floor: 1.23}; + [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); + expect(request.data.imp[0].bidfloor).to.equal(1.23); + }); it('should add alias name to PBS Request', function() { createVideoBidderRequest(); @@ -1568,6 +1773,92 @@ describe('the rubicon adapter', function () { const [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); expect(request.data.regs.coppa).to.equal(1); }); + + it('should include first party data', () => { + createVideoBidderRequest(); + + const context = { + keywords: ['e', 'f'], + rating: '4-star' + }; + const user = { + keywords: ['d'], + gender: 'M', + yob: '1984', + geo: { country: 'ca' } + }; + + sandbox.stub(config, 'getConfig').callsFake(key => { + const config = { + fpd: { + context, + user + } + }; + return utils.deepAccess(config, key); + }); + + const expected = [{ + bidders: [ 'rubicon' ], + config: { + fpd: { + site: Object.assign({}, bidderRequest.bids[0].params.inventory, context), + user: Object.assign({}, bidderRequest.bids[0].params.visitor, user) + } + } + }]; + + const [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); + expect(request.data.ext.prebid.bidderconfig).to.deep.equal(expected); + }); + + it('should include storedAuctionResponse in video bid request', function () { + createVideoBidderRequest(); + + sandbox.stub(Date, 'now').callsFake(() => + bidderRequest.auctionStart + 100 + ); + + const [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); + expect(request.data.imp).to.exist.and.to.be.a('array'); + expect(request.data.imp).to.have.lengthOf(1); + expect(request.data.imp[0].ext).to.exist.and.to.be.a('object'); + expect(request.data.imp[0].ext.prebid).to.exist.and.to.be.a('object'); + expect(request.data.imp[0].ext.prebid.storedauctionresponse).to.exist.and.to.be.a('object'); + expect(request.data.imp[0].ext.prebid.storedauctionresponse.id).to.equal('11111'); + }); + + it('should include pbAdSlot in bid request', function () { + createVideoBidderRequest(); + bidderRequest.bids[0].fpd = { + context: { + pbAdSlot: '1234567890' + } + }; + + sandbox.stub(Date, 'now').callsFake(() => + bidderRequest.auctionStart + 100 + ); + + const [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); + expect(request.data.imp[0].ext.context.data.adslot).to.equal('1234567890'); + }); + }); + + it('should include pbAdSlot in bid request', function () { + createVideoBidderRequest(); + bidderRequest.bids[0].fpd = { + context: { + pbAdSlot: '1234567890' + } + }; + + sandbox.stub(Date, 'now').callsFake(() => + bidderRequest.auctionStart + 100 + ); + + const [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); + expect(request.data.imp[0].ext.context.data.adslot).to.equal('1234567890'); }); describe('combineSlotUrlParams', function () { @@ -1633,6 +1924,12 @@ describe('the rubicon adapter', function () { } }); }); + + it('should not fail if keywords param is not an array', function () { + bidderRequest.bids[0].params.keywords = 'a,b,c'; + const slotParams = spec.createSlotParams(bidderRequest.bids[0], bidderRequest); + expect(slotParams.kw).to.equal(''); + }); }); describe('hasVideoMediaType', function () { @@ -2455,7 +2752,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/s2sTesting_spec.js b/test/spec/modules/s2sTesting_spec.js index 52377dcabf2..5c7f3004dee 100644 --- a/test/spec/modules/s2sTesting_spec.js +++ b/test/spec/modules/s2sTesting_spec.js @@ -1,5 +1,5 @@ -import s2sTesting from 'modules/s2sTesting'; -import { config } from 'src/config'; +import s2sTesting from 'modules/s2sTesting.js'; +import { config } from 'src/config.js'; var expect = require('chai').expect; diff --git a/test/spec/modules/saraBidAdapter_spec.js b/test/spec/modules/saraBidAdapter_spec.js deleted file mode 100644 index 6614ec65265..00000000000 --- 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/scaleableAnalyticsAdapter_spec.js b/test/spec/modules/scaleableAnalyticsAdapter_spec.js index 300f72751a4..70b94a2b807 100644 --- a/test/spec/modules/scaleableAnalyticsAdapter_spec.js +++ b/test/spec/modules/scaleableAnalyticsAdapter_spec.js @@ -1,24 +1,49 @@ -import scaleableAnalytics from 'modules/scaleableAnalyticsAdapter'; +import scaleableAnalytics from 'modules/scaleableAnalyticsAdapter.js'; import { expect } from 'chai'; -import events from 'src/events'; +import events from 'src/events.js'; import CONSTANTS from 'src/constants.json'; -import adapterManager from 'src/adapterManager'; +import { server } from 'test/mocks/xhr.js'; const BID_TIMEOUT = CONSTANTS.EVENTS.BID_TIMEOUT; const AUCTION_INIT = CONSTANTS.EVENTS.AUCTION_INIT; -const BID_RESPONSE = CONSTANTS.EVENTS.BID_RESPONSE; const BID_WON = CONSTANTS.EVENTS.BID_WON; const AUCTION_END = CONSTANTS.EVENTS.AUCTION_END; describe('Scaleable Analytics Adapter', function() { + const bidsReceivedObj = { + adUnitCode: '12345', + bidderCode: 'test-code', + cpm: 3.14, + currency: 'USD', + dealId: null, + mediaType: 'banner', + timeToRespond: 285, + size: '300x250' + }; + const MOCK_DATA = { adUnitCode: '12345', + auctionEnd: { + bidsReceived: [bidsReceivedObj] + }, + bidderRequests: [{ + bids: [{ + adUnitCode: '12345', + bidder: 'test-code', + params: { + test: 'value' + } + }] + }], site: '5c4fab7a829e955d6c265e72', bidResponse: { adUnitCode: '12345', bidderCode: 'test-code', cpm: 3.14, - timeToRespond: 285 + timeToRespond: 285, + params: [{ + test: 'value' + }] }, bidTimeout: [ { @@ -28,40 +53,54 @@ describe('Scaleable Analytics Adapter', function() { ] }; - MOCK_DATA.expectedBidResponse = { - event: 'bids', - bids: [{ - code: MOCK_DATA.bidResponse.bidderCode, - cpm: MOCK_DATA.bidResponse.cpm, - ttr: MOCK_DATA.bidResponse.timeToRespond - }], - adunit: MOCK_DATA.adUnitCode, - site: MOCK_DATA.site - }; + const bidObj = MOCK_DATA.bidderRequests[0].bids[0]; - MOCK_DATA.expectedBidTimeout = { - event: 'bids', - bids: [], - timeouts: [MOCK_DATA.bidTimeout[0].bidder], - adunit: MOCK_DATA.bidTimeout[0].adUnitCode, - site: MOCK_DATA.site - }; + const expectedBidRequests = [{bidder: 'scaleable_adunit_request'}].concat([ + { + bidder: bidObj.bidder, + params: bidObj.params + } + ]); - let xhr; - let requests; + MOCK_DATA.expectedRequestResponse = { + event: 'request', + site: MOCK_DATA.site, + adunits: [{ + code: bidObj.adUnitCode, + bidRequests: expectedBidRequests + }] + } - before(function() { - xhr = sinon.useFakeXMLHttpRequest(); - xhr.onCreate = request => requests.push(request); - }); + MOCK_DATA.expectedBidTimeout = { + [MOCK_DATA.bidTimeout[0].adUnitCode]: [{ + timeouts: 1, + bidder: MOCK_DATA.bidTimeout[0].bidder + }] + }; - after(function() { - xhr.restore(); - }); + MOCK_DATA.expectedAuctionEndResponse = { + event: 'bids', + site: MOCK_DATA.site, + adunits: [{ + code: MOCK_DATA.auctionEnd.bidsReceived[0].adUnitCode, + bidData: [{ + bidder: bidsReceivedObj.bidderCode, + cpm: bidsReceivedObj.cpm, + currency: bidsReceivedObj.currency, + dealId: bidsReceivedObj.dealId, + type: bidsReceivedObj.mediaType, + ttr: bidsReceivedObj.timeToRespond, + size: bidsReceivedObj.size + }] + }, + { + bidData: MOCK_DATA.expectedBidTimeout[MOCK_DATA.bidTimeout[0].adUnitCode], + code: MOCK_DATA.bidTimeout[0].adUnitCode + }] + } describe('Event Handling', function() { beforeEach(function() { - requests = []; sinon.stub(events, 'getEvents').returns([]); scaleableAnalytics.enableAnalytics({ @@ -79,44 +118,34 @@ describe('Scaleable Analytics Adapter', function() { it('should handle the auction init event', function(done) { events.emit(AUCTION_INIT, { - adUnitCodes: [MOCK_DATA.adUnitCode] + adUnitCodes: [MOCK_DATA.adUnitCode], + bidderRequests: MOCK_DATA.bidderRequests }); - const result = JSON.parse(requests[0].requestBody); - expect(result).to.deep.equal({ - event: 'request', - site: MOCK_DATA.site, - adunit: MOCK_DATA.adUnitCode - }); + const result = JSON.parse(server.requests[0].requestBody); + expect(result).to.deep.equal(MOCK_DATA.expectedRequestResponse); done(); }); - it('should handle the bid response event', function() { - events.emit(BID_RESPONSE, MOCK_DATA.bidResponse); - - const actual = scaleableAnalytics.getAuctionData(); - - expect(actual[MOCK_DATA.adUnitCode]).to.deep.equal(MOCK_DATA.expectedBidResponse); - }); - it('should handle the bid timeout event', function() { events.emit(BID_TIMEOUT, MOCK_DATA.bidTimeout); const actual = scaleableAnalytics.getAuctionData(); - expect(actual[MOCK_DATA.bidTimeout[0].adUnitCode]).to.deep.equal(MOCK_DATA.expectedBidTimeout); + expect(actual).to.deep.equal(MOCK_DATA.expectedBidTimeout); }); it('should handle the bid won event', function(done) { events.emit(BID_WON, MOCK_DATA.bidResponse); - const result = JSON.parse(requests[0].requestBody); + const result = JSON.parse(server.requests[0].requestBody); expect(result).to.deep.equal({ adunit: MOCK_DATA.adUnitCode, code: MOCK_DATA.bidResponse.bidderCode, cpm: MOCK_DATA.bidResponse.cpm, ttr: MOCK_DATA.bidResponse.timeToRespond, + params: MOCK_DATA.bidResponse.params, event: 'win', site: MOCK_DATA.site }); @@ -125,10 +154,10 @@ describe('Scaleable Analytics Adapter', function() { }); it('should handle the auction end event', function(done) { - events.emit(AUCTION_END, {}); + events.emit(AUCTION_END, MOCK_DATA.auctionEnd); - const result = JSON.parse(requests[0].requestBody); - expect(result).to.deep.equal(MOCK_DATA.expectedBidResponse); + const result = JSON.parse(server.requests[0].requestBody); + expect(result).to.deep.equal(MOCK_DATA.expectedAuctionEndResponse); done(); }); diff --git a/test/spec/modules/schain_spec.js b/test/spec/modules/schain_spec.js index 8f5104f1822..34d0cff9a60 100644 --- a/test/spec/modules/schain_spec.js +++ b/test/spec/modules/schain_spec.js @@ -1,4 +1,6 @@ -import {isValidSchainConfig, isSchainObjectValid, copySchainObjectInAdunits} from '../../../modules/schain'; +import { isValidSchainConfig, isSchainObjectValid, makeBidRequestsHook } from '../../../modules/schain.js'; +import { deepClone } from '../../../src/utils.js'; +import {config} from '../../../src/config.js'; import { expect } from 'chai'; describe('#isValidSchainConfig: module config validation', function() { @@ -245,42 +247,241 @@ describe('#isSchainObjectValid: schain object validation', function() { }) }); -describe('Passing schain object to adUnits', function() { - let schainConfig; - - beforeEach(function() { - schainConfig = { - 'ver': '1.0', - 'complete': 1, - 'nodes': [ +describe('#makeBidRequestsHook', function() { + const bidderRequests = [ + { + 'bidderCode': 'rubicon', + 'bids': [ { - 'asi': 'indirectseller.com', - 'sid': '00001', - 'hp': 1 - }, + 'bidder': 'rubicon', + 'params': { + 'accountId': 14062, + 'siteId': 70608, + 'zoneId': 498816 + }, + 'mediaTypes': { + 'banner': { + 'sizes': [[300, 250], [300, 600]] + } + }, + 'adUnitCode': 'div-gpt-ad-1460505748561-0', + 'sizes': [[300, 250], [300, 600]], + 'bidId': '2e6d166eb869c3' + } + ], + }, + { + 'bidderCode': 'districtm', + 'bids': [ { - 'asi': 'indirectseller-2.com', - 'sid': '00002', - 'hp': 2 + 'bidder': 'districtm', + 'params': { + 'placementId': 13144370 + }, + 'mediaTypes': { + 'banner': { + 'sizes': [[300, 250], [300, 600]] + } + }, + 'adUnitCode': 'div-gpt-ad-1460505748561-0', + 'sizes': [[300, 250], [300, 600]], + 'bidId': '41cdeddf7b6905' } - ] - }; + ], + }, + { + 'bidderCode': 'appnexus', + 'bids': [ + { + 'bidder': 'appnexus', + 'params': { + 'placementId': 13144370 + }, + 'mediaTypes': { + 'banner': { + 'sizes': [[300, 250], [300, 600]] + } + }, + 'adUnitCode': 'div-gpt-ad-1460505748561-0', + 'sizes': [[300, 250], [300, 600]], + 'bidId': '626cc7f1c4ccfc' + } + ], + + } + ]; + + const globalSchainConfig = { + 'schain': { + 'validation': 'off', + 'config': { + 'ver': '1.0', + 'complete': 1, + 'nodes': [ + { + 'asi': 'indirectseller.com', + 'sid': '00001', + 'hp': 1 + }, + + { + 'asi': 'indirectseller-2.com', + 'sid': '00002', + 'hp': 1 + } + ] + } + } + }; + + const goodStrictBidderConfig = { + bidders: ['appnexus'], + config: { + 'schain': { + 'validation': 'strict', + 'config': { + 'ver': '1.0', + 'complete': 1, + 'nodes': [ + { + 'asi': 'myoverride1.com', + 'sid': '00001', + 'hp': 1, + 'name': 'node1' + }, + { + 'asi': 'myoverride2.com', + 'sid': '00001', + 'hp': 1, + 'name': 'node2' + } + ] + } + } + } + } + + const badStrictBidderConfig = { + bidders: ['appnexus'], + config: { + 'schain': { + 'validation': 'strict', + 'config': { + 'ver': '1.0', + 'complete': 1, + 'nodes': [ + { + 'asi': 'myoverride1.com', + 'sid': 1, + 'hp': 1, + 'name': 342 + }, + { + 'asi': 'myoverride2.com', + 'sid': 2, + 'hp': 1, + 'name': '342' + } + ] + } + } + } + }; + + const goodRelaxedBidderConfig = { + bidders: ['districtm'], + config: { + 'schain': { + 'validation': 'relaxed', + 'config': { + 'ver': '1.0', + 'complete': 1, + 'nodes': [ + { + 'asi': 'myoverride.com', + 'sid': '00001', + 'hp': 1, + 'name': 'goodConfig' + } + ] + } + } + } + }; + + const badRelaxedBidderConfig = { + bidders: ['districtm'], + config: { + 'schain': { + 'validation': 'relaxed', + 'config': { + 'ver': 1, + 'complete': 1, + 'nodes': [ + { + 'asi': 'myoverride.com', + 'sid': 1, + 'hp': 1 + } + ] + } + } + } + }; + + beforeEach(function () { + config.setConfig(globalSchainConfig); }); - it('schain object should be applied to all adUnits', function() { - let adUnits = [ - { - bids: [{}, {}] - }, - { - bids: [{}, {}] + afterEach(function () { + config.resetConfig(); + + config.setBidderConfig({ + bidders: ['districtm'], + config: { + schain: null + } + }); + + config.setBidderConfig({ + bidders: ['appnexus'], + config: { + schain: null } - ]; - copySchainObjectInAdunits(adUnits, schainConfig); - expect(adUnits[0].bids[0].schain).to.equal(schainConfig); - expect(adUnits[0].bids[1].schain).to.equal(schainConfig); - expect(adUnits[1].bids[0].schain).to.equal(schainConfig); - expect(adUnits[1].bids[1].schain).to.equal(schainConfig); + }); + }); + + it('should properly read from bidder schain + global schain configs', function() { + function testCallback(bidderRequests) { + expect(bidderRequests[0].bids[0].schain).to.exist; + expect(bidderRequests[0].bids[0].schain).to.deep.equal(globalSchainConfig.schain.config); + expect(bidderRequests[1].bids[0].schain).to.exist; + expect(bidderRequests[1].bids[0].schain).to.deep.equal(goodRelaxedBidderConfig.config.schain.config); + expect(bidderRequests[2].bids[0].schain).to.exist; + expect(bidderRequests[2].bids[0].schain).to.deep.equal(goodStrictBidderConfig.config.schain.config); + } + + const testBidderRequests = deepClone(bidderRequests); + config.setBidderConfig(goodStrictBidderConfig); + config.setBidderConfig(goodRelaxedBidderConfig); + + makeBidRequestsHook(testCallback, testBidderRequests); + }); + + it('should reject bad strict config but allow a bad relaxed config for bidders trying to override it', function () { + function testCallback(bidderRequests) { + expect(bidderRequests[0].bids[0].schain).to.exist; + expect(bidderRequests[0].bids[0].schain).to.deep.equal(globalSchainConfig.schain.config); + expect(bidderRequests[1].bids[0].schain).to.exist; + expect(bidderRequests[1].bids[0].schain).to.deep.equal(badRelaxedBidderConfig.config.schain.config); + expect(bidderRequests[2].bids[0].schain).to.be.undefined; + } + + const testBidderRequests = deepClone(bidderRequests); + config.setBidderConfig(badStrictBidderConfig); + config.setBidderConfig(badRelaxedBidderConfig); + + makeBidRequestsHook(testCallback, testBidderRequests); }); }); diff --git a/test/spec/modules/seedingAllianceAdapter_spec.js b/test/spec/modules/seedingAllianceAdapter_spec.js new file mode 100755 index 00000000000..e6f96c92fd9 --- /dev/null +++ b/test/spec/modules/seedingAllianceAdapter_spec.js @@ -0,0 +1,186 @@ +// jshint esversion: 6, es3: false, node: true +import {assert, expect} from 'chai'; +import {spec} from 'modules/seedingAllianceBidAdapter.js'; +import { NATIVE } from 'src/mediaTypes.js'; +import { config } from 'src/config.js'; + +describe('SeedingAlliance adapter', function () { + let serverResponse, bidRequest, bidResponses; + let bid = { + 'bidder': 'seedingAlliance', + 'params': { + 'adUnitId': '1hq8' + } + }; + + describe('isBidRequestValid', function () { + it('should return true when required params found', function () { + assert(spec.isBidRequestValid(bid)); + }); + + it('should return false when AdUnitId is not set', function () { + delete bid.params.adUnitId; + assert.isFalse(spec.isBidRequestValid(bid)); + }); + }); + + describe('buildRequests', function () { + it('should send request with correct structure', function () { + let validBidRequests = [{ + bidId: 'bidId', + params: {} + }]; + + let request = spec.buildRequests(validBidRequests, { refererInfo: { referer: 'page' } }); + + assert.equal(request.method, 'POST'); + assert.ok(request.data); + }); + + it('should have default request structure', function () { + let keys = 'site,device,cur,imp,user'.split(','); + let validBidRequests = [{ + bidId: 'bidId', + params: {} + }]; + let request = JSON.parse(spec.buildRequests(validBidRequests, { refererInfo: { referer: 'page' } }).data); + let data = Object.keys(request); + + assert.deepEqual(keys, data); + }); + + it('Verify the auction ID', function () { + let validBidRequests = [{ + bidId: 'bidId', + params: {}, + auctionId: 'auctionId' + }]; + let request = JSON.parse(spec.buildRequests(validBidRequests, { refererInfo: { referer: 'page' }, auctionId: validBidRequests[0].auctionId }).data); + + assert.equal(request.id, validBidRequests[0].auctionId); + }); + + it('Verify the device', function () { + let validBidRequests = [{ + bidId: 'bidId', + params: {} + }]; + let request = JSON.parse(spec.buildRequests(validBidRequests, { refererInfo: { referer: 'page' } }).data); + + assert.equal(request.device.ua, navigator.userAgent); + }); + + it('Verify native asset ids', function () { + let validBidRequests = [{ + bidId: 'bidId', + params: {}, + nativeParams: { + body: { + required: true, + len: 350 + }, + image: { + required: true + }, + title: { + required: true + }, + sponsoredBy: { + required: true + }, + cta: { + required: true + }, + icon: { + required: true + } + } + }]; + + let assets = JSON.parse(spec.buildRequests(validBidRequests, { refererInfo: { referer: 'page' } }).data).imp[0].native.request.assets; + + assert.equal(assets[0].id, 1); + assert.equal(assets[1].id, 3); + assert.equal(assets[2].id, 0); + assert.equal(assets[3].id, 2); + assert.equal(assets[4].id, 4); + assert.equal(assets[5].id, 5); + }); + }); + + describe('interpretResponse', function () { + const goodResponse = { + body: { + cur: 'EUR', + id: '4b516b80-886e-4ec0-82ae-9209e6d625fb', + seatbid: [ + { + seat: 'seedingAlliance', + bid: [{ + adm: { + native: { + assets: [ + {id: 0, title: {text: 'this is a title'}} + ], + imptrackers: ['https://domain.for/imp/tracker?price=${AUCTION_PRICE}'], + link: { + clicktrackers: ['https://domain.for/imp/tracker?price=${AUCTION_PRICE}'], + url: 'https://domain.for/ad/' + } + } + }, + impid: 1, + price: 0.55 + }] + } + ] + } + }; + const badResponse = { body: { + cur: 'EUR', + id: '4b516b80-886e-4ec0-82ae-9209e6d625fb', + seatbid: [] + }}; + + const bidRequest = { + data: {}, + bids: [{ bidId: 'bidId1' }] + }; + + it('should return null if body is missing or empty', function () { + const result = spec.interpretResponse(badResponse, bidRequest); + assert.equal(result.length, 0); + + delete badResponse.body + + const result1 = spec.interpretResponse(badResponse, bidRequest); + assert.equal(result.length, 0); + }); + + it('should return the correct params', function () { + const result = spec.interpretResponse(goodResponse, bidRequest); + const bid = goodResponse.body.seatbid[0].bid[0]; + + assert.deepEqual(result[0].currency, goodResponse.body.cur); + assert.deepEqual(result[0].requestId, bidRequest.bids[0].bidId); + assert.deepEqual(result[0].cpm, bid.price); + assert.deepEqual(result[0].creativeId, bid.crid); + assert.deepEqual(result[0].mediaType, 'native'); + assert.deepEqual(result[0].bidderCode, 'seedingAlliance'); + }); + + it('should return the correct tracking links', function () { + const result = spec.interpretResponse(goodResponse, bidRequest); + const bid = goodResponse.body.seatbid[0].bid[0]; + const regExpPrice = new RegExp('price=' + bid.price); + + result[0].native.clickTrackers.forEach(function (clickTracker) { + assert.ok(clickTracker.search(regExpPrice) > -1); + }); + + result[0].native.impressionTrackers.forEach(function (impTracker) { + assert.ok(impTracker.search(regExpPrice) > -1); + }); + }); + }); +}); diff --git a/test/spec/modules/seedtagBidAdapter_spec.js b/test/spec/modules/seedtagBidAdapter_spec.js index 4bd4b599c55..5c8c58196f7 100644 --- a/test/spec/modules/seedtagBidAdapter_spec.js +++ b/test/spec/modules/seedtagBidAdapter_spec.js @@ -1,5 +1,5 @@ import { expect } from 'chai' -import { spec, getTimeoutUrl } from 'modules/seedtagBidAdapter' +import { spec, getTimeoutUrl } from 'modules/seedtagBidAdapter.js' function getSlotConfigs(mediaTypes, params) { return { diff --git a/test/spec/modules/segmentoBidAdapter_spec.js b/test/spec/modules/segmentoBidAdapter_spec.js new file mode 100644 index 00000000000..17ad424f73f --- /dev/null +++ b/test/spec/modules/segmentoBidAdapter_spec.js @@ -0,0 +1,187 @@ +import { expect } from 'chai'; +import { spec } from '../../../modules/segmentoBidAdapter.js'; + +const BIDDER_CODE = 'segmento'; +const URL = 'https://prebid-bidder.rutarget.ru/bid'; +const SYNC_IFRAME_URL = 'https://tag.rutarget.ru/tag?event=otherPage&check=true&response=syncframe&synconly=true'; +const SYNC_IMAGE_URL = 'https://tag.rutarget.ru/tag?event=otherPage&check=true&synconly=true'; +const RUB = 'RUB'; +const TIME_TO_LIVE = 0; + +describe('SegmentoAdapter', function () { + describe('isBidRequestValid', function () { + const bid = { + bidder: BIDDER_CODE, + bidId: '51ef8751f9aead', + params: { + placementId: 34 + }, + adUnitCode: 'div-gpt-ad-1460505748561-0', + transactionId: 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', + sizes: [[320, 50], [300, 250], [300, 600]], + bidderRequestId: '418b37f85e772c', + auctionId: '18fd8b8b0bd757' + }; + + it('should return true if placementId is a number', function () { + expect(spec.isBidRequestValid(bid)).to.equal(true); + }); + + it('should return false if placementId is not a number', function () { + bid.params.placementId = 'placementId'; + expect(spec.isBidRequestValid(bid)).to.equal(false); + }); + + it('should return false if no placementId param', function () { + delete bid.params.placementId; + expect(spec.isBidRequestValid(bid)).to.equal(false); + }); + }); + + describe('buildRequests', function () { + const bids = [{ + bidder: 'segmento', + bidId: '51ef8751f9aead', + params: { + placementId: 34 + }, + adUnitCode: 'div-gpt-ad-1460505748561-0', + transactionId: 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', + sizes: [[320, 50], [300, 250], [300, 600]], + bidderRequestId: '418b37f85e772c', + auctionId: '18fd8b8b0bd757' + }]; + + const bidderRequest = { + refererInfo: { + referer: 'https://comepage.com' + } + }; + + const request = spec.buildRequests(bids, bidderRequest); + it('should return POST method', function () { + expect(request.method).to.equal('POST'); + }); + + it('should return valid url', function () { + expect(request.url).to.equal(URL); + }); + + it('should return valid data', function () { + const data = request.data; + expect(data).to.have.all.keys('settings', 'places'); + expect(data.settings.currency).to.be.equal(RUB); + expect(data.settings.referrer).to.be.a('string'); + expect(data.settings.referrer).to.be.equal(bidderRequest.refererInfo.referer); + const places = data.places; + for (let i = 0; i < places.length; i++) { + const place = places[i]; + const bid = bids[i]; + expect(place).to.have.all.keys('id', 'placementId', 'sizes'); + expect(place.id).to.be.a('string'); + expect(place.id).to.be.equal(bid.bidId); + expect(place.placementId).to.be.a('number'); + expect(place.placementId).to.be.equal(bid.params.placementId); + expect(place.sizes).to.be.an('array'); + expect(place.sizes).to.deep.equal(bid.sizes); + } + }); + + it('should return empty places if no valid bids are passed', function () { + const request = spec.buildRequests([], {}); + expect(request.data.places).to.be.an('array').to.deep.equal([]); + }); + }); + + describe('interpretResponse', function() { + const serverResponse = { + body: { + bids: [{ + id: '51ef8751f9aead', + cpm: 0.23, + currency: RUB, + creativeId: 123, + displayUrl: 'displayUrl?t=123&p=456', + size: { + width: 300, + height: 250 + } + }] + } + }; + + const emptyServerResponse = { + body: { + bids: [] + } + }; + + it('should return valid data', function () { + const response = spec.interpretResponse(serverResponse); + expect(response).to.be.an('array'); + for (let i = 0; i < response.length; i++) { + const item = response[i]; + const bid = serverResponse.body.bids[i]; + expect(item).to.have.all.keys('requestId', 'cpm', 'width', 'height', 'creativeId', + 'currency', 'netRevenue', 'ttl', 'adUrl'); + expect(item.requestId).to.be.a('string'); + expect(item.requestId).to.be.equal(bid.id); + expect(item.cpm).to.be.a('number'); + expect(item.cpm).to.be.equal(bid.cpm); + expect(item.width).to.be.a('number'); + expect(item.width).to.be.equal(bid.size.width); + expect(item.height).to.be.a('number'); + expect(item.height).to.be.equal(bid.size.height); + expect(item.creativeId).to.be.a('number'); + expect(item.creativeId).to.be.equal(bid.creativeId); + expect(item.currency).to.be.a('string'); + expect(item.currency).to.be.equal(bid.currency); + expect(item.netRevenue).to.be.a('boolean'); + expect(item.netRevenue).to.equal(true); + expect(item.ttl).to.be.a('number'); + expect(item.ttl).to.be.equal(TIME_TO_LIVE); + expect(item.adUrl).to.be.a('string'); + expect(item.adUrl).to.be.equal(bid.displayUrl); + } + }); + + it('should return empty array if no bids', function () { + const response = spec.interpretResponse(emptyServerResponse); + expect(response).to.be.an('array').to.deep.equal([]); + }); + + it('should return empty array if server response is invalid', function () { + const response = spec.interpretResponse({}); + expect(response).to.be.an('array').to.deep.equal([]); + }); + }); + + describe('getUserSyncs', function() { + it('should return iframe type if iframe enabled', function () { + const syncs = spec.getUserSyncs({ iframeEnabled: true }); + const sync = syncs[0]; + expect(syncs).to.be.an('array').with.lengthOf(1); + expect(sync).to.have.all.keys('type', 'url'); + expect(sync.type).to.be.a('string'); + expect(sync.type).to.be.equal('iframe'); + expect(sync.url).to.be.a('string'); + expect(sync.url).to.be.equal(SYNC_IFRAME_URL); + }); + + it('should return iframe type if iframe disabled, but image enable', function () { + const syncs = spec.getUserSyncs({ pixelEnabled: true }); + const sync = syncs[0]; + expect(syncs).to.be.an('array').with.lengthOf(1); + expect(sync).to.have.all.keys('type', 'url'); + expect(sync.type).to.be.a('string'); + expect(sync.type).to.be.equal('image'); + expect(sync.url).to.be.a('string'); + expect(sync.url).to.be.equal(SYNC_IMAGE_URL); + }); + + it('should return empty array if iframe and pixels disabled', function () { + const syncs = spec.getUserSyncs({}); + expect(syncs).to.be.an('array').to.deep.equal([]); + }); + }); +}); diff --git a/test/spec/modules/sekindoUMBidAdapter_spec.js b/test/spec/modules/sekindoUMBidAdapter_spec.js index b699015bb3e..2c361c21303 100644 --- a/test/spec/modules/sekindoUMBidAdapter_spec.js +++ b/test/spec/modules/sekindoUMBidAdapter_spec.js @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import { spec } from 'modules/sekindoUMBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; +import { spec } from 'modules/sekindoUMBidAdapter.js'; +import { newBidder } from 'src/adapters/bidderFactory.js'; describe('sekindoUMAdapter', function () { const adapter = newBidder(spec); @@ -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 8949463e151..00000000000 --- 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 index 1190648bb84..e69de29bb2d 100644 --- a/test/spec/modules/serverbidServerBidAdapter_spec.js +++ b/test/spec/modules/serverbidServerBidAdapter_spec.js @@ -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/shareUserIds_spec.js b/test/spec/modules/shareUserIds_spec.js index 4ae5f93a1a6..451892919cb 100644 --- a/test/spec/modules/shareUserIds_spec.js +++ b/test/spec/modules/shareUserIds_spec.js @@ -1,4 +1,4 @@ -import {userIdTargeting} from '../../../modules/userIdTargeting'; +import {userIdTargeting} from '../../../modules/userIdTargeting.js'; import { expect } from 'chai'; describe('#userIdTargeting', function() { @@ -22,7 +22,7 @@ describe('#userIdTargeting', function() { pubads.clearTargeting(); pubads.setTargeting('test', ['TEST']); userIdTargeting(userIds, JSON.stringify(config)); - expect(pubads.getTargeting()).to.deep.equal({test: ['TEST']}); + expect(pubads.getTargeting('test')).to.deep.equal(['TEST']); }); it('all UserIds are passed as is with GAM: true', function() { @@ -31,7 +31,8 @@ describe('#userIdTargeting', function() { pubads.setTargeting('test', ['TEST']); delete config.GAM_KEYS; userIdTargeting(userIds, config); - expect(pubads.getTargeting()).to.deep.equal({test: ['TEST'], tdid: ['my-tdid']}); + expect(pubads.getTargeting('test')).to.deep.equal(['TEST']); + expect(pubads.getTargeting('tdid')).to.deep.equal(['my-tdid']); }) it('Publisher prefered key-names are used', function() { @@ -39,7 +40,8 @@ describe('#userIdTargeting', function() { pubads.clearTargeting(); pubads.setTargeting('test', ['TEST']); userIdTargeting(userIds, config); - expect(pubads.getTargeting()).to.deep.equal({test: ['TEST'], 'TD_ID': ['my-tdid']}); + expect(pubads.getTargeting('test')).to.deep.equal(['TEST']); + expect(pubads.getTargeting('TD_ID')).to.deep.equal(['my-tdid']); }); it('Publisher does not want to pass an id', function() { @@ -48,6 +50,6 @@ describe('#userIdTargeting', function() { pubads.setTargeting('test', ['TEST']); config.GAM_KEYS.tdid = ''; userIdTargeting(userIds, config); - expect(pubads.getTargeting()).to.deep.equal({test: ['TEST']}); + expect(pubads.getTargeting('test')).to.deep.equal(['TEST']); }); }); diff --git a/test/spec/modules/sharethroughBidAdapter_spec.js b/test/spec/modules/sharethroughBidAdapter_spec.js index 8a8ccdbbeb3..92f9fd11eeb 100644 --- a/test/spec/modules/sharethroughBidAdapter_spec.js +++ b/test/spec/modules/sharethroughBidAdapter_spec.js @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import { sharethroughAdapterSpec, sharethroughInternal } from 'modules/sharethroughBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; +import { sharethroughAdapterSpec, sharethroughInternal } from 'modules/sharethroughBidAdapter.js'; +import { newBidder } from 'src/adapters/bidderFactory.js'; const spec = newBidder(sharethroughAdapterSpec).getSpec(); const bidRequests = [ @@ -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' @@ -120,9 +120,9 @@ const bidderResponse = { header: { get: (header) => header } }; -const setUserAgent = (str) => { +const setUserAgent = (uaString) => { window.navigator['__defineGetter__']('userAgent', function () { - return str; + return uaString; }); }; @@ -217,10 +217,8 @@ describe('sharethrough adapter spec', function () { it('should return an array of requests', function () { const builtBidRequests = spec.buildRequests(bidRequests); - expect(builtBidRequests[0].url).to.eq( - 'http://btlr.sharethrough.com/WYu2BXv1/v1'); - expect(builtBidRequests[1].url).to.eq( - 'http://btlr.sharethrough.com/WYu2BXv1/v1'); + expect(builtBidRequests[0].url).to.eq('https://btlr.sharethrough.com/WYu2BXv1/v1'); + expect(builtBidRequests[1].url).to.eq('https://btlr.sharethrough.com/WYu2BXv1/v1'); expect(builtBidRequests[0].method).to.eq('GET'); }); @@ -250,6 +248,34 @@ describe('sharethrough adapter spec', function () { expect(builtBidRequests[0].data.instant_play_capable).to.be.false; }); + it('should set the secure parameter to false when the protocol is http', function() { + const stub = sinon.stub(sharethroughInternal, 'getProtocol').returns('http:'); + const bidRequest = spec.buildRequests(bidRequests, null)[0]; + expect(bidRequest.data.secure).to.be.false; + stub.restore() + }); + + it('should set the secure parameter to true when the protocol is https', function() { + const stub = sinon.stub(sharethroughInternal, 'getProtocol').returns('https:'); + const bidRequest = spec.buildRequests(bidRequests, null)[0]; + expect(bidRequest.data.secure).to.be.true; + stub.restore() + }); + + it('should set the secure parameter to true when the protocol is neither http or https', function() { + const stub = sinon.stub(sharethroughInternal, 'getProtocol').returns('about:'); + const bidRequest = spec.buildRequests(bidRequests, null)[0]; + expect(bidRequest.data.secure).to.be.true; + stub.restore() + }); + + it('should add ccpa parameter if uspConsent is present', function () { + const uspConsent = '1YNN'; + const bidderRequest = { uspConsent: uspConsent }; + const bidRequest = spec.buildRequests(bidRequests, bidderRequest)[0]; + expect(bidRequest.data.us_privacy).to.eq(uspConsent); + }); + it('should add consent parameters if gdprConsent is present', function () { const gdprConsent = { consentString: 'consent_string123', gdprApplies: true }; const bidderRequest = { gdprConsent: gdprConsent }; @@ -413,7 +439,7 @@ describe('sharethrough adapter spec', function () { expect(() => btoa(JSON.stringify(bidderResponse))).to.throw(); expect(() => resp = sharethroughInternal.b64EncodeUnicode(JSON.stringify(bidderResponse))).not.to.throw(); expect(adMarkup).to.match( - /data-str-native-key="pKey" data-stx-response-name=\"str_response_bidId\"/); + /data-str-native-key="pKey" data-stx-response-name="str_response_bidId"/); expect(!!adMarkup.indexOf(resp)).to.eql(true); // insert functionality to autodetect whether or not in safeframe, and handle JS insertion @@ -428,10 +454,10 @@ describe('sharethrough adapter spec', function () { expect(() => btoa(JSON.stringify(bidderResponse))).to.throw(); expect(() => resp = sharethroughInternal.b64EncodeUnicode(JSON.stringify(bidderResponse))).not.to.throw(); expect(adMarkup).to.match( - /data-str-native-key="pKey" data-stx-response-name=\"str_response_bidId\"/); + /data-str-native-key="pKey" data-stx-response-name="str_response_bidId"/); expect(!!adMarkup.indexOf(resp)).to.eql(true); expect(adMarkup).to.match( - /"'; +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 index 30afad308c7..5e6397f1b2e 100644 --- a/test/spec/modules/smartadserverBidAdapter_spec.js +++ b/test/spec/modules/smartadserverBidAdapter_spec.js @@ -3,28 +3,32 @@ import { } from 'chai'; import { spec -} from 'modules/smartadserverBidAdapter'; +} from 'modules/smartadserverBidAdapter.js'; import { newBidder -} from 'src/adapters/bidderFactory'; +} from 'src/adapters/bidderFactory.js'; import { config -} from 'src/config'; -import * as utils from 'src/utils'; -import { requestBidsHook } from 'modules/consentManagement'; +} from 'src/config.js'; +import * as utils from 'src/utils.js'; +import { requestBidsHook } from 'modules/consentManagement.js'; // Default params with optional ones describe('Smart bid adapter tests', function () { var DEFAULT_PARAMS = [{ adUnitCode: 'sas_42', bidId: 'abcd1234', - sizes: [ - [300, 250], - [300, 200] - ], + mediaTypes: { + banner: { + sizes: [ + [300, 250], + [300, 200] + ] + } + }, bidder: 'smartadserver', params: { - domain: 'http://prg.smartadserver.com', + domain: 'https://prg.smartadserver.com', siteId: '1234', pageId: '5678', formatId: '90', @@ -42,13 +46,18 @@ describe('Smart bid adapter tests', function () { var DEFAULT_PARAMS_WO_OPTIONAL = [{ adUnitCode: 'sas_42', bidId: 'abcd1234', - sizes: [ - [300, 250], - [300, 200] - ], + mediaTypes: { + banner: { + sizes: [ + [300, 250], + [300, 200] + ], + } + }, + bidder: 'smartadserver', params: { - domain: 'http://prg.smartadserver.com', + domain: 'https://prg.smartadserver.com', siteId: '1234', pageId: '5678', formatId: '90' @@ -78,9 +87,10 @@ describe('Smart bid adapter tests', function () { } }); 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('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'); @@ -93,7 +103,7 @@ describe('Smart bid adapter tests', function () { 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.not.have.property('pageDomain'); 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'); @@ -115,7 +125,6 @@ describe('Smart bid adapter tests', function () { 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, { @@ -262,6 +271,35 @@ describe('Smart bid adapter tests', function () { }); }); + describe('ccpa/us privacy tests', function () { + afterEach(function () { + config.resetConfig(); + $$PREBID_GLOBAL$$.requestBids.removeAll(); + }); + + it('Verify build request with us privacy', function () { + config.setConfig({ + 'currency': { + 'adServerCurrency': 'EUR' + }, + consentManagement: { + cmp: 'iab', + consentRequired: true, + timeout: 1000, + allowAuctionWithoutConsent: true + } + }); + + const uspConsentValue = '1YNN' + const request = spec.buildRequests(DEFAULT_PARAMS_WO_OPTIONAL, { + uspConsent: uspConsentValue + }); + const requestContent = JSON.parse(request[0].data); + + expect(requestContent).to.have.property('us_privacy').and.to.equal(uspConsentValue); + }); + }); + describe('Instream video tests', function () { afterEach(function () { config.resetConfig(); @@ -327,7 +365,7 @@ describe('Smart bid adapter tests', function () { 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.not.have.property('pageDomain'); 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'); @@ -355,7 +393,6 @@ describe('Smart bid adapter tests', function () { 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, { @@ -379,7 +416,7 @@ describe('Smart bid adapter tests', function () { } }, params: { - domain: 'http://prg.smartadserver.com', + domain: 'https://prg.smartadserver.com', siteId: '1234', pageId: '5678', formatId: '90', @@ -396,4 +433,49 @@ describe('Smart bid adapter tests', function () { expect(request[1]).to.not.be.empty; }); }); + + describe('Supply Chain Serializer tests', function () { + it('Verify a multi node supply chain serialization matches iab example', function() { + let schain = { + 'ver': '1.0', + 'complete': 1, + 'nodes': [ + { + 'asi': 'exchange1.com', + 'sid': '1234', + 'hp': 1, + 'rid': 'bid-request-1', + 'name': 'publisher', + 'domain': 'publisher.com' + }, + { + 'asi': 'exchange2.com', + 'sid': 'abcd', + 'hp': 1, + 'rid': 'bid-request-2', + 'name': 'intermediary', + 'domain': 'intermediary.com' + } + ] + }; + + let serializedSchain = spec.serializeSupplyChain(schain); + expect(serializedSchain).to.equal('1.0,1!exchange1.com,1234,1,bid-request-1,publisher,publisher.com!exchange2.com,abcd,1,bid-request-2,intermediary,intermediary.com'); + }); + + it('Verifiy that null schain produce null result', function () { + let actual = spec.serializeSupplyChain(null); + expect(null, actual); + }); + + it('Verifiy that schain with null nodes produce null result', function () { + let schain = { + 'ver': '1.0', + 'complete': 1 + + }; + let actual = spec.serializeSupplyChain(null); + expect(null, actual); + }); + }); }); diff --git a/test/spec/modules/smartrtbBidAdapter_spec.js b/test/spec/modules/smartrtbBidAdapter_spec.js index 7477dbf9418..cb5ceee0870 100644 --- a/test/spec/modules/smartrtbBidAdapter_spec.js +++ b/test/spec/modules/smartrtbBidAdapter_spec.js @@ -1,6 +1,6 @@ import { expect } from 'chai' -import { spec, _getPlatform } from 'modules/smartrtbBidAdapter' -import { newBidder } from 'src/adapters/bidderFactory' +import { spec, _getPlatform } from 'modules/smartrtbBidAdapter.js' +import { newBidder } from 'src/adapters/bidderFactory.js' const br = { body: { @@ -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 index e301e9733a6..2780e88255d 100644 --- a/test/spec/modules/smartyadsBidAdapter_spec.js +++ b/test/spec/modules/smartyadsBidAdapter_spec.js @@ -1,5 +1,5 @@ import {expect} from 'chai'; -import {spec} from '../../../modules/smartyadsBidAdapter'; +import {spec} from '../../../modules/smartyadsBidAdapter.js'; describe('SmartyadsAdapter', function () { let bid = { @@ -33,7 +33,7 @@ describe('SmartyadsAdapter', 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'); + expect(serverRequest.url).to.equal('https://ssp-nj.webtradehub.com/?c=o&m=multi'); }); it('Returns valid data if array of bids is valid', function () { let data = serverRequest.data; @@ -46,7 +46,7 @@ describe('SmartyadsAdapter', function () { 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).to.have.keys('placementId', 'bidId', 'traffic', 'sizes'); expect(placement.placementId).to.equal(0); expect(placement.bidId).to.equal('23fhj33i987f'); expect(placement.traffic).to.equal('banner'); @@ -78,7 +78,7 @@ describe('SmartyadsAdapter', function () { 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'); + 'netRevenue', 'currency', 'dealId', 'mediaType'); expect(dataItem.requestId).to.equal('23fhj33i987f'); expect(dataItem.cpm).to.equal(0.4); expect(dataItem.width).to.equal(300); @@ -108,8 +108,7 @@ describe('SmartyadsAdapter', function () { let dataItem = videoResponses[0]; expect(dataItem).to.have.all.keys('requestId', 'cpm', 'vastUrl', 'ttl', 'creativeId', - 'netRevenue', 'currency', 'dealId'); - expect(dataItem.mediaType).to.not.exist; + 'netRevenue', 'currency', 'dealId', 'mediaType'); expect(dataItem.requestId).to.equal('23fhj33i987f'); expect(dataItem.cpm).to.equal(0.5); expect(dataItem.vastUrl).to.equal('test.com'); @@ -122,10 +121,12 @@ describe('SmartyadsAdapter', function () { const native = { body: [{ mediaType: 'native', - clickUrl: 'test.com', - title: 'Test', - image: 'test.com', - impressionTrackers: ['test.com'], + native: { + clickUrl: 'test.com', + title: 'Test', + image: 'test.com', + impressionTrackers: ['test.com'], + }, ttl: 120, cpm: 0.4, requestId: '23fhj33i987f', @@ -138,15 +139,15 @@ describe('SmartyadsAdapter', function () { 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).to.have.keys('requestId', 'cpm', 'ttl', 'creativeId', 'netRevenue', 'currency', 'mediaType', 'native'); + expect(dataItem.native).to.have.keys('clickUrl', 'impressionTrackers', 'title', 'image') 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.native.clickUrl).to.equal('test.com'); + expect(dataItem.native.title).to.equal('Test'); + expect(dataItem.native.image).to.equal('test.com'); + expect(dataItem.native.impressionTrackers).to.be.an('array').that.is.not.empty; + expect(dataItem.native.impressionTrackers[0]).to.equal('test.com'); expect(dataItem.ttl).to.equal(120); expect(dataItem.creativeId).to.equal('2'); expect(dataItem.netRevenue).to.be.true; @@ -224,7 +225,7 @@ describe('SmartyadsAdapter', 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('//ssp-nj.webtradehub.com/?c=o&m=cookie'); + expect(userSync[0].url).to.be.equal('https://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 144c7ca60f6..0ac242ce0e1 100644 --- a/test/spec/modules/smilewantedBidAdapter_spec.js +++ b/test/spec/modules/smilewantedBidAdapter_spec.js @@ -1,9 +1,9 @@ import { expect } from 'chai'; -import { spec } from 'modules/smilewantedBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; -import { config } from 'src/config'; -import * as utils from 'src/utils'; -import { requestBidsHook } from 'modules/consentManagement'; +import { spec } from 'modules/smilewantedBidAdapter.js'; +import { newBidder } from 'src/adapters/bidderFactory.js'; +import { config } from 'src/config.js'; +import * as utils from 'src/utils.js'; +import { requestBidsHook } from 'modules/consentManagement.js'; const DISPLAY_REQUEST = [{ adUnitCode: 'sw_300x250', @@ -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/smmsBidAdapter_spec.js b/test/spec/modules/smmsBidAdapter_spec.js index 3ed952811ea..3cbeb91cf5a 100644 --- a/test/spec/modules/smmsBidAdapter_spec.js +++ b/test/spec/modules/smmsBidAdapter_spec.js @@ -1,6 +1,6 @@ import {expect} from 'chai'; -import {spec, _getUrlVars} from 'modules/smmsBidAdapter'; -import * as utils from 'src/utils'; +import {spec, _getUrlVars} from 'modules/smmsBidAdapter.js'; +import * as utils from 'src/utils.js'; const BASE_URI = 'https://bidder.mediams.mb.softbank.jp/api/v1/prebid/banner' const NATIVE_BASE_URI = 'https://bidder.mediams.mb.softbank.jp/api/v1/prebid/native' diff --git a/test/spec/modules/somoBidAdapter_spec.js b/test/spec/modules/somoBidAdapter_spec.js index 16fd43841b7..32e9c6c5323 100644 --- a/test/spec/modules/somoBidAdapter_spec.js +++ b/test/spec/modules/somoBidAdapter_spec.js @@ -1,6 +1,6 @@ import {expect} from 'chai'; -import {spec} from 'modules/somoBidAdapter'; -import * as utils from 'src/utils'; +import {spec} from 'modules/somoBidAdapter.js'; +import * as utils from 'src/utils.js'; describe('Somo Audience Adapter Tests', function () { describe('isBidRequestValid', function () { @@ -32,13 +32,20 @@ describe('Somo Audience Adapter Tests', function () { placementId: 'test' } }]; - const request = spec.buildRequests(bidRequests); - expect(request[0].url).to.equal('//publisher-east.mobileadtrading.com/rtb/bid?s=test'); + const bidderRequest = { + refererInfo: { + referer: 'https://www.test.com/page?var=val', + canonicalUrl: 'https://www.test.com/page' + } + }; + + const request = spec.buildRequests(bidRequests, bidderRequest); + expect(request[0].url).to.equal('https://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.ref).to.equal('https://www.test.com/page?var=val'); + expect(ortbRequest.site.page).to.equal('https://www.test.com/page'); expect(ortbRequest.site.domain).to.not.be.undefined; expect(ortbRequest.imp).to.have.lengthOf(1); expect(ortbRequest.device).to.not.equal(null); @@ -50,18 +57,30 @@ describe('Somo Audience Adapter Tests', function () { it('should properly build a banner request with sizes defined in 2d array', function () { const bidRequests = [{ bidder: 'somo', - sizes: [[300, 250]], + mediaTypes: { + banner: { + 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'); + + const bidderRequest = { + refererInfo: { + referer: 'https://www.test.com/page?var=val', + canonicalUrl: 'https://www.test.com/page' + } + } + + const request = spec.buildRequests(bidRequests, bidderRequest); + expect(request[0].url).to.equal('https://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.ref).to.equal('https://www.test.com/page?var=val'); + expect(ortbRequest.site.page).to.equal('https://www.test.com/page'); expect(ortbRequest.site.domain).to.not.be.undefined; expect(ortbRequest.imp).to.have.lengthOf(1); expect(ortbRequest.imp[0].bidfloor).to.not.be.null; @@ -72,18 +91,30 @@ describe('Somo Audience Adapter Tests', function () { it('should properly build a banner request with sizes defined in 1d array', function () { const bidRequests = [{ bidder: 'somo', - sizes: [300, 250], + mediaTypes: { + banner: { + 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'); + + const bidderRequest = { + refererInfo: { + referer: 'https://www.test.com/page?var=val', + canonicalUrl: 'https://www.test.com/page' + } + }; + + const request = spec.buildRequests(bidRequests, bidderRequest); + expect(request[0].url).to.equal('https://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.ref).to.equal('https://www.test.com/page?var=val'); + expect(ortbRequest.site.page).to.equal('https://www.test.com/page'); expect(ortbRequest.site.domain).to.not.be.undefined; expect(ortbRequest.imp).to.have.lengthOf(1); expect(ortbRequest.imp[0].bidfloor).to.not.be.null; @@ -100,7 +131,11 @@ describe('Somo Audience Adapter Tests', function () { const bidRequests = [ { bidder: 'somo', - sizes: [[300, 200]], + mediaTypes: { + banner: { + sizes: [[300, 200]] + } + }, mediaType: 'banner', params: { placementId: 'test', @@ -130,18 +165,27 @@ describe('Somo Audience Adapter Tests', function () { const bidRequests = [{ bidder: 'somo', mediaTypes: { - video: {} + video: { + sizes: [200, 300] + } }, - sizes: [200, 300], params: { placementId: 'test' } }]; - const request = spec.buildRequests(bidRequests); + + const bidderRequest = { + refererInfo: { + referer: 'https://www.test.com/page?var=val', + canonicalUrl: 'https://www.test.com/page' + } + }; + + const request = spec.buildRequests(bidRequests, bidderRequest); 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.ref).to.equal('https://www.test.com/page?var=val'); + expect(ortbRequest.site.page).to.equal('https://www.test.com/page'); expect(ortbRequest.site.domain).to.not.be.undefined; expect(ortbRequest.imp).to.have.lengthOf(1); expect(ortbRequest.imp[0].video).to.not.equal(null); @@ -153,18 +197,27 @@ describe('Somo Audience Adapter Tests', function () { const bidRequests = [{ bidder: 'somo', mediaTypes: { - video: {} + video: { + sizes: [[200, 300]] + } }, - sizes: [[200, 300]], params: { placementId: 'test' } }]; - const request = spec.buildRequests(bidRequests); + + const bidderRequest = { + refererInfo: { + referer: 'https://www.test.com/page?var=val', + canonicalUrl: 'https://www.test.com/page' + } + }; + + const request = spec.buildRequests(bidRequests, bidderRequest); 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.ref).to.equal('https://www.test.com/page?var=val'); + expect(ortbRequest.site.page).to.equal('https://www.test.com/page'); expect(ortbRequest.site.domain).to.not.be.undefined; expect(ortbRequest.imp).to.have.lengthOf(1); expect(ortbRequest.imp[0].video).to.not.equal(null); @@ -200,8 +253,11 @@ describe('Somo Audience Adapter Tests', function () { const bidRequests = [ { bidder: 'somo', - sizes: [[200, 300]], - mediaType: 'video', + mediaTypes: { + video: { + sizes: [[200, 300]] + } + }, params: { placementId: 'test', video: { @@ -247,12 +303,20 @@ describe('Somo Audience Adapter Tests', function () { placementId: 'test' } }]; - const request = spec.buildRequests(bidRequests); + + const bidderRequest = { + refererInfo: { + referer: 'https://www.test.com/page?var=val', + canonicalUrl: 'https://www.test.com/page' + } + }; + + const request = spec.buildRequests(bidRequests, bidderRequest); 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.ref).to.equal('https://www.test.com/page?var=val'); + expect(ortbRequest.site.page).to.equal('https://www.test.com/page'); expect(ortbRequest.site.domain).to.not.be.undefined; }); diff --git a/test/spec/modules/sonobiAnalyticsAdapter_spec.js b/test/spec/modules/sonobiAnalyticsAdapter_spec.js index 389dfee34f9..76ff88836d4 100644 --- a/test/spec/modules/sonobiAnalyticsAdapter_spec.js +++ b/test/spec/modules/sonobiAnalyticsAdapter_spec.js @@ -1,25 +1,20 @@ -import sonobiAnalytics from 'modules/sonobiAnalyticsAdapter'; +import sonobiAnalytics from 'modules/sonobiAnalyticsAdapter.js'; import {expect} from 'chai'; +import {server} from 'test/mocks/xhr.js'; let events = require('src/events'); let adapterManager = require('src/adapterManager').default; let constants = require('src/constants.json'); describe('Sonobi Prebid Analytic', function () { - let xhr; - let requests = []; var clock; describe('enableAnalytics', function () { beforeEach(function () { - requests = []; - xhr = sinon.useFakeXMLHttpRequest(); - xhr.onCreate = request => requests.push(request); sinon.stub(events, 'getEvents').returns([]); clock = sinon.useFakeTimers(Date.now()); }); afterEach(function () { - xhr.restore(); events.getEvents.restore(); clock.restore(); }); @@ -81,8 +76,8 @@ describe('Sonobi Prebid Analytic', function () { events.emit(constants.EVENTS.AUCTION_END, {auctionId: '13', bidsReceived: [bid]}); clock.tick(5000); - expect(requests).to.have.length(1); - expect(JSON.parse(requests[0].requestBody)).to.have.length(3) + expect(server.requests).to.have.length(1); + expect(JSON.parse(server.requests[0].requestBody)).to.have.length(3) done(); }); }); diff --git a/test/spec/modules/sonobiBidAdapter_spec.js b/test/spec/modules/sonobiBidAdapter_spec.js index 8d4dff0fbac..019edd84c9f 100644 --- a/test/spec/modules/sonobiBidAdapter_spec.js +++ b/test/spec/modules/sonobiBidAdapter_spec.js @@ -1,7 +1,7 @@ import { expect } from 'chai' -import { spec, _getPlatform } from 'modules/sonobiBidAdapter' -import { newBidder } from 'src/adapters/bidderFactory' -import {userSync} from '../../../src/userSync'; +import { spec, _getPlatform } from 'modules/sonobiBidAdapter.js' +import { newBidder } from 'src/adapters/bidderFactory.js' +import {userSync} from '../../../src/userSync.js'; describe('SonobiBidAdapter', function () { const adapter = newBidder(spec) @@ -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', @@ -297,11 +298,10 @@ describe('SonobiBidAdapter', function () { 'refererInfo': { 'numIframes': 0, 'reachedTop': true, - 'referer': 'http://example.com', - 'stack': ['http://example.com'] + 'referer': 'https://example.com', + 'stack': ['https://example.com'] }, uspConsent: 'someCCPAString' - }; it('should include the digitrust id and keyv', () => { window.DigiTrust = { @@ -343,7 +343,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) @@ -371,7 +371,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 () { @@ -392,8 +392,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) @@ -412,8 +412,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) @@ -436,62 +436,8 @@ describe('SonobiBidAdapter', function () { it('should return null if there is nothing to bid on', function () { const bidRequests = spec.buildRequests([{params: {}}], bidderRequests) expect(bidRequests).to.equal(null); - }) - - it('should return a properly formatted request with commonid as hfa', function () { - delete bidRequest[0].params.hfa; - delete bidRequest[1].params.hfa; - bidRequest[0].crumbs = {'pubcid': 'abcd-efg-0101'}; - bidRequest[1].crumbs = {'pubcid': 'abcd-efg-0101'}; - const bidRequests = spec.buildRequests(bidRequest, bidderRequests); - expect(bidRequests.url).to.equal('https://apex.go.sonobi.com/trinity.json'); - expect(bidRequests.method).to.equal('GET'); - expect(bidRequests.data.ref).not.to.be.empty; - expect(bidRequests.data.s).not.to.be.empty; - expect(bidRequests.data.hfa).to.equal('PRE-abcd-efg-0101'); }); - it('should return a properly formatted request with commonid from User ID as hfa', function () { - delete bidRequest[0].params.hfa; - delete bidRequest[1].params.hfa; - bidRequest[0].userId = {'pubcid': 'abcd-efg-0101'}; - bidRequest[1].userId = {'pubcid': 'abcd-efg-0101'}; - const bidRequests = spec.buildRequests(bidRequest, bidderRequests); - expect(bidRequests.url).to.equal('https://apex.go.sonobi.com/trinity.json'); - expect(bidRequests.method).to.equal('GET'); - expect(bidRequests.data.ref).not.to.be.empty; - expect(bidRequests.data.s).not.to.be.empty; - expect(bidRequests.data.hfa).to.equal('PRE-abcd-efg-0101'); - delete bidRequest[0].userId; - delete bidRequest[1].userId; - }) - - it('should return a properly formatted request with unified id from User ID as tdid', function () { - delete bidRequest[0].params.tdid; - delete bidRequest[1].params.tdid; - bidRequest[0].userId = {'tdid': 'td-abcd-efg-0101'}; - bidRequest[1].userId = {'tdid': 'td-abcd-efg-0101'}; - const bidRequests = spec.buildRequests(bidRequest, bidderRequests); - expect(bidRequests.url).to.equal('https://apex.go.sonobi.com/trinity.json'); - expect(bidRequests.method).to.equal('GET'); - expect(bidRequests.data.ref).not.to.be.empty; - expect(bidRequests.data.s).not.to.be.empty; - expect(bidRequests.data.tdid).to.equal('td-abcd-efg-0101'); - }) - - it('should return a properly formatted request with hfa preferred over commonid', function () { - bidRequest[0].params.hfa = 'hfakey'; - bidRequest[1].params.hfa = 'hfakey'; - bidRequest[0].crumbs = {'pubcid': 'abcd-efg-0101'}; - bidRequest[1].crumbs = {'pubcid': 'abcd-efg-0101'}; - const bidRequests = spec.buildRequests(bidRequest, bidderRequests) - expect(bidRequests.url).to.equal('https://apex.go.sonobi.com/trinity.json') - expect(bidRequests.method).to.equal('GET') - expect(bidRequests.data.ref).not.to.be.empty - expect(bidRequests.data.s).not.to.be.empty - expect(bidRequests.data.hfa).to.equal('hfakey') - }) - it('should set ius as 0 if Sonobi cannot drop iframe pixels', function () { userSync.canBidderRegisterSync.returns(false); const bidRequests = spec.buildRequests(bidRequest, bidderRequests); @@ -542,11 +488,30 @@ describe('SonobiBidAdapter', function () { 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'); + }); + it('should return a properly formatted request with us_privacy included', function() { const bidRequests = spec.buildRequests(bidRequest, bidderRequests); expect(bidRequests.data.us_privacy).to.equal('someCCPAString'); }); - }) + + it('should make a request to the url defined in the bidder param', function() { + const bRequest = [ + { + ...bidRequest[0], + params: { + ...bidRequest[0].params, + bid_request_url: 'https://iad-2-apex.go.sonobi.com/trinity.json' + } + } + ]; + const bidRequests = spec.buildRequests(bRequest, bidderRequests); + expect(bidRequests.url).to.equal('https://iad-2-apex.go.sonobi.com/trinity.json'); + }) + }); describe('.interpretResponse', function () { const bidRequests = { @@ -554,7 +519,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': [ { @@ -660,7 +625,7 @@ describe('SonobiBidAdapter', function () { 'cpm': 1.07, 'width': 300, 'height': 600, - 'ad': ``, + 'ad': ``, 'ttl': 500, 'creativeId': '1234abcd', 'netRevenue': true, @@ -672,7 +637,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, @@ -686,7 +651,7 @@ describe('SonobiBidAdapter', function () { 'cpm': 1.07, 'width': 300, 'height': 600, - 'ad': ``, + 'ad': ``, 'ttl': 500, 'creativeId': '1234abcd', 'netRevenue': true, @@ -698,7 +663,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/sortableAnalyticsAdapter_spec.js b/test/spec/modules/sortableAnalyticsAdapter_spec.js index 90bd5fcdf22..258c4b8f74d 100644 --- a/test/spec/modules/sortableAnalyticsAdapter_spec.js +++ b/test/spec/modules/sortableAnalyticsAdapter_spec.js @@ -1,13 +1,12 @@ import {expect} from 'chai'; -import sortableAnalyticsAdapter, {TIMEOUT_FOR_REGISTRY, DEFAULT_PBID_TIMEOUT} from 'modules/sortableAnalyticsAdapter'; -import events from 'src/events'; +import sortableAnalyticsAdapter, {TIMEOUT_FOR_REGISTRY, DEFAULT_PBID_TIMEOUT} from 'modules/sortableAnalyticsAdapter.js'; +import events from 'src/events.js'; import CONSTANTS from 'src/constants.json'; -import * as prebidGlobal from 'src/prebidGlobal'; +import * as prebidGlobal from 'src/prebidGlobal.js'; +import {server} from 'test/mocks/xhr.js'; describe('Sortable Analytics Adapter', function() { - let requests; let sandbox; - let xhr; let clock; const initialConfig = { @@ -137,8 +136,6 @@ describe('Sortable Analytics Adapter', function() { beforeEach(function() { sandbox = sinon.sandbox.create(); - xhr = sandbox.useFakeXMLHttpRequest(); - xhr.onCreate = (request) => requests.push(request); clock = sandbox.useFakeTimers(); sandbox.stub(events, 'getEvents').returns([]); sandbox.stub(prebidGlobal, 'getGlobal').returns({ @@ -152,12 +149,12 @@ describe('Sortable Analytics Adapter', function() { } }); - requests = []; sortableAnalyticsAdapter.enableAnalytics(initialConfig); }); afterEach(function() { sandbox.restore(); + clock.restore(); sortableAnalyticsAdapter.disableAnalytics(); }); @@ -179,6 +176,9 @@ describe('Sortable Analytics Adapter', function() { }); describe('events tracking', function() { + beforeEach(function() { + server.requests = []; + }); it('should send the PBID event', function() { events.emit(CONSTANTS.EVENTS.AUCTION_INIT, TEST_DATA.AUCTION_INIT); events.emit(CONSTANTS.EVENTS.BID_REQUESTED, TEST_DATA.BID_REQUESTED); @@ -190,8 +190,8 @@ describe('Sortable Analytics Adapter', function() { clock.tick(DEFAULT_PBID_TIMEOUT); - expect(requests.length).to.equal(1); - let result = JSON.parse(requests[0].requestBody); + expect(server.requests.length).to.equal(1); + let result = JSON.parse(server.requests[0].requestBody); expect(result).to.have.own.property('pbid'); expect(result.pbid).to.deep.include({ ai: 'fb8d579a-5c3f-4705-ab94-3cff39005d9e', @@ -242,10 +242,10 @@ describe('Sortable Analytics Adapter', function() { clock.tick(TIMEOUT_FOR_REGISTRY); - expect(requests.length).to.equal(2); - const pbid_req = JSON.parse(requests[0].requestBody); + expect(server.requests.length).to.equal(2); + const pbid_req = JSON.parse(server.requests[0].requestBody); expect(pbid_req).to.have.own.property('pbid'); - const pbwon_req = JSON.parse(requests[1].requestBody); + const pbwon_req = JSON.parse(server.requests[1].requestBody); expect(pbwon_req).to.have.own.property('pbrw'); expect(pbwon_req.pbrw).to.deep.equal({ ac: '300x250', @@ -270,10 +270,10 @@ describe('Sortable Analytics Adapter', function() { clock.tick(TIMEOUT_FOR_REGISTRY); - expect(requests.length).to.equal(2); - const pbid_req = JSON.parse(requests[0].requestBody); + expect(server.requests.length).to.equal(2); + const pbid_req = JSON.parse(server.requests[0].requestBody); expect(pbid_req).to.have.own.property('pbid'); - const pbto_req = JSON.parse(requests[1].requestBody); + const pbto_req = JSON.parse(server.requests[1].requestBody); expect(pbto_req).to.have.own.property('pbto'); expect(pbto_req.pbto).to.deep.equal({ ai: 'fb8d579a-5c3f-4705-ab94-3cff39005d9e', @@ -291,8 +291,8 @@ describe('Sortable Analytics Adapter', function() { clock.tick(TIMEOUT_FOR_REGISTRY); - expect(requests.length).to.equal(1); - const err_req = JSON.parse(requests[0].requestBody); + expect(server.requests.length).to.equal(1); + const err_req = JSON.parse(server.requests[0].requestBody); expect(err_req).to.have.own.property('pber'); expect(err_req.pber).to.include({ args: '{}', diff --git a/test/spec/modules/sortableBidAdapter_spec.js b/test/spec/modules/sortableBidAdapter_spec.js index 98695f44ee0..8d2b4eea87d 100644 --- a/test/spec/modules/sortableBidAdapter_spec.js +++ b/test/spec/modules/sortableBidAdapter_spec.js @@ -1,9 +1,7 @@ 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}`; +import { spec } from 'modules/sortableBidAdapter.js'; +import { newBidder } from 'src/adapters/bidderFactory.js'; +import * as utils from 'src/utils.js'; describe('sortableBidAdapter', function() { const adapter = newBidder(spec); @@ -56,6 +54,12 @@ describe('sortableBidAdapter', function() { expect(spec.isBidRequestValid(bid)).to.equal(false); }); + it('should return false when sizes are empty', function () { + let bid = makeBid(); + bid.sizes = []; + expect(spec.isBidRequestValid(bid)).to.equal(false); + }); + it('should return false when require params are not passed', function () { let bid = makeBid(); bid.params = {}; @@ -100,6 +104,25 @@ describe('sortableBidAdapter', function() { delete bid.params.keywords; expect(spec.isBidRequestValid(bid)).to.equal(true); }); + + it('should return true with video media type', () => { + const videoBid = { + 'bidder': 'sortable', + 'params': { + 'tagId': '403370', + 'siteId': 'example.com', + }, + 'adUnitCode': 'adunit-code', + 'bidId': '30b31c1838de1e', + 'bidderRequestId': '22edbae2733bf6', + 'auctionId': '1d1a030790a475', + 'mediaTypes': { + 'video': { + } + } + }; + expect(spec.isBidRequestValid(videoBid)).to.equal(true); + }); }); describe('buildRequests', function () { @@ -124,9 +147,33 @@ describe('sortableBidAdapter', function() { 'bidId': '30b31c1838de1e', 'bidderRequestId': '22edbae2733bf6', 'auctionId': '1d1a030790a475' + }, { + 'bidder': 'sortable', + 'params': { + 'tagId': '403371', + 'siteId': 'example.com', + 'floor': 0.21 + }, + 'sizes': [ + [300, 250] + ], + 'bidId': '30b31c1838de1e', + 'bidderRequestId': '22edbae2733bf6', + 'auctionId': '1d1a030790a475', + 'mediaTypes': { + 'native': { + 'body': {'required': true, 'sendId': true}, + 'clickUrl': {'required': true, 'sendId': true}, + 'cta': {'required': true, 'sendId': true}, + 'icon': {'required': true, 'sendId': true}, + 'image': {'required': true, 'sendId': true}, + 'sponsoredBy': {'required': true, 'sendId': true}, + 'title': {'required': true, 'sendId': true, 'len': 100} + } + } }]; - const request = spec.buildRequests(bidRequests); + const request = spec.buildRequests(bidRequests, {refererInfo: { referer: 'http://example.com/page?param=val' }}); const requestBody = JSON.parse(request.data); it('sends bid request to our endpoint via POST', function () { @@ -134,6 +181,7 @@ describe('sortableBidAdapter', function() { }); it('attaches source and version to endpoint URL as query params', function () { + const ENDPOINT = `https://c.deployads.com/openrtb2/auction?src=$$REPO_AND_VERSION$$&host=example.com`; expect(request.url).to.equal(ENDPOINT); }); @@ -163,6 +211,126 @@ describe('sortableBidAdapter', function() { '300x250': 1.20 }); }); + + it('sets domain and href correctly', function () { + expect(requestBody.site.domain).to.equal('example.com'); + expect(requestBody.site.page).to.equal('http://example.com/page?param=val'); + }); + + it('should have the version in native object set for native bid', function() { + expect(requestBody.imp[1].native.ver).to.equal('1'); + }); + + it('should have the assets set for native bid', function() { + const assets = JSON.parse(requestBody.imp[1].native.request).assets; + expect(assets[0]).to.deep.equal({'title': {'len': 100}, 'required': 1, 'id': 0}); + expect(assets[1]).to.deep.equal({'img': {'type': 3, 'wmin': 1, 'hmin': 1}, 'required': 1, 'id': 1}); + expect(assets[2]).to.deep.equal({'img': {'type': 1, 'wmin': 1, 'hmin': 1}, 'required': 1, 'id': 2}); + expect(assets[3]).to.deep.equal({'data': {'type': 2}, 'required': 1, 'id': 3}); + expect(assets[4]).to.deep.equal({'data': {'type': 12}, 'required': 1, 'id': 4}); + expect(assets[5]).to.deep.equal({'data': {'type': 1}, 'required': 1, 'id': 5}); + }); + + const videoBidRequests = [{ + 'bidder': 'sortable', + 'params': { + 'tagId': '403370', + 'siteId': 'example.com', + 'video': { + 'minduration': 5, + 'maxduration': 10, + 'startdelay': 0 + } + }, + 'bidId': '30b31c1838de1e', + 'bidderRequestId': '22edbae2733bf6', + 'auctionId': '1d1a030790a475', + 'mediaTypes': { + 'video': { + 'context': 'instream', + 'mimes': ['video/x-ms-wmv'], + 'playerSize': [[400, 300]], + 'api': [0], + 'protocols': [2, 3], + 'playbackmethod': [1] + } + } + }]; + + const videoRequest = spec.buildRequests(videoBidRequests, {refererInfo: { referer: 'http://localhost:9876/' }}); + const videoRequestBody = JSON.parse(videoRequest.data); + + it('should include video params', () => { + const video = videoRequestBody.imp[0].video; + expect(video.mimes).to.deep.equal(['video/x-ms-wmv']); + expect(video.w).to.equal(400); + expect(video.h).to.equal(300); + expect(video.api).to.deep.equal([0]); + expect(video.protocols).to.deep.equal([2, 3]); + expect(video.playbackmethod).to.deep.equal([1]); + expect(video.minduration).to.equal(5); + expect(video.maxduration).to.equal(10); + expect(video.startdelay).to.equal(0); + }); + + it('sets domain and href correctly', function () { + expect(videoRequestBody.site.domain).to.equal('localhost'); + expect(videoRequestBody.site.page).to.equal('http://localhost:9876/'); + }); + + const gdprBidRequests = [{ + 'bidder': 'sortable', + 'params': { + 'tagId': '403370', + 'siteId': 'example.com', + 'floor': 0.21, + 'keywords': {}, + 'floorSizeMap': {} + }, + 'sizes': [ + [300, 250] + ], + 'bidId': '30b31c1838de1e', + 'bidderRequestId': '22edbae2733bf6', + 'auctionId': '1d1a030790a475' + }]; + const consentString = 'BOJ/P2HOJ/P2HABABMAAAAAZ+A=='; + + function getGdprRequestBody(gdprApplies, consentString) { + const gdprRequest = spec.buildRequests(gdprBidRequests, {'gdprConsent': { + 'gdprApplies': gdprApplies, + 'consentString': consentString + }, + refererInfo: { + referer: 'http://localhost:9876/' + }}); + return JSON.parse(gdprRequest.data); + } + + it('should handle gdprApplies being present and true', function() { + const gdprRequestBody = getGdprRequestBody(true, consentString); + expect(gdprRequestBody.regs.ext.gdpr).to.equal(1); + expect(gdprRequestBody.user.ext.consent).to.equal(consentString); + }) + + it('should handle gdprApplies being present and false', function() { + const gdprRequestBody = getGdprRequestBody(false, consentString); + expect(gdprRequestBody.regs.ext.gdpr).to.equal(0); + expect(gdprRequestBody.user.ext.consent).to.equal(consentString); + }) + + it('should handle gdprApplies being undefined', function() { + const gdprRequestBody = getGdprRequestBody(undefined, consentString); + expect(gdprRequestBody.regs).to.deep.equal({ext: {}}); + expect(gdprRequestBody.user.ext.consent).to.equal(consentString); + }) + + it('should handle gdprConsent being undefined', function() { + const gdprRequest = spec.buildRequests(gdprBidRequests, {refererInfo: { referer: 'http://localhost:9876/' }}); + const gdprRequestBody = JSON.parse(gdprRequest.data); + expect(gdprRequestBody.regs).to.deep.equal({ext: {}}); + expect(gdprRequestBody.user).to.equal(undefined); + }) }); describe('interpretResponse', function () { @@ -193,6 +361,33 @@ describe('sortableBidAdapter', function() { }; } + function makeNativeResponse() { + return { + body: { + 'id': '5e5c23a5ba71e77', + 'seatbid': [ + { + 'bid': [ + { + 'id': '6vmb3isptf', + 'crid': 'sortablescreative', + 'impid': '322add653672f67', + 'price': 1.55, + 'adm': '{"native":{"link":{"clicktrackers":[],"url":"https://www.sortable.com/"},"assets":[{"title":{"text":"Ads With Sortable"},"id":1},{"img":{"w":790,"url":"https://path.to/image","h":294},"id":2},{"img":{"url":"https://path.to/icon"},"id":3},{"data":{"value":"Body here"},"id":4},{"data":{"value":"Learn More"},"id":5},{"data":{"value":"Sortable"},"id":6}],"imptrackers":[],"ver":1}}', + 'ext': {'ad_format': 'native'}, + 'h': 90, + 'nurl': 'http://nurl', + 'w': 728 + } + ], + 'seat': 'MOCK' + } + ], + 'bidid': '5e5c23a5ba71e77' + } + }; + } + const expectedBid = { 'requestId': '322add653672f68', 'cpm': 1.22, @@ -207,6 +402,29 @@ describe('sortableBidAdapter', function() { 'ad': '
' }; + const expectedNativeBid = { + 'requestId': '322add653672f67', + 'cpm': 1.55, + 'width': 728, + 'height': 90, + 'creativeId': 'sortablescreative', + 'dealId': null, + 'currency': 'USD', + 'netRevenue': true, + 'sortable': { 'ad_format': 'native' }, + 'mediaType': 'native', + 'ttl': 60, + 'native': { + 'clickUrl': 'https://www.sortable.com/', + 'title': 'Ads With Sortable', + 'image': {'url': 'https://path.to/image', 'height': 294, 'width': 790}, + 'icon': 'https://path.to/icon', + 'body': 'Body here', + 'cta': 'Learn More', + 'sponsoredBy': 'Sortable' + } + }; + it('should get the correct bid response', function () { let result = spec.interpretResponse(makeResponse()); expect(result.length).to.equal(1); @@ -254,5 +472,68 @@ describe('sortableBidAdapter', function() { let result = spec.interpretResponse(response); expect(result.length).to.equal(0); }); + + it('should get the correct native bid response', function () { + let result = spec.interpretResponse(makeNativeResponse()); + expect(result.length).to.equal(1); + expect(result[0]).to.deep.equal(expectedNativeBid); + }); + + it('fail to parse invalid native bid response', function () { + let response = makeNativeResponse(); + response.body.seatbid[0].bid[0].adm = ''; + let result = spec.interpretResponse(response); + expect(result.length).to.equal(0); + }); + + it('should keep custom properties', () => { + const customProperties = {test: 'a test message', param: {testParam: 1}}; + const expectedResult = Object.assign({}, expectedBid, {[spec.code]: customProperties}); + const response = makeResponse(); + response.body.seatbid[0].bid[0].ext = customProperties; + const result = spec.interpretResponse(response); + expect(result.length).to.equal(1); + expect(result[0]).to.deep.equal(expectedResult); + }); + + it('should handle instream response', () => { + const response = makeResponse(); + const bid = response.body.seatbid[0].bid[0]; + delete bid.nurl; + bid.ext = {ad_format: 'instream'}; + const result = spec.interpretResponse(response)[0]; + expect(result.mediaType).to.equal('video'); + expect(result.vastXml).to.equal(bid.adm); + }); + + it('should return iframe syncs', () => { + const syncResponse = { + ext: { + sync_dsps: [ + ['iframe', 'http://example-dsp/sync-iframe'], + ['image', 'http://example-dsp/sync-image'] + ] + } + }; + expect(spec.getUserSyncs({iframeEnabled: true}, [{body: syncResponse}])).to.deep.equal([{ + type: 'iframe', + url: 'http://example-dsp/sync-iframe' + }]); + }); + + it('should return image syncs', () => { + const syncResponse = { + ext: { + sync_dsps: [ + ['iframe', 'http://example-dsp/sync-iframe'], + ['image', 'http://example-dsp/sync-image'] + ] + } + }; + expect(spec.getUserSyncs({pixelEnabled: true}, [{body: syncResponse}])).to.deep.equal([{ + type: 'image', + url: 'http://example-dsp/sync-image' + }]); + }); }); }); diff --git a/test/spec/modules/sovrnAnalyticsAdapter_spec.js b/test/spec/modules/sovrnAnalyticsAdapter_spec.js index 299e22ca790..d6795331417 100644 --- a/test/spec/modules/sovrnAnalyticsAdapter_spec.js +++ b/test/spec/modules/sovrnAnalyticsAdapter_spec.js @@ -1,7 +1,8 @@ -import sovrnAnalyticsAdapter from '../../../modules/sovrnAnalyticsAdapter' -import { expect } from 'chai' -import {config} from 'src/config' -import adaptermanager from 'src/adapterManager' +import sovrnAnalyticsAdapter from '../../../modules/sovrnAnalyticsAdapter.js'; +import { expect } from 'chai'; +import {config} from 'src/config.js'; +import adaptermanager from 'src/adapterManager.js'; +import { server } from 'test/mocks/xhr.js'; var assert = require('assert'); let events = require('src/events'); @@ -171,16 +172,10 @@ let bidAdjustmentNoMatchingRequest = { 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(); }); @@ -436,7 +431,7 @@ describe('Sovrn Analytics Adapter', function () { emitEvent('BID_RESPONSE', bidResponse, auctionId); emitEvent('BID_RESPONSE', bidResponse2, auctionId) emitEvent('AUCTION_END', {}, auctionId); - let requestBody = JSON.parse(requests[0].requestBody); + let requestBody = JSON.parse(server.requests[0].requestBody); let requestsFromRequestBody = requestBody.requests[0]; let bidsFromRequests = requestsFromRequestBody.bids[0]; expect(requestBody).to.deep.include(expectedPostBody); @@ -512,7 +507,7 @@ describe('Sovrn Analytics Adapter', function () { it('should send bid won data ', function () { emitEvent('AUCTION_INIT', auctionInit, auctionId); emitEvent('BID_WON', bidWonEvent, auctionId); - let requestBody = JSON.parse(requests[0].requestBody); + let requestBody = JSON.parse(server.requests[0].requestBody); expect(requestBody).to.deep.include(expectedBidWonBody); expect(requestBody.winningBid).to.deep.include(expectedWinningBid); }); @@ -536,9 +531,9 @@ describe('Sovrn Analytics Adapter', function () { emitEvent('AUCTION_INIT', auctionInit, auctionId) emitEvent('BID_REQUESTED', bidRequested, auctionId) emitEvent('AUCTION_END', {}, auctionId) - requests[0].respond(200) + server.requests[0].respond(200) emitEvent('BID_RESPONSE', bidResponse, auctionId) - let requestBody = JSON.parse(requests[1].requestBody) + let requestBody = JSON.parse(server.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/sovrnBidAdapter_spec.js b/test/spec/modules/sovrnBidAdapter_spec.js index 0778b6487c2..c82cc32207a 100644 --- a/test/spec/modules/sovrnBidAdapter_spec.js +++ b/test/spec/modules/sovrnBidAdapter_spec.js @@ -1,6 +1,6 @@ import {expect} from 'chai'; -import {LogError, spec} from 'modules/sovrnBidAdapter'; -import {newBidder} from 'src/adapters/bidderFactory'; +import {LogError, spec} from 'modules/sovrnBidAdapter.js'; +import {newBidder} from 'src/adapters/bidderFactory.js'; const ENDPOINT = `https://ap.lijit.com/rtb/bid?src=$$REPO_AND_VERSION$$`; diff --git a/test/spec/modules/spotxBidAdapter_spec.js b/test/spec/modules/spotxBidAdapter_spec.js index be550e8fc83..9c6e6071155 100644 --- a/test/spec/modules/spotxBidAdapter_spec.js +++ b/test/spec/modules/spotxBidAdapter_spec.js @@ -1,5 +1,5 @@ import {expect} from 'chai'; -import {spec, GOOGLE_CONSENT} from 'modules/spotxBidAdapter'; +import {spec, GOOGLE_CONSENT} from 'modules/spotxBidAdapter.js'; describe('the spotx adapter', function () { function getValidBidObject() { @@ -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); @@ -273,6 +273,30 @@ describe('the spotx adapter', function () { expect(request.data.regs.ext.gdpr).to.equal(1); expect(request.data.user.ext.consent).to.equal('consent123'); }); + + it('should pass CCPA us_privacy string', function() { + var request; + + bidRequestObj.uspConsent = '1YYY' + + request = spec.buildRequests([bid], bidRequestObj)[0]; + expect(request.data.regs.ext.us_privacy).to.equal('1YYY'); + }); + + it('should pass both GDPR params and CCPA us_privacy', function() { + var request; + + bidRequestObj.gdprConsent = { + consentString: 'consent123', + gdprApplies: true + }; + bidRequestObj.uspConsent = '1YYY' + + request = spec.buildRequests([bid], bidRequestObj)[0]; + expect(request.data.regs.ext.gdpr).to.equal(1); + expect(request.data.user.ext.consent).to.equal('consent123'); + expect(request.data.regs.ext.us_privacy).to.equal('1YYY'); + }); }); describe('interpretResponse', function() { @@ -359,7 +383,8 @@ 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].videoCacheKey).to.equal('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 +396,8 @@ 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].videoCacheKey).to.equal('cache124'); expect(responses[1].width).to.equal(200); }); }); @@ -440,9 +466,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 +498,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 593871fd9d6..f8e3ba83bbe 100644 --- a/test/spec/modules/staqAnalyticsAdapter_spec.js +++ b/test/spec/modules/staqAnalyticsAdapter_spec.js @@ -1,6 +1,6 @@ -import analyticsAdapter, { ExpiringQueue, getUmtSource, storage } from 'modules/staqAnalyticsAdapter'; +import analyticsAdapter, { ExpiringQueue, getUmtSource, storage } from 'modules/staqAnalyticsAdapter.js'; import { expect } from 'chai'; -import adapterManager from 'src/adapterManager'; +import adapterManager from 'src/adapterManager.js'; import CONSTANTS from 'src/constants.json'; const events = require('../../../src/events'); @@ -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/stvBidAdapter_spec.js b/test/spec/modules/stvBidAdapter_spec.js index 72ea428304a..c2278313b2d 100644 --- a/test/spec/modules/stvBidAdapter_spec.js +++ b/test/spec/modules/stvBidAdapter_spec.js @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import { spec } from 'modules/stvBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; +import { spec } from 'modules/stvBidAdapter.js'; +import { newBidder } from 'src/adapters/bidderFactory.js'; const VADS_ENDPOINT_URL = 'https://ads.smartstream.tv/r/'; diff --git a/test/spec/modules/sublimeBidAdapter_spec.js b/test/spec/modules/sublimeBidAdapter_spec.js index 45173b09953..ae9e293a757 100644 --- a/test/spec/modules/sublimeBidAdapter_spec.js +++ b/test/spec/modules/sublimeBidAdapter_spec.js @@ -1,10 +1,30 @@ import { expect } from 'chai'; -import { spec } from 'modules/sublimeBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; +import { spec, sendEvent, log, setState, state } from 'modules/sublimeBidAdapter.js'; +import { newBidder } from 'src/adapters/bidderFactory.js'; + +let utils = require('src/utils'); describe('Sublime Adapter', function() { const adapter = newBidder(spec); + describe('sendEvent', function() { + let sandbox; + + beforeEach(function () { + sandbox = sinon.sandbox.create(); + }); + + it('should trigger pixel', function () { + sandbox.spy(utils, 'triggerPixel'); + sendEvent('test', true); + expect(utils.triggerPixel.called).to.equal(true); + }); + + afterEach(function () { + sandbox.restore(); + }); + }) + describe('inherited functions', function() { it('exists and is a function', function() { expect(adapter.callBids).to.exist.and.to.be.a('function'); @@ -129,6 +149,7 @@ describe('Sublime Adapter', function() { currency: 'USD', netRevenue: true, ttl: 600, + pbav: '0.5.2', ad: '', }, ]; @@ -170,6 +191,7 @@ describe('Sublime Adapter', function() { netRevenue: true, ttl: 600, ad: '', + pbav: '0.5.2', }; expect(result[0]).to.deep.equal(expectedResponse); @@ -219,6 +241,7 @@ describe('Sublime Adapter', function() { netRevenue: true, ttl: 600, ad: '', + pbav: '0.5.2', }; expect(result[0]).to.deep.equal(expectedResponse); @@ -250,6 +273,10 @@ describe('Sublime Adapter', function() { let expectedResponse = []; expect(result).to.deep.equal(expectedResponse); + + describe('On bid Time out', function () { + spec.onTimeout(result); + }); }); }); }); diff --git a/test/spec/modules/supply2BidAdapter_spec.js b/test/spec/modules/supply2BidAdapter_spec.js deleted file mode 100644 index 8abbecd801c..00000000000 --- 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 d2f024181a4..b67da86ebf2 100644 --- a/test/spec/modules/synacormediaBidAdapter_spec.js +++ b/test/spec/modules/synacormediaBidAdapter_spec.js @@ -1,6 +1,6 @@ import { assert, expect } from 'chai'; -import { BANNER } from 'src/mediaTypes'; -import { spec } from 'modules/synacormediaBidAdapter'; +import { BANNER } from 'src/mediaTypes.js'; +import { spec } from 'modules/synacormediaBidAdapter.js'; describe('synacormediaBidAdapter ', function () { describe('isBidRequestValid', function () { @@ -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([ { @@ -535,6 +535,109 @@ describe('synacormediaBidAdapter ', function () { }); }); + describe('Bid Requests with schain object ', function() { + let validBidReq = { + bidder: 'synacormedia', + params: { + seatId: 'prebid', + placementId: 'demo1', + pos: 1, + video: {} + }, + renderer: { + url: '../syncOutstreamPlayer.js' + }, + mediaTypes: { + video: { + playerSize: [[300, 250]], + context: 'outstream' + } + }, + adUnitCode: 'div-1', + transactionId: '0869f34e-090b-4b20-84ee-46ff41405a39', + sizes: [[300, 250]], + bidId: '22b3a2268d9f0e', + bidderRequestId: '1d195910597e13', + auctionId: '3375d336-2aea-4ee7-804c-6d26b621ad20', + src: 'client', + bidRequestsCount: 1, + bidderRequestsCount: 1, + bidderWinsCount: 0, + schain: { + ver: '1.0', + complete: 1, + nodes: [ + { + asi: 'indirectseller.com', + sid: '00001', + hp: 1 + } + ] + } + }; + let bidderRequest = { + refererInfo: { + referer: 'http://localhost:9999/' + }, + bidderCode: 'synacormedia', + auctionId: 'f8a75621-d672-4cbb-9275-3db7d74fb110', + bidderRequestId: '16d438671bfbec', + bids: [ + { + bidder: 'synacormedia', + params: { + seatId: 'prebid', + placementId: 'demo1', + pos: 1, + video: {} + }, + renderer: { + url: '../syncOutstreamPlayer.js' + }, + mediaTypes: { + video: { + playerSize: [[300, 250]], + context: 'outstream' + } + }, + adUnitCode: 'div-1', + sizes: [[300, 250]], + bidId: '211c0236bb8f4e', + bidderRequestId: '16d438671bfbec', + auctionId: 'f8a75621-d672-4cbb-9275-3db7d74fb110', + src: 'client', + bidRequestsCount: 1, + bidderRequestsCount: 1, + bidderWinsCount: 0, + schain: { + ver: '1.0', + complete: 1, + nodes: [ + { + asi: 'indirectseller.com', + sid: '00001', + hp: 1 + } + ] + } + } + ], + auctionStart: 1580310345205, + timeout: 1000, + start: 1580310345211 + }; + + it('should return valid bid request with schain object', function () { + let req = spec.buildRequests([validBidReq], 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.data).to.have.property('source'); + expect(req.data.source).to.have.property('ext'); + expect(req.data.source.ext).to.have.property('schain'); + }); + }); + describe('interpretResponse', function () { let bidResponse = { id: '10865933907263896~9998~0', @@ -542,7 +645,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 +653,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 +788,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/taphypeBidAdapter_spec.js b/test/spec/modules/taphypeBidAdapter_spec.js index 2fcdd964520..6b36973814e 100644 --- a/test/spec/modules/taphypeBidAdapter_spec.js +++ b/test/spec/modules/taphypeBidAdapter_spec.js @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import { spec } from 'modules/taphypeBidAdapter'; +import { spec } from 'modules/taphypeBidAdapter.js'; describe('taphypeBidAdapterTests', function () { it('validate_pub_params', function () { diff --git a/test/spec/modules/teadsBidAdapter_spec.js b/test/spec/modules/teadsBidAdapter_spec.js index 670888bc4d6..e21dce9135a 100644 --- a/test/spec/modules/teadsBidAdapter_spec.js +++ b/test/spec/modules/teadsBidAdapter_spec.js @@ -1,9 +1,9 @@ import {expect} from 'chai'; -import {spec} from 'modules/teadsBidAdapter'; -import {newBidder} from 'src/adapters/bidderFactory'; +import {spec} from 'modules/teadsBidAdapter.js'; +import {newBidder} from 'src/adapters/bidderFactory.js'; -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,8 @@ describe('teadsBidAdapter', () => { 'gdprApplies': true, 'vendorData': { 'hasGlobalConsent': false - } + }, + 'apiVersion': 1 } }; @@ -146,13 +147,14 @@ describe('teadsBidAdapter', () => { expect(payload.gdpr_iab).to.exist; expect(payload.gdpr_iab.consent).to.equal(consentString); expect(payload.gdpr_iab.status).to.equal(12); + expect(payload.gdpr_iab.apiVersion).to.equal(1); }); it('should add referer info to payload', 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 } @@ -161,7 +163,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() { @@ -175,7 +177,8 @@ describe('teadsBidAdapter', () => { 'gdprApplies': true, 'vendorData': { 'hasGlobalScope': true - } + }, + 'apiVersion': 1 } }; @@ -185,6 +188,32 @@ describe('teadsBidAdapter', () => { expect(payload.gdpr_iab).to.exist; expect(payload.gdpr_iab.consent).to.equal(consentString); expect(payload.gdpr_iab.status).to.equal(11); + expect(payload.gdpr_iab.apiVersion).to.equal(1); + }); + + it('should send GDPR TCF2 to endpoint with 12 status', function() { + let consentString = 'JRJ8RKfDeBNsERRDCSAAZ+A=='; + let bidderRequest = { + 'auctionId': '1d1a030790a475', + 'bidderRequestId': '22edbae2733bf6', + 'timeout': 3000, + 'gdprConsent': { + 'consentString': consentString, + 'gdprApplies': true, + 'vendorData': { + 'isServiceSpecific': true + }, + 'apiVersion': 2 + } + }; + + const request = spec.buildRequests(bidRequests, bidderRequest); + const payload = JSON.parse(request.data); + + expect(payload.gdpr_iab).to.exist; + expect(payload.gdpr_iab.consent).to.equal(consentString); + expect(payload.gdpr_iab.status).to.equal(12); + expect(payload.gdpr_iab.apiVersion).to.equal(2); }); it('should send GDPR to endpoint with 22 status', function() { @@ -196,7 +225,8 @@ describe('teadsBidAdapter', () => { 'gdprConsent': { 'consentString': undefined, 'gdprApplies': undefined, - 'vendorData': undefined + 'vendorData': undefined, + 'apiVersion': 1 } }; @@ -206,6 +236,7 @@ describe('teadsBidAdapter', () => { expect(payload.gdpr_iab).to.exist; expect(payload.gdpr_iab.consent).to.equal(''); expect(payload.gdpr_iab.status).to.equal(22); + expect(payload.gdpr_iab.apiVersion).to.equal(1); }); it('should send GDPR to endpoint with 0 status', function() { @@ -219,7 +250,8 @@ describe('teadsBidAdapter', () => { 'gdprApplies': false, 'vendorData': { 'hasGlobalScope': false - } + }, + 'apiVersion': 1 } }; @@ -229,6 +261,55 @@ describe('teadsBidAdapter', () => { expect(payload.gdpr_iab).to.exist; expect(payload.gdpr_iab.consent).to.equal(consentString); expect(payload.gdpr_iab.status).to.equal(0); + expect(payload.gdpr_iab.apiVersion).to.equal(1); + }); + + it('should send GDPR to endpoint with 0 status when gdprApplies = false (vendorData = undefined)', function() { + let consentString = 'JRJ8RKfDeBNsERRDCSAAZ+A=='; + let bidderRequest = { + 'auctionId': '1d1a030790a475', + 'bidderRequestId': '22edbae2733bf6', + 'timeout': 3000, + 'gdprConsent': { + 'consentString': undefined, + 'gdprApplies': false, + 'vendorData': undefined, + 'apiVersion': 1 + } + }; + + const request = spec.buildRequests(bidRequests, bidderRequest); + const payload = JSON.parse(request.data); + + expect(payload.gdpr_iab).to.exist; + expect(payload.gdpr_iab.consent).to.equal(''); + expect(payload.gdpr_iab.status).to.equal(0); + expect(payload.gdpr_iab.apiVersion).to.equal(1); + }); + + it('should send GDPR to endpoint with 12 status when apiVersion = 0', function() { + let consentString = 'JRJ8RKfDeBNsERRDCSAAZ+A=='; + let bidderRequest = { + 'auctionId': '1d1a030790a475', + 'bidderRequestId': '22edbae2733bf6', + 'timeout': 3000, + 'gdprConsent': { + 'consentString': consentString, + 'gdprApplies': true, + 'vendorData': { + 'hasGlobalScope': false + }, + 'apiVersion': 0 + } + }; + + const request = spec.buildRequests(bidRequests, bidderRequest); + const payload = JSON.parse(request.data); + + expect(payload.gdpr_iab).to.exist; + expect(payload.gdpr_iab.consent).to.equal(consentString); + expect(payload.gdpr_iab.status).to.equal(12); + expect(payload.gdpr_iab.apiVersion).to.equal(0); }); it('should use good mediaTypes video playerSizes', function() { @@ -368,71 +449,4 @@ describe('teadsBidAdapter', () => { expect(result.length).to.equal(0); }); }); - - it('should call userSync with good params', function() { - let bids = [{ - 'body': { - 'responses': [{ - 'ad': '', + 'ad': '', 'ttl': 360, 'creativeId': '5cb5dc9375c0e', 'netRevenue': true, diff --git a/test/spec/modules/viewdeosDXBidAdapter_spec.js b/test/spec/modules/viewdeosDXBidAdapter_spec.js index 80082347687..f9bee1b0efe 100644 --- a/test/spec/modules/viewdeosDXBidAdapter_spec.js +++ b/test/spec/modules/viewdeosDXBidAdapter_spec.js @@ -1,8 +1,8 @@ import {expect} from 'chai'; -import {spec} from 'modules/viewdeosDXBidAdapter'; -import {newBidder} from 'src/adapters/bidderFactory'; +import {spec} from 'modules/viewdeosDXBidAdapter.js'; +import {newBidder} from 'src/adapters/bidderFactory.js'; -const ENDPOINT = '//hb.sync.viewdeos.com/auction/'; +const ENDPOINT = 'https://ghb.sync.viewdeos.com/auction/'; const DISPLAY_REQUEST = { 'bidder': 'viewdeos', @@ -43,6 +43,7 @@ const SERVER_VIDEO_RESPONSE = { } ] }; +const SERVER_OUSTREAM_VIDEO_RESPONSE = SERVER_VIDEO_RESPONSE; const SERVER_DISPLAY_RESPONSE = { 'source': {'aid': 12345, 'pubId': 54321}, @@ -74,6 +75,25 @@ const SERVER_DISPLAY_RESPONSE_WITH_MIXED_SYNCS = { 'cookieURLSTypes': ['image', 'iframe'] }; +const outstreamVideoBidderRequest = { + bidderCode: 'bidderCode', + bids: [{ + 'params': { + 'aid': 12345, + 'outstream': { + 'video_controls': 'show' + } + }, + mediaTypes: { + video: { + context: 'outstream', + playerSize: [640, 480] + } + }, + bidId: '2e41f65424c87c' + }] +}; + const videoBidderRequest = { bidderCode: 'bidderCode', bids: [{mediaTypes: {video: {}}, bidId: '2e41f65424c87c'}] @@ -119,9 +139,17 @@ const displayEqResponse = [{ cpm: 0.9 }]; -describe('viewdeosDXBidAdapter', function () { // todo remove only +describe('viewdeosDXBidAdapter', function () { const adapter = newBidder(spec); + describe('when outstream params are passing properly', function() { + const videoBids = spec.interpretResponse({body: SERVER_OUSTREAM_VIDEO_RESPONSE}, {bidderRequest: outstreamVideoBidderRequest}); + it('should return renderer with expected outstream params config', function() { + expect(!!videoBids[0].renderer).to.equal(true); + expect(videoBids[0].renderer.getConfig().video_controls).to.equal('show'); + }) + }) + 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}]); diff --git a/test/spec/modules/visxBidAdapter_spec.js b/test/spec/modules/visxBidAdapter_spec.js index 167d54e37a6..7720bb2a3e4 100755 --- a/test/spec/modules/visxBidAdapter_spec.js +++ b/test/spec/modules/visxBidAdapter_spec.js @@ -1,7 +1,7 @@ import { expect } from 'chai'; -import { spec } from 'modules/visxBidAdapter'; -import { config } from 'src/config'; -import { newBidder } from 'src/adapters/bidderFactory'; +import { spec } from 'modules/visxBidAdapter.js'; +import { config } from 'src/config.js'; +import { newBidder } from 'src/adapters/bidderFactory.js'; describe('VisxAdapter', function () { const adapter = newBidder(spec); @@ -42,10 +42,18 @@ describe('VisxAdapter', function () { describe('buildRequests', function () { const bidderRequest = { refererInfo: { - referer: 'http://example.com' + referer: 'https://example.com' } }; const referrer = bidderRequest.refererInfo.referer; + const schainObject = { + ver: '1.0', + nodes: [ + {asi: 'exchange2.com', sid: 'abcd', hp: 1}, + {asi: 'exchange1.com', sid: '1234!abcd', hp: 1, name: 'publisher, Inc.', domain: 'publisher.com'} + ] + }; + const schainString = JSON.stringify(schainObject); let bidRequests = [ { 'bidder': 'visx', @@ -200,6 +208,42 @@ describe('VisxAdapter', function () { expect(payload).to.have.property('gdpr_consent', 'AAA'); expect(payload).to.have.property('gdpr_applies', 1); }); + + it('if schain is present payload must have schain param', function () { + const schainBidRequests = [ + Object.assign({schain: schainObject}, bidRequests[0]), + bidRequests[1], + bidRequests[2] + ]; + const request = spec.buildRequests(schainBidRequests, bidderRequest); + const payload = request.data; + expect(payload).to.be.an('object'); + expect(payload).to.have.property('schain', schainString); + expect(payload).to.have.property('u', referrer); + expect(payload).to.have.property('pt', 'net'); + expect(payload).to.have.property('auids', '903535,903535,903536'); + expect(payload).to.have.property('sizes', '300x250,300x600,728x90'); + expect(payload).to.have.property('r', '22edbae2733bf6'); + expect(payload).to.have.property('cur', 'EUR'); + }); + + it('if userId is available payload must have appropriate params', function () { + const schainBidRequests = [ + Object.assign({userId: { + tdid: '111', + id5id: '222', + digitrustid: {data: {id: 'DTID', keyv: 4, privacy: {optout: false}, producer: 'ABC', version: 2}} + }}, bidRequests[0]), + bidRequests[1], + bidRequests[2] + ]; + const request = spec.buildRequests(schainBidRequests, bidderRequest); + const payload = request.data; + expect(payload).to.be.an('object'); + expect(payload).to.have.property('tdid', '111'); + expect(payload).to.have.property('id5', '222'); + expect(payload).to.have.property('dtid', 'DTID'); + }); }); describe('interpretResponse', function () { diff --git a/test/spec/modules/vmgBidAdapter_spec.js b/test/spec/modules/vmgBidAdapter_spec.js index 688c03577fd..41aa077adc7 100644 --- a/test/spec/modules/vmgBidAdapter_spec.js +++ b/test/spec/modules/vmgBidAdapter_spec.js @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import { spec } from 'modules/vmgBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; +import { spec } from 'modules/vmgBidAdapter.js'; +import { newBidder } from 'src/adapters/bidderFactory.js'; describe('VmgAdapter', function () { const adapter = newBidder(spec); diff --git a/test/spec/modules/vrtcalBidAdapter_spec.js b/test/spec/modules/vrtcalBidAdapter_spec.js index 7b37e393575..729b0a723e4 100644 --- a/test/spec/modules/vrtcalBidAdapter_spec.js +++ b/test/spec/modules/vrtcalBidAdapter_spec.js @@ -1,5 +1,5 @@ import {expect} from 'chai'; -import {spec} from '../../../modules/vrtcalBidAdapter'; +import {spec} from '../../../modules/vrtcalBidAdapter.js'; describe('Vrtcal Adapter', function () { let bid = { diff --git a/test/spec/modules/vubleAnalyticsAdapter_spec.js b/test/spec/modules/vubleAnalyticsAdapter_spec.js index 841a53c6dee..e69de29bb2d 100644 --- a/test/spec/modules/vubleAnalyticsAdapter_spec.js +++ b/test/spec/modules/vubleAnalyticsAdapter_spec.js @@ -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/vubleBidAdapter_spec.js b/test/spec/modules/vubleBidAdapter_spec.js index b00dbca9b01..2f0d1c1e262 100644 --- a/test/spec/modules/vubleBidAdapter_spec.js +++ b/test/spec/modules/vubleBidAdapter_spec.js @@ -1,8 +1,8 @@ // import or require modules necessary for the test, e.g.: import {expect} from 'chai'; -import {spec as adapter} from 'modules/vubleBidAdapter'; -import * as utils from 'src/utils'; +import {spec as adapter} from 'modules/vubleBidAdapter.js'; +import * as utils from 'src/utils.js'; describe('VubleAdapter', function () { describe('Check methods existance', function () { @@ -202,7 +202,27 @@ describe('VubleAdapter', function () { adUnitCode: '' } }; - let bidderRequest = { + let request4 = { + method: 'POST', + url: 'https://player.mediabong.net/prebid/request', + data: { + width: '640', + height: '360', + pub_id: '3', + zone_id: '3579', + context: 'instream', + floor_price: 0, + url: '', + env: 'net', + bid_id: 'ijkl', + adUnitCode: '', + gdpr_consent: { + consent_string: 'test', + gdpr_applies: true + } + } + }; + let bidderRequest1 = { refererInfo: { referer: 'https://www.vuble.tv/', reachedTop: true, @@ -214,10 +234,17 @@ describe('VubleAdapter', function () { ] } }; + let bidderRequest2 = { + 'gdprConsent': { + consentString: 'test', + gdprApplies: true + } + }; it('must return the right formatted requests', function () { expect(adapter.buildRequests([bid1, bid2])).to.deep.equal([request1, request2]); - expect(adapter.buildRequests([bid3], bidderRequest)).to.deep.equal([request3]); + expect(adapter.buildRequests([bid3], bidderRequest1)).to.deep.equal([request3]); + expect(adapter.buildRequests([bid3], bidderRequest2)).to.deep.equal([request4]); }); }); diff --git a/test/spec/modules/weboramaBidAdapter_spec.js b/test/spec/modules/weboramaBidAdapter_spec.js deleted file mode 100644 index d0b119825a6..00000000000 --- 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 index b3884a90b84..95f0117e5d1 100644 --- a/test/spec/modules/widespaceBidAdapter_spec.js +++ b/test/spec/modules/widespaceBidAdapter_spec.js @@ -1,6 +1,6 @@ -import { expect } from 'chai'; -import { spec } from 'modules/widespaceBidAdapter'; -import includes from 'core-js/library/fn/array/includes'; +import {expect} from 'chai'; +import {spec, storage} from 'modules/widespaceBidAdapter.js'; +import includes from 'core-js/library/fn/array/includes.js'; describe('+widespaceAdatperTest', function () { // Dummy bid request @@ -141,24 +141,27 @@ describe('+widespaceAdatperTest', function () { }); describe('+bidRequest', function () { - const request = spec.buildRequests(bidRequest, bidderRequest); + let request; const UrlRegExp = /^((ftp|http|https):)?\/\/[^ "]+$/; + before(function() { + request = spec.buildRequests(bidRequest, bidderRequest); + }) let fakeLocalStorage = {}; let lsSetStub; let lsGetStub; let lsRemoveStub; - beforeEach(function() { - lsSetStub = sinon.stub(window.localStorage, 'setItem').callsFake(function (name, value) { + beforeEach(function () { + lsSetStub = sinon.stub(storage, 'setDataInLocalStorage').callsFake(function (name, value) { fakeLocalStorage[name] = value; }); - lsGetStub = sinon.stub(window.localStorage, 'getItem').callsFake(function (key) { + lsGetStub = sinon.stub(storage, 'getDataFromLocalStorage').callsFake(function (key) { return fakeLocalStorage[key] || null; }); - lsRemoveStub = sinon.stub(window.localStorage, 'removeItem').callsFake(function (key) { + lsRemoveStub = sinon.stub(storage, 'removeDataFromLocalStorage').callsFake(function (key) { if (key && (fakeLocalStorage[key] !== null || fakeLocalStorage[key] !== undefined)) { delete fakeLocalStorage[key]; } @@ -166,7 +169,7 @@ describe('+widespaceAdatperTest', function () { }); }); - afterEach(function() { + afterEach(function () { lsSetStub.restore(); lsGetStub.restore(); lsRemoveStub.restore(); diff --git a/test/spec/modules/kummaBidAdapter_spec.js b/test/spec/modules/windtalkerBidAdapter_spec.js similarity index 87% rename from test/spec/modules/kummaBidAdapter_spec.js rename to test/spec/modules/windtalkerBidAdapter_spec.js index 7d33bd085b5..222a7611b01 100644 --- a/test/spec/modules/kummaBidAdapter_spec.js +++ b/test/spec/modules/windtalkerBidAdapter_spec.js @@ -1,12 +1,15 @@ import {expect} from 'chai'; -import {spec} from 'modules/kummaBidAdapter'; -import {getTopWindowLocation} from 'src/utils'; +import {spec} from 'modules/windtalkerBidAdapter'; import {newBidder} from 'src/adapters/bidderFactory'; -describe('Kumma Adapter Tests', function () { +describe('Windtalker Adapter Tests', function () { const slotConfigs = [{ placementCode: '/DfpAccount1/slot1', - sizes: [[300, 250]], + mediaTypes: { + banner: { + sizes: [[300, 250]] + } + }, bidId: 'bid12345', mediaType: 'banner', params: { @@ -20,7 +23,11 @@ describe('Kumma Adapter Tests', function () { } }, { placementCode: '/DfpAccount2/slot2', - sizes: [[728, 90]], + mediaTypes: { + banner: { + sizes: [[728, 90]] + } + }, bidId: 'bid23456', mediaType: 'banner', params: { @@ -49,7 +56,11 @@ describe('Kumma Adapter Tests', function () { }]; const videoSlotConfig = [{ placementCode: '/DfpAccount1/slot4', - sizes: [[640, 480]], + mediaTypes: { + video: { + playerSize: [[640, 480]] + } + }, bidId: 'bid12345678', mediaType: 'video', video: { @@ -70,16 +81,16 @@ describe('Kumma Adapter Tests', function () { app: { id: '1111', name: 'app name', - bundle: 'com.kumma.apps', - storeUrl: 'http://kumma.com/apps', - domain: 'kumma.com' + bundle: 'io.windtalker.apps', + storeUrl: 'https://windtalker.io/apps', + domain: 'windtalker.io' } } }]; it('Verify build request', function () { const request = spec.buildRequests(slotConfigs); - expect(request.url).to.equal('//hb.kumma.com/'); + expect(request.url).to.equal('https://windtalkerdisplay.hb.adp3.net/'); expect(request.method).to.equal('POST'); const ortbRequest = JSON.parse(request.data); // site object @@ -87,7 +98,7 @@ describe('Kumma Adapter Tests', function () { 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.site.page).to.equal(window.location.href); expect(ortbRequest.imp).to.have.lengthOf(2); // device object expect(ortbRequest.device).to.not.equal(null); @@ -117,7 +128,9 @@ describe('Kumma Adapter Tests', function () { bid: [{ impid: ortbRequest.imp[0].id, price: 1.25, - adm: 'This is an Ad' + adm: 'This is an Ad', + w: 300, + h: 250 }] }], cur: 'USD' @@ -145,7 +158,7 @@ describe('Kumma Adapter Tests', function () { it('Verify Native request', function () { const request = spec.buildRequests(nativeSlotConfig); - expect(request.url).to.equal('//hb.kumma.com/'); + expect(request.url).to.equal('https://windtalkerdisplay.hb.adp3.net/'); expect(request.method).to.equal('POST'); const ortbRequest = JSON.parse(request.data); // native impression @@ -183,7 +196,7 @@ describe('Kumma Adapter Tests', function () { it('Verify Native response', function () { const request = spec.buildRequests(nativeSlotConfig); - expect(request.url).to.equal('//hb.kumma.com/'); + expect(request.url).to.equal('https://windtalkerdisplay.hb.adp3.net/'); expect(request.method).to.equal('POST'); const ortbRequest = JSON.parse(request.data); const nativeResponse = { @@ -195,7 +208,7 @@ describe('Kumma Adapter Tests', function () { { 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/' } + link: { url: 'https://brand.com/' } } }; const ortbResponse = { @@ -203,7 +216,7 @@ describe('Kumma Adapter Tests', function () { bid: [{ impid: ortbRequest.imp[0].id, price: 1.25, - nurl: 'http://rtb.adx1.com/log', + nurl: 'https://rtb.adx1.com/log', adm: JSON.stringify(nativeResponse) }] }], @@ -226,21 +239,21 @@ describe('Kumma Adapter Tests', function () { 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.clickUrl).to.equal(encodeURIComponent('https://brand.com/')); expect(nativeBid.impressionTrackers).to.have.lengthOf(1); - expect(nativeBid.impressionTrackers[0]).to.equal('http://rtb.adx1.com/log'); + expect(nativeBid.impressionTrackers[0]).to.equal('https://rtb.adx1.com/log'); }); it('Verify Video request', function () { const request = spec.buildRequests(videoSlotConfig); - expect(request.url).to.equal('//hb.kumma.com/'); + expect(request.url).to.equal('https://windtalkerdisplay.hb.adp3.net/'); 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); + expect(videoRequest.site.page).to.equal(window.location.href); // device object expect(videoRequest.device).to.not.equal(null); expect(videoRequest.device.ua).to.equal(navigator.userAgent); @@ -261,7 +274,7 @@ describe('Kumma Adapter Tests', function () { bid: [{ impid: videoRequest.imp[0].id, price: 1.90, - adm: 'http://vid.example.com/9876', + adm: 'https://vid.example.com/9876', crid: '510511_754567308' }] }], @@ -272,7 +285,7 @@ describe('Kumma Adapter Tests', function () { // 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.vastUrl).to.equal('https://vid.example.com/9876'); expect(bid.crid).to.equal('510511_754567308'); expect(bid.width).to.equal(640); expect(bid.height).to.equal(480); @@ -283,7 +296,7 @@ describe('Kumma Adapter Tests', function () { }); it('Verifies bidder code', function () { - expect(spec.code).to.equal('kumma'); + expect(spec.code).to.equal('windtalker'); }); it('Verifies supported media types', function () { @@ -309,9 +322,9 @@ describe('Kumma Adapter Tests', function () { 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'); + expect(ortbRequest.app.bundle).to.equal('io.windtalker.apps'); + expect(ortbRequest.app.storeurl).to.equal('https://windtalker.io/apps'); + expect(ortbRequest.app.domain).to.equal('windtalker.io'); }); it('Verify GDPR', function () { @@ -322,7 +335,7 @@ describe('Kumma Adapter Tests', function () { } }; const request = spec.buildRequests(slotConfigs, bidderRequest); - expect(request.url).to.equal('//hb.kumma.com/'); + expect(request.url).to.equal('https://windtalkerdisplay.hb.adp3.net/'); expect(request.method).to.equal('POST'); const ortbRequest = JSON.parse(request.data); expect(ortbRequest.user).to.not.equal(null); diff --git a/test/spec/modules/wipesBidAdapter_spec.js b/test/spec/modules/wipesBidAdapter_spec.js new file mode 100644 index 00000000000..c453eca82c5 --- /dev/null +++ b/test/spec/modules/wipesBidAdapter_spec.js @@ -0,0 +1,150 @@ +import {expect} from 'chai'; +import {spec} from 'modules/wipesBidAdapter.js'; +import {newBidder} from 'src/adapters/bidderFactory.js'; + +const ENDPOINT_URL = 'https://adn-srv.reckoner-api.com/v1/prebid'; + +describe('wipesBidAdapter', function () { + const adapter = newBidder(spec); + + describe('isBidRequestValid', function () { + let bid = { + 'bidder': 'wipes', + 'params': { + asid: 'dWyPondh2EGB_bNlrVjzIXRZO9F0k1dpo0I8ZvQ' + }, + 'adUnitCode': 'adunit-code', + 'bidId': '51ef8751f9aead', + 'bidderRequestId': '15246a574e859f', + 'auctionId': 'b06c5141-fe8f-4cdf-9d7d-54415490a917', + }; + + it('should return true when required params found', function () { + expect(spec.isBidRequestValid(bid)).to.equal(true); + }); + + it('should return false when asid not passed correctly', function () { + bid.params.asid = ''; + 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': 'wipes', + 'params': { + asid: 'dWyPondh2EGB_bNlrVjzIXRZO9F0k1dpo0I8ZvQ' + }, + 'adUnitCode': 'adunit-code', + 'bidId': '51ef8751f9aead', + 'bidderRequestId': '15246a574e859f', + 'auctionId': 'b06c5141-fe8f-4cdf-9d7d-54415490a917', + }, + { + 'bidder': 'wipes', + 'params': { + asid: 'dWyPondh2EGB_bNlrVjzIXRZO9F0k1dpo0I8ZvQ' + }, + 'adUnitCode': 'adunit-code2', + 'bidId': '51ef8751f9aead', + 'bidderRequestId': '15246a574e859f', + 'auctionId': 'b06c5141-fe8f-4cdf-9d7d-54415490a917', + } + ]; + + let bidderRequest = { + refererInfo: { + numIframes: 0, + reachedTop: true, + referer: 'http://example.com', + stack: ['http://example.com'] + } + }; + + const request = spec.buildRequests(bidRequests, bidderRequest); + + 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_URL); + expect(request[1].url).to.equal(ENDPOINT_URL); + }); + + it('adUnitCode should be sent as uc parameters on any requests', function () { + expect(request[0].data.asid).to.equal('dWyPondh2EGB_bNlrVjzIXRZO9F0k1dpo0I8ZvQ'); + expect(request[1].data.asid).to.equal('dWyPondh2EGB_bNlrVjzIXRZO9F0k1dpo0I8ZvQ'); + }); + }); + + describe('interpretResponse', function () { + let bidRequestVideo = [ + { + 'method': 'GET', + 'url': ENDPOINT_URL, + 'data': { + 'asid': 'dWyPondh2EGB_bNlrVjzIXRZO9F0k1dpo0I8ZvQ', + 'bid_id': '23beaa6af6cdde', + } + } + ]; + + let serverResponseVideo = { + body: { + 'uuid': 'a42947f8-f8fd-4cf7-bb72-31a87ab1f6ff', + 'ad_tag': '', + 'height': 160, + 'width': 300, + 'cpm': 850, + 'status_message': '', + 'currency': 'JPY', + 'video_creative_id': 600004, + 'bid_id': '23beaa6af6cdde' + } + }; + + it('should get the correct bid response for video', function () { + let expectedResponse = [{ + 'requestId': '23beaa6af6cdde', + 'cpm': 850, + 'width': 300, + 'height': 160, + 'creativeId': '600004', + 'dealId': undefined, + 'currency': 'JPY', + 'netRevenue': true, + 'ttl': 3000, + 'referrer': '', + 'mediaType': 'banner', + 'ad': '' + }]; + 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); + }); + + it('handles empty bid response', function () { + let response = { + body: { + 'uid': 'a42947f8-f8fd-4cf7-bb72-31a87ab1f6ff', + 'height': 0, + 'crid': '', + 'statusMessage': '', + 'width': 0, + 'cpm': 0 + } + }; + let result = spec.interpretResponse(response, bidRequestVideo[0]); + expect(result.length).to.equal(0); + }); + }); +}); diff --git a/test/spec/modules/xendizBidAdapter_spec.js b/test/spec/modules/xendizBidAdapter_spec.js deleted file mode 100644 index 4d1aa3c935f..00000000000 --- 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 e48d3011ed2..a12abc74c64 100644 --- a/test/spec/modules/xhbBidAdapter_spec.js +++ b/test/spec/modules/xhbBidAdapter_spec.js @@ -1,9 +1,9 @@ import { expect } from 'chai'; -import { spec } from 'modules/xhbBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; -import { deepClone } from 'src/utils'; +import { spec } from 'modules/xhbBidAdapter.js'; +import { newBidder } from 'src/adapters/bidderFactory.js'; +import { deepClone } from 'src/utils.js'; -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 2548bb31fdc..00000000000 --- 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/yieldlabBidAdapter_spec.js b/test/spec/modules/yieldlabBidAdapter_spec.js index c8709969e00..5dcd112228a 100644 --- a/test/spec/modules/yieldlabBidAdapter_spec.js +++ b/test/spec/modules/yieldlabBidAdapter_spec.js @@ -1,6 +1,6 @@ import { expect } from 'chai' -import { spec } from 'modules/yieldlabBidAdapter' -import { newBidder } from 'src/adapters/bidderFactory' +import { spec } from 'modules/yieldlabBidAdapter.js' +import { newBidder } from 'src/adapters/bidderFactory.js' const REQUEST = { 'bidder': 'yieldlab', @@ -18,7 +18,14 @@ const REQUEST = { 'auctionId': '2e41f65424c87c', 'adUnitCode': 'adunit-code', 'bidId': '2d925f27f5079f', - 'sizes': [728, 90] + 'sizes': [728, 90], + 'userIdAsEids': [{ + 'source': 'netid.de', + 'uids': [{ + 'id': 'fH5A3n2O8_CZZyPoJVD-eabc6ECb7jhxCicsds7qSg', + 'atype': 1 + }] + }] } const RESPONSE = { @@ -27,9 +34,14 @@ const RESPONSE = { format: 0, id: 1111, price: 1, - pid: 2222 + pid: 2222, + adtype: 'BANNER' } +const VIDEO_RESPONSE = Object.assign({}, RESPONSE, { + 'adtype': 'VIDEO' +}) + describe('yieldlabBidAdapter', function () { const adapter = newBidder(spec) @@ -72,6 +84,10 @@ describe('yieldlabBidAdapter', function () { expect(request.url).to.include('t=key1%3Dvalue1%26key2%3Dvalue2') }) + it('passes userids to bid request', function () { + expect(request.url).to.include('ids=netid.de%3AfH5A3n2O8_CZZyPoJVD-eabc6ECb7jhxCicsds7qSg') + }) + const gdprRequest = spec.buildRequests(bidRequests, { gdprConsent: { consentString: 'BN5lERiOMYEdiAKAWXEND1AAAAE6DABACMA', @@ -140,7 +156,7 @@ describe('yieldlabBidAdapter', function () { } } }) - const result = spec.interpretResponse({body: [RESPONSE]}, {validBidRequests: [VIDEO_REQUEST]}) + const result = spec.interpretResponse({body: [VIDEO_RESPONSE]}, {validBidRequests: [VIDEO_REQUEST]}) expect(result[0].requestId).to.equal('2d925f27f5079f') expect(result[0].cpm).to.equal(0.01) @@ -158,7 +174,7 @@ describe('yieldlabBidAdapter', function () { } } }) - const result = spec.interpretResponse({body: [RESPONSE]}, {validBidRequests: [OUTSTREAM_REQUEST]}) + const result = spec.interpretResponse({body: [VIDEO_RESPONSE]}, {validBidRequests: [OUTSTREAM_REQUEST]}) expect(result[0].renderer.id).to.equal('2d925f27f5079f') expect(result[0].renderer.url).to.equal('https://ad2.movad.net/dynamic.ad?a=o193092&ma_loadEvent=ma-start-event') diff --git a/test/spec/modules/yieldliftBidAdapter_spec.js b/test/spec/modules/yieldliftBidAdapter_spec.js new file mode 100644 index 00000000000..640a0f4e613 --- /dev/null +++ b/test/spec/modules/yieldliftBidAdapter_spec.js @@ -0,0 +1,257 @@ +import {expect} from 'chai'; +import {spec} from 'modules/yieldliftBidAdapter.js'; + +const REQUEST = { + 'bidderCode': 'yieldlift', + 'auctionId': 'auctionId-56a2-4f71-9098-720a68f2f708', + 'bidderRequestId': 'requestId', + 'bidRequest': [{ + 'bidder': 'yieldlift', + 'params': { + 'unitId': 123456, + }, + 'placementCode': 'div-gpt-dummy-placement-code', + 'mediaTypes': {'banner': {'sizes': [[300, 250]]}}, + 'bidId': 'bidId1', + 'bidderRequestId': 'bidderRequestId', + 'auctionId': 'auctionId-56a2-4f71-9098-720a68f2f708' + }, + { + 'bidder': 'yieldlift', + 'params': { + 'unitId': 123456, + }, + 'placementCode': 'div-gpt-dummy-placement-code', + 'mediaTypes': {'banner': {'sizes': [[300, 250]]}}, + 'bidId': 'bidId2', + 'bidderRequestId': 'bidderRequestId', + 'auctionId': 'auctionId-56a2-4f71-9098-720a68f2f708' + }], + 'start': 1487883186070, + 'auctionStart': 1487883186069, + 'timeout': 3000 +}; + +const RESPONSE = { + 'headers': null, + 'body': { + 'id': 'responseId', + 'seatbid': [ + { + 'bid': [ + { + 'id': 'bidId1', + 'impid': 'bidId1', + 'price': 0.18, + 'adm': '', + 'adid': '144762342', + 'adomain': [ + 'https://dummydomain.com' + ], + 'iurl': 'iurl', + 'cid': '109', + 'crid': 'creativeId', + 'cat': [], + 'w': 300, + 'h': 250, + 'ext': { + 'prebid': { + 'type': 'banner' + }, + 'bidder': { + 'appnexus': { + 'brand_id': 334553, + 'auction_id': 514667951122925701, + 'bidder_id': 2, + 'bid_ad_type': 0 + } + } + } + }, + { + 'id': 'bidId2', + 'impid': 'bidId2', + 'price': 0.1, + 'adm': '', + 'adid': '144762342', + 'adomain': [ + 'https://dummydomain.com' + ], + 'iurl': 'iurl', + 'cid': '109', + 'crid': 'creativeId', + 'cat': [], + 'w': 300, + 'h': 250, + 'ext': { + 'prebid': { + 'type': 'banner' + }, + 'bidder': { + 'appnexus': { + 'brand_id': 386046, + 'auction_id': 517067951122925501, + 'bidder_id': 2, + 'bid_ad_type': 0 + } + } + } + } + ], + 'seat': 'yieldlift' + } + ], + 'ext': { + 'usersync': { + 'sovrn': { + 'status': 'none', + 'syncs': [ + { + 'url': 'urlsovrn', + 'type': 'iframe' + } + ] + }, + 'appnexus': { + 'status': 'none', + 'syncs': [ + { + 'url': 'urlappnexus', + 'type': 'pixel' + } + ] + } + }, + 'responsetimemillis': { + 'appnexus': 127 + } + } + } +}; + +describe('YieldLift', function () { + describe('isBidRequestValid', function () { + it('should accept request if only unitId is passed', function () { + let bid = { + bidder: 'yieldlift', + params: { + unitId: 'unitId', + } + }; + expect(spec.isBidRequestValid(bid)).to.equal(true); + }); + it('should accept request if only networkId is passed', function () { + let bid = { + bidder: 'yieldlift', + params: { + networkId: 'networkId', + } + }; + expect(spec.isBidRequestValid(bid)).to.equal(true); + }); + it('should accept request if only publisherId is passed', function () { + let bid = { + bidder: 'yieldlift', + params: { + publisherId: 'publisherId', + } + }; + expect(spec.isBidRequestValid(bid)).to.equal(true); + }); + + it('reject requests without params', function () { + let bid = { + bidder: 'yieldlift', + params: {} + }; + expect(spec.isBidRequestValid(bid)).to.equal(false); + }); + }); + + describe('buildRequests', function () { + it('creates request data', function () { + let request = spec.buildRequests(REQUEST.bidRequest, REQUEST); + + expect(request).to.exist.and.to.be.a('object'); + const payload = JSON.parse(request.data); + expect(payload.imp[0]).to.have.property('id', REQUEST.bidRequest[0].bidId); + expect(payload.imp[1]).to.have.property('id', REQUEST.bidRequest[1].bidId); + }); + + it('has gdpr data if applicable', function () { + const req = Object.assign({}, REQUEST, { + gdprConsent: { + consentString: 'consentString', + gdprApplies: true, + } + }); + let request = spec.buildRequests(REQUEST.bidRequest, req); + + const payload = JSON.parse(request.data); + expect(payload.user.ext).to.have.property('consent', req.gdprConsent.consentString); + expect(payload.regs.ext).to.have.property('gdpr', 1); + }); + }); + + describe('interpretResponse', function () { + it('have bids', function () { + let bids = spec.interpretResponse(RESPONSE, REQUEST); + expect(bids).to.be.an('array').that.is.not.empty; + validateBidOnIndex(0); + validateBidOnIndex(1); + + function validateBidOnIndex(index) { + expect(bids[index]).to.have.property('currency', 'USD'); + expect(bids[index]).to.have.property('requestId', RESPONSE.body.seatbid[0].bid[index].impid); + expect(bids[index]).to.have.property('cpm', RESPONSE.body.seatbid[0].bid[index].price); + expect(bids[index]).to.have.property('width', RESPONSE.body.seatbid[0].bid[index].w); + expect(bids[index]).to.have.property('height', RESPONSE.body.seatbid[0].bid[index].h); + expect(bids[index]).to.have.property('ad', RESPONSE.body.seatbid[0].bid[index].adm); + expect(bids[index]).to.have.property('creativeId', RESPONSE.body.seatbid[0].bid[index].crid); + expect(bids[index]).to.have.property('ttl', 30); + expect(bids[index]).to.have.property('netRevenue', true); + } + }); + + it('handles empty response', function () { + const EMPTY_RESP = Object.assign({}, RESPONSE, {'body': {}}); + const bids = spec.interpretResponse(EMPTY_RESP, REQUEST); + + expect(bids).to.be.empty; + }); + }); + + describe('getUserSyncs', function () { + it('handles no parameters', function () { + let opts = spec.getUserSyncs({}); + expect(opts).to.be.an('array').that.is.empty; + }); + it('returns non if sync is not allowed', function () { + let opts = spec.getUserSyncs({iframeEnabled: false, pixelEnabled: false}); + + expect(opts).to.be.an('array').that.is.empty; + }); + + it('iframe sync enabled should return results', function () { + let opts = spec.getUserSyncs({iframeEnabled: true, pixelEnabled: false}, [RESPONSE]); + + expect(opts.length).to.equal(1); + expect(opts[0].type).to.equal('iframe'); + expect(opts[0].url).to.equal(RESPONSE.body.ext.usersync['sovrn'].syncs[0].url); + }); + + it('pixel sync enabled should return results', function () { + let opts = spec.getUserSyncs({iframeEnabled: false, pixelEnabled: true}, [RESPONSE]); + + expect(opts.length).to.equal(1); + expect(opts[0].type).to.equal('image'); + expect(opts[0].url).to.equal(RESPONSE.body.ext.usersync['appnexus'].syncs[0].url); + }); + + it('all sync enabled should return all results', function () { + let opts = spec.getUserSyncs({iframeEnabled: true, pixelEnabled: true}, [RESPONSE]); + + expect(opts.length).to.equal(2); + }); + }); +}); diff --git a/test/spec/modules/yieldmoBidAdapter_spec.js b/test/spec/modules/yieldmoBidAdapter_spec.js index 60fe25db95e..5904113bd42 100644 --- a/test/spec/modules/yieldmoBidAdapter_spec.js +++ b/test/spec/modules/yieldmoBidAdapter_spec.js @@ -1,32 +1,55 @@ import { expect } from 'chai'; -import { spec } from 'modules/yieldmoBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; -import * as utils from 'src/utils'; +import { spec } from 'modules/yieldmoBidAdapter.js'; +import { newBidder } from 'src/adapters/bidderFactory.js'; +import * as utils from 'src/utils.js'; describe('YieldmoAdapter', function () { const adapter = newBidder(spec); const ENDPOINT = 'https://ads.yieldmo.com/exchange/prebid'; let tdid = '8d146286-91d4-4958-aff4-7e489dd1abd6'; + let criteoId = 'aff4'; let bid = { bidder: 'yieldmo', params: { - bidFloor: 0.1 + bidFloor: 0.1, }, adUnitCode: 'adunit-code', - sizes: [[300, 250], [300, 600]], + mediaTypes: { + banner: { + sizes: [ + [300, 250], + [300, 600], + ], + }, + }, bidId: '30b31c1838de1e', bidderRequestId: '22edbae2733bf6', auctionId: '1d1a030790a475', crumbs: { - pubcid: 'c604130c-0144-4b63-9bf2-c2bd8c8d86da' + pubcid: 'c604130c-0144-4b63-9bf2-c2bd8c8d86da', }, userId: { tdid, - } + }, }; let bidArray = [bid]; + let bidderRequest = { + bidderCode: 'yieldmo', + auctionId: 'e3a336ad-2761-4a1c-b421-ecc7c5294a34', + bidderRequestId: '14c4ede8c693f', + bids: bidArray, + auctionStart: 1520001292880, + timeout: 3000, + start: 1520001292884, + doneCbCallCount: 0, + refererInfo: { + numIframes: 1, + reachedTop: true, + referer: 'yieldmo.com', + }, + }; describe('isBidRequestValid', function () { it('should return true when necessary information is found', function () { @@ -52,57 +75,66 @@ describe('YieldmoAdapter', function () { describe('buildRequests', function () { it('should attempt to send bid requests to the endpoint via GET', function () { - const request = spec.buildRequests(bidArray); + const request = spec.buildRequests(bidArray, bidderRequest); 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() - }) + let bidArray = [{ ...bid, crumbs: undefined }]; + expect(function () { + spec.buildRequests(bidArray, bidderRequest); + }).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}]'); - + let placementInfo = spec.buildRequests(bidArray, bidderRequest).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 + bidFloor: 0.2, }, adUnitCode: 'adunit-code-1', - sizes: [[300, 250], [300, 600]], + mediaTypes: { + banner: { + sizes: [ + [300, 250], + [300, 600], + ], + }, + }, bidId: '123456789', bidderRequestId: '987654321', auctionId: '0246810', crumbs: { - pubcid: 'c604130c-0144-4b63-9bf2-c2bd8c8d86da' - } - + 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}]'); + placementInfo = spec.buildRequests(bidArray, bidderRequest).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; + let placementInfo = spec.buildRequests(bidArray, bidderRequest).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; + placementInfo = spec.buildRequests(bidArray, bidderRequest).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; + const data = spec.buildRequests(bidArray, bidderRequest).data; expect(data.hasOwnProperty('page_url')).to.be.true; expect(data.hasOwnProperty('bust')).to.be.true; expect(data.hasOwnProperty('pr')).to.be.true; @@ -121,16 +153,25 @@ describe('YieldmoAdapter', function () { bidder: 'yieldmo', params: {}, adUnitCode: 'adunit-code', - sizes: [[300, 250], [300, 600]], + mediaTypes: { + banner: { + sizes: [ + [300, 250], + [300, 600], + ], + }, + }, bidId: '30b31c1838de1e', bidderRequestId: '22edbae2733bf6', auctionId: '1d1a030790a475', userId: { - pubcid: 'c604130c-0144-4b63-9bf2-c2bd8c8d86da2' - } + pubcid: 'c604130c-0144-4b63-9bf2-c2bd8c8d86da2', + }, }; - const data = spec.buildRequests([pubcidBid]).data; - expect(data.pubcid).to.deep.equal('c604130c-0144-4b63-9bf2-c2bd8c8d86da2'); + const data = spec.buildRequests([pubcidBid], bidderRequest).data; + expect(data.pubcid).to.deep.equal( + 'c604130c-0144-4b63-9bf2-c2bd8c8d86da2' + ); }); it('should add unified id as parameter of request', function () { @@ -138,17 +179,81 @@ describe('YieldmoAdapter', function () { bidder: 'yieldmo', params: {}, adUnitCode: 'adunit-code', - sizes: [[300, 250], [300, 600]], + mediaTypes: { + banner: { + sizes: [ + [300, 250], + [300, 600], + ], + }, + }, bidId: '30b31c1838de1e', bidderRequestId: '22edbae2733bf6', auctionId: '1d1a030790a475', userId: { tdid, - } + }, }; - const data = spec.buildRequests([unifiedIdBid]).data; + const data = spec.buildRequests([unifiedIdBid], bidderRequest).data; expect(data.tdid).to.deep.equal(tdid); }); + + it('should add CRITEO RTUS id as parameter of request', function () { + const criteoIdBid = { + bidder: 'yieldmo', + params: {}, + adUnitCode: 'adunit-code', + mediaTypes: { + banner: { + sizes: [ + [300, 250], + [300, 600], + ], + }, + }, + bidId: '30b31c1838de1e', + bidderRequestId: '22edbae2733bf6', + auctionId: '1d1a030790a475', + userId: { + criteoId, + }, + }; + const data = spec.buildRequests([criteoIdBid], bidderRequest).data; + expect(data.cri_prebid).to.deep.equal(criteoId); + }); + + it('should add gdpr information to request if available', () => { + bidderRequest.gdprConsent = { + consentString: 'BOJ/P2HOJ/P2HABABMAAAAAZ+A==', + vendorData: { blerp: 1 }, + gdprApplies: true, + }; + const data = spec.buildRequests(bidArray, bidderRequest).data; + expect(data.userConsent).equal( + JSON.stringify({ + gdprApplies: true, + cmp: 'BOJ/P2HOJ/P2HABABMAAAAAZ+A==', + }) + ); + }); + + it('should add ccpa information to request if available', () => { + const privacy = '1YNY'; + bidderRequest.us_privacy = privacy; + const data = spec.buildRequests(bidArray, bidderRequest).data; + expect(data.us_privacy).equal(privacy); + }); + + it('should add schain if it is in the bidRequest', () => { + const schain = { + ver: '1.0', + complete: 1, + nodes: [{ asi: 'indirectseller.com', sid: '00001', hp: 1 }], + }; + bidArray[0].schain = schain; + const request = spec.buildRequests([bidArray[0]], bidderRequest); + expect(request.data.schain).equal(JSON.stringify(schain)); + }); }); describe('interpretResponse', function () { @@ -156,17 +261,20 @@ describe('YieldmoAdapter', function () { beforeEach(function () { serverResponse = { - body: [{ - callback_id: '21989fdbef550a', - cpm: 3.45455, - width: 300, - height: 250, - ad: '
', - creative_id: '9874652394875' - }], - header: 'header?' + 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); @@ -180,7 +288,8 @@ describe('YieldmoAdapter', function () { currency: 'USD', netRevenue: true, ttl: 300, - ad: '
' + ad: + '
', }); }); @@ -191,7 +300,7 @@ describe('YieldmoAdapter', function () { serverResponse.body[0].cpm = null; response = spec.interpretResponse(serverResponse); - expect(response).to.deep.equal([]) + expect(response).to.deep.equal([]); }); }); @@ -199,15 +308,17 @@ describe('YieldmoAdapter', function () { const SYNC_ENDPOINT = 'https://static.yieldmo.com/blank.min.html?orig='; let options = { iframeEnabled: true, - pixelEnabled: 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() - }]); + expect(spec.getUserSync(options)).to.deep.equal([ + { + type: 'iframe', + url: SYNC_ENDPOINT + utils.getOrigin(), + }, + ]); options.iframeEnabled = false; 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 8f2e40d1810..00000000000 --- 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/yieldoneAnalyticsAdapter_spec.js b/test/spec/modules/yieldoneAnalyticsAdapter_spec.js index b7b4cd82b07..bc1001cc6c1 100644 --- a/test/spec/modules/yieldoneAnalyticsAdapter_spec.js +++ b/test/spec/modules/yieldoneAnalyticsAdapter_spec.js @@ -1,5 +1,5 @@ -import yieldoneAnalytics from 'modules/yieldoneAnalyticsAdapter'; -import { targeting } from 'src/targeting'; +import yieldoneAnalytics from 'modules/yieldoneAnalyticsAdapter.js'; +import { targeting } from 'src/targeting.js'; import { expect } from 'chai'; let events = require('src/events'); let adapterManager = require('src/adapterManager').default; @@ -113,6 +113,7 @@ describe('Yieldone Prebid Analytic', function () { const responses = [ { + ad: 'test ad content 1', width: 300, height: 250, statusMessage: 'Bid available', @@ -124,6 +125,7 @@ describe('Yieldone Prebid Analytic', function () { timeToRespond: 100 }, { + ad: 'test ad content 2', width: 336, height: 280, statusMessage: 'Bid available', @@ -135,6 +137,7 @@ describe('Yieldone Prebid Analytic', function () { timeToRespond: 100 }, { + ad: 'test ad content 3', width: 300, height: 250, statusMessage: 'Bid available', @@ -158,6 +161,7 @@ describe('Yieldone Prebid Analytic', function () { ]; const winner = { + ad: 'test ad content 3', width: 300, height: 250, statusMessage: 'Bid available', @@ -169,69 +173,83 @@ describe('Yieldone Prebid Analytic', function () { timeToRespond: 100 }; + const auctionEnd = { + auctionId: auctionId, + bidsReceived: responses.slice(0, 3) + }; + + const preparedResponses = responses.map((resp) => { + const res = Object.assign({}, resp); + delete res.ad; + return res; + }); + const expectedEvents = [ { eventType: constants.EVENTS.AUCTION_INIT, - page: {url: testReferrer}, params: { config: initOptions, - auctionId: auctionId, - pubId: initOptions.pubId + auctionId: auctionId } }, { eventType: constants.EVENTS.BID_REQUESTED, - page: {url: testReferrer}, - params: Object.assign({pubId: initOptions.pubId}, request[0]) + params: Object.assign(request[0]) }, { eventType: constants.EVENTS.BID_REQUESTED, - page: {url: testReferrer}, - params: Object.assign({pubId: initOptions.pubId}, request[1]) + params: Object.assign(request[1]) }, { eventType: constants.EVENTS.BID_REQUESTED, - page: {url: testReferrer}, - params: Object.assign({pubId: initOptions.pubId}, request[2]) + params: Object.assign(request[2]) }, { eventType: constants.EVENTS.BID_RESPONSE, - page: {url: testReferrer}, - params: Object.assign({pubId: initOptions.pubId}, responses[0]) + params: Object.assign(preparedResponses[0]) }, { eventType: constants.EVENTS.BID_RESPONSE, - page: {url: testReferrer}, - params: Object.assign({pubId: initOptions.pubId}, responses[1]) + params: Object.assign(preparedResponses[1]) }, { eventType: constants.EVENTS.BID_RESPONSE, - page: {url: testReferrer}, - params: Object.assign({pubId: initOptions.pubId}, responses[2]) + params: Object.assign(preparedResponses[2]) }, { eventType: constants.EVENTS.BID_TIMEOUT, - page: {url: testReferrer}, - params: Object.assign({pubId: initOptions.pubId}, request[2]) + params: Object.assign(request[2]) }, { eventType: constants.EVENTS.AUCTION_END, - page: {url: testReferrer}, params: { auctionId: auctionId, - pubId: initOptions.pubId, - adServerTargeting: fakeTargeting + adServerTargeting: fakeTargeting, + bidsReceived: preparedResponses.slice(0, 3) } } ]; + const expectedResult = { + pubId: initOptions.pubId, + page: {url: testReferrer}, + wrapper_version: '$prebid.version$', + events: expectedEvents + }; + const preparedWinnerParams = Object.assign({adServerTargeting: fakeTargeting}, winner); + delete preparedWinnerParams.ad; const wonExpectedEvents = [ { eventType: constants.EVENTS.BID_WON, - page: {url: testReferrer}, - params: Object.assign({pubId: initOptions.pubId, adServerTargeting: fakeTargeting}, winner) + params: preparedWinnerParams } ]; + const wonExpectedResult = { + pubId: initOptions.pubId, + page: {url: testReferrer}, + wrapper_version: '$prebid.version$', + events: wonExpectedEvents + }; adapterManager.enableAnalytics({ provider: 'yieldone', @@ -250,9 +268,9 @@ describe('Yieldone Prebid Analytic', function () { events.emit(constants.EVENTS.BID_TIMEOUT, [responses[3], responses[4]]); - events.emit(constants.EVENTS.AUCTION_END, {auctionId: auctionId}); + events.emit(constants.EVENTS.AUCTION_END, auctionEnd); - expect(yieldoneAnalytics.eventsStorage[auctionId]).to.deep.equal(expectedEvents); + expect(yieldoneAnalytics.eventsStorage[auctionId]).to.deep.equal(expectedResult); delete yieldoneAnalytics.eventsStorage[auctionId]; @@ -260,7 +278,7 @@ describe('Yieldone Prebid Analytic', function () { events.emit(constants.EVENTS.BID_WON, winner); sinon.assert.callCount(sendStatStub, 2); - expect(yieldoneAnalytics.eventsStorage[auctionId]).to.deep.equal(wonExpectedEvents); + expect(yieldoneAnalytics.eventsStorage[auctionId]).to.deep.equal(wonExpectedResult); delete yieldoneAnalytics.eventsStorage[auctionId]; done(); diff --git a/test/spec/modules/yieldoneBidAdapter_spec.js b/test/spec/modules/yieldoneBidAdapter_spec.js index abc579514ef..84065682297 100644 --- a/test/spec/modules/yieldoneBidAdapter_spec.js +++ b/test/spec/modules/yieldoneBidAdapter_spec.js @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import { spec } from 'modules/yieldoneBidAdapter'; -import { newBidder } from 'src/adapters/bidderFactory'; +import { spec } from 'modules/yieldoneBidAdapter.js'; +import { newBidder } from 'src/adapters/bidderFactory.js'; const ENDPOINT = 'https://y.one.impact-ad.jp/h_bid'; const USER_SYNC_URL = 'https://y.one.impact-ad.jp/push_sync'; @@ -64,7 +64,16 @@ describe('yieldoneBidAdapter', function() { } ]; - const request = spec.buildRequests(bidRequests); + let bidderRequest = { + refererInfo: { + numIframes: 0, + reachedTop: true, + referer: 'http://example.com', + stack: ['http://example.com'] + } + }; + + const request = spec.buildRequests(bidRequests, bidderRequest); it('sends bid request to our endpoint via GET', function () { expect(request[0].method).to.equal('GET'); @@ -85,7 +94,7 @@ describe('yieldoneBidAdapter', function() { const bidRequest = Object.assign({}, bidRequests[0]); bidRequest.mediaTypes = {}; bidRequest.mediaTypes.video = {context: 'outstream'}; - const request = spec.buildRequests([bidRequest]); + const request = spec.buildRequests([bidRequest], bidderRequest); expect(request[0].data.w).to.equal('300'); expect(request[0].data.h).to.equal('250'); }); diff --git a/test/spec/modules/yuktamediaAnalyticsAdaptor_spec.js b/test/spec/modules/yuktamediaAnalyticsAdaptor_spec.js index f6efa077f35..24a524c85c7 100644 --- a/test/spec/modules/yuktamediaAnalyticsAdaptor_spec.js +++ b/test/spec/modules/yuktamediaAnalyticsAdaptor_spec.js @@ -1,22 +1,18 @@ -import yuktamediaAnalyticsAdapter from 'modules/yuktamediaAnalyticsAdapter'; +import yuktamediaAnalyticsAdapter from 'modules/yuktamediaAnalyticsAdapter.js'; import { expect } from 'chai'; -let adapterManager = require('src/adapterManager').default; +import adapterManager from 'src/adapterManager.js'; +import * as utils from 'src/utils.js'; +import { server } from 'test/mocks/xhr.js'; + let events = require('src/events'); let constants = require('src/constants.json'); -describe('YuktaMedia analytics adapter', function () { - let xhr; - let requests; - +describe('yuktamedia analytics adapter', function () { beforeEach(function () { - xhr = sinon.useFakeXMLHttpRequest(); - requests = []; - xhr.onCreate = request => requests.push(request); sinon.stub(events, 'getEvents').returns([]); }); afterEach(function () { - xhr.restore(); events.getEvents.restore(); }); @@ -26,152 +22,767 @@ describe('YuktaMedia analytics adapter', function () { 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 = { + let prebidEvent = { + 'addAdUnits': {}, + 'requestBids': {}, + 'auctionInit': { + 'auctionId': 'db377024-d866-4a24-98ac-5e430f881313', + 'timestamp': 1576823893836, + 'auctionStatus': 'inProgress', + 'adUnits': [ + { + 'code': 'div-gpt-ad-1460505748561-0', + 'mediaTypes': { + 'banner': { + 'sizes': [ + [ + 300, + 250 + ], + [ + 300, + 600 + ] + ] + } + }, + 'bids': [ + { + 'bidder': 'appnexus', + 'params': { + 'placementId': 13144370 + }, + 'crumbs': { + 'pubcid': 'ff4002c4-ce05-4a61-b4ef-45a3cd93991a' + } + } + ], + 'sizes': [ + [ + 300, + 250 + ], + [ + 300, + 600 + ] + ], + 'transactionId': '6d275806-1943-4f3e-9cd5-624cbd05ad98' + } + ], + 'adUnitCodes': [ + 'div-gpt-ad-1460505748561-0' + ], + 'bidderRequests': [ + { + 'bidderCode': 'appnexus', + 'auctionId': 'db377024-d866-4a24-98ac-5e430f881313', + 'bidderRequestId': '155975c76e13b1', + 'bids': [ + { + 'bidder': 'appnexus', + 'params': { + 'placementId': 13144370 + }, + 'crumbs': { + 'pubcid': 'ff4002c4-ce05-4a61-b4ef-45a3cd93991a' + }, + 'mediaTypes': { + 'banner': { + 'sizes': [ + [ + 300, + 250 + ], + [ + 300, + 600 + ] + ] + } + }, + 'adUnitCode': 'div-gpt-ad-1460505748561-0', + 'transactionId': '6d275806-1943-4f3e-9cd5-624cbd05ad98', + 'sizes': [ + [ + 300, + 250 + ], + [ + 300, + 600 + ] + ], + 'bidId': '263efc09896d0c', + 'bidderRequestId': '155975c76e13b1', + 'auctionId': 'db377024-d866-4a24-98ac-5e430f881313', + 'src': 'client', + 'bidRequestsCount': 1, + 'bidderRequestsCount': 1, + 'bidderWinsCount': 0 + } + ], + 'auctionStart': 1576823893836, + 'timeout': 1000, + 'refererInfo': { + 'referer': 'http://observer.com/integrationExamples/gpt/hello_world.html', + 'reachedTop': true, + 'numIframes': 0, + 'stack': [ + 'http://observer.com/integrationExamples/gpt/hello_world.html' + ] + }, + 'start': 1576823893838 + } + ], + 'noBids': [], + 'bidsReceived': [], + 'winningBids': [], + 'timeout': 1000 + }, + 'bidRequested': { + 'bidderCode': 'appnexus', + 'auctionId': 'db377024-d866-4a24-98ac-5e430f881313', + 'bidderRequestId': '155975c76e13b1', + 'bids': [ + { + 'bidder': 'appnexus', + 'params': { + 'placementId': 13144370 + }, + 'crumbs': { + 'pubcid': 'ff4002c4-ce05-4a61-b4ef-45a3cd93991a' + }, + 'mediaTypes': { + 'banner': { + 'sizes': [ + [ + 300, + 250 + ], + [ + 300, + 600 + ] + ] + } + }, + 'adUnitCode': 'div-gpt-ad-1460505748561-0', + 'transactionId': '6d275806-1943-4f3e-9cd5-624cbd05ad98', + 'sizes': [ + [ + 300, + 250 + ], + [ + 300, + 600 + ] + ], + 'bidId': '263efc09896d0c', + 'bidderRequestId': '155975c76e13b1', + 'auctionId': 'db377024-d866-4a24-98ac-5e430f881313', + 'src': 'client', + 'bidRequestsCount': 1, + 'bidderRequestsCount': 1, + 'bidderWinsCount': 0 + } + ], + 'auctionStart': 1576823893836, + 'timeout': 1000, + 'refererInfo': { + 'referer': 'http://observer.com/integrationExamples/gpt/hello_world.html', + 'reachedTop': true, + 'numIframes': 0, + 'stack': [ + 'http://observer.com/integrationExamples/gpt/hello_world.html' + ] + }, + 'start': 1576823893838 + }, + 'bidAdjustment': { + 'bidderCode': 'appnexus', + 'width': 300, + 'height': 250, + 'statusMessage': 'Bid available', + 'adId': '393976d8770041', + 'requestId': '263efc09896d0c', + 'mediaType': 'banner', + 'source': 'client', + 'cpm': 0.5, + 'creativeId': 96846035, + 'currency': 'USD', + 'netRevenue': true, + 'ttl': 300, + 'adUnitCode': 'div-gpt-ad-1460505748561-0', + 'appnexus': { + 'buyerMemberId': 9325 + }, + 'meta': { + 'advertiserId': 2529885 + }, + 'ad': '', + 'originalCpm': 0.5, + 'originalCurrency': 'USD', + 'auctionId': 'db377024-d866-4a24-98ac-5e430f881313', + 'responseTimestamp': 1576823894050, + 'requestTimestamp': 1576823893838, + 'bidder': 'appnexus', + 'timeToRespond': 212 + }, + 'bidTimeout': [ + ], + 'bidResponse': { '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' + 'width': 300, + 'height': 250, + 'statusMessage': 'Bid available', + 'adId': '393976d8770041', + 'requestId': '263efc09896d0c', + 'mediaType': 'banner', + 'source': 'client', + 'cpm': 0.5, + 'creativeId': 96846035, + 'currency': 'USD', + 'netRevenue': true, + 'ttl': 300, + 'adUnitCode': 'div-gpt-ad-1460505748561-0', + 'appnexus': { + 'buyerMemberId': 9325 + }, + 'meta': { + 'advertiserId': 2529885 + }, + 'ad': '', + 'originalCpm': 0.5, + 'originalCurrency': 'USD', + 'auctionId': 'db377024-d866-4a24-98ac-5e430f881313', + 'responseTimestamp': 1576823894050, + 'requestTimestamp': 1576823893838, + 'bidder': 'appnexus', + 'timeToRespond': 212, + 'pbLg': '0.50', + 'pbMg': '0.50', + 'pbHg': '0.50', + 'pbAg': '0.50', + 'pbDg': '0.50', + 'pbCg': '', + 'size': '300x250', + 'adserverTargeting': { + 'hb_bidder': 'appnexus', + 'hb_adid': '393976d8770041', + 'hb_pb': '0.50', + 'hb_size': '300x250', + 'hb_source': 'client', + 'hb_format': 'banner' + } + }, + 'auctionEnd': { + 'auctionId': 'db377024-d866-4a24-98ac-5e430f881313', + 'timestamp': 1576823893836, + 'auctionEnd': 1576823894054, + 'auctionStatus': 'completed', + 'adUnits': [ + { + 'code': 'div-gpt-ad-1460505748561-0', + 'mediaTypes': { + 'banner': { + 'sizes': [ + [ + 300, + 250 + ], + [ + 300, + 600 + ] + ] + } + }, + 'bids': [ + { + 'bidder': 'appnexus', + 'params': { + 'placementId': 13144370 + }, + 'crumbs': { + 'pubcid': 'ff4002c4-ce05-4a61-b4ef-45a3cd93991a' + } + } + ], + 'sizes': [ + [ + 300, + 250 + ], + [ + 300, + 600 + ] + ], + 'transactionId': '6d275806-1943-4f3e-9cd5-624cbd05ad98' + } + ], + 'adUnitCodes': [ + 'div-gpt-ad-1460505748561-0' + ], + 'bidderRequests': [ + { + 'bidderCode': 'appnexus', + 'auctionId': 'db377024-d866-4a24-98ac-5e430f881313', + 'bidderRequestId': '155975c76e13b1', + 'bids': [ + { + 'bidder': 'appnexus', + 'params': { + 'placementId': 13144370 + }, + 'crumbs': { + 'pubcid': 'ff4002c4-ce05-4a61-b4ef-45a3cd93991a' + }, + 'mediaTypes': { + 'banner': { + 'sizes': [ + [ + 300, + 250 + ], + [ + 300, + 600 + ] + ] + } + }, + 'adUnitCode': 'div-gpt-ad-1460505748561-0', + 'transactionId': '6d275806-1943-4f3e-9cd5-624cbd05ad98', + 'sizes': [ + [ + 300, + 250 + ], + [ + 300, + 600 + ] + ], + 'bidId': '263efc09896d0c', + 'bidderRequestId': '155975c76e13b1', + 'auctionId': 'db377024-d866-4a24-98ac-5e430f881313', + 'src': 'client', + 'bidRequestsCount': 1, + 'bidderRequestsCount': 1, + 'bidderWinsCount': 0 + } + ], + 'auctionStart': 1576823893836, + 'timeout': 1000, + 'refererInfo': { + 'referer': 'http://observer.com/integrationExamples/gpt/hello_world.html', + 'reachedTop': true, + 'numIframes': 0, + 'stack': [ + 'http://observer.com/integrationExamples/gpt/hello_world.html' + ] + }, + 'start': 1576823893838 + } + ], + 'noBids': [], + 'bidsReceived': [ + { + 'bidderCode': 'appnexus', + 'width': 300, + 'height': 250, + 'statusMessage': 'Bid available', + 'adId': '393976d8770041', + 'requestId': '263efc09896d0c', + 'mediaType': 'banner', + 'source': 'client', + 'cpm': 0.5, + 'creativeId': 96846035, + 'currency': 'USD', + 'netRevenue': true, + 'ttl': 300, + 'adUnitCode': 'div-gpt-ad-1460505748561-0', + 'appnexus': { + 'buyerMemberId': 9325 + }, + 'meta': { + 'advertiserId': 2529885 + }, + 'ad': '', + 'originalCpm': 0.5, + 'originalCurrency': 'USD', + 'auctionId': 'db377024-d866-4a24-98ac-5e430f881313', + 'responseTimestamp': 1576823894050, + 'requestTimestamp': 1576823893838, + 'bidder': 'appnexus', + 'timeToRespond': 212, + 'pbLg': '0.50', + 'pbMg': '0.50', + 'pbHg': '0.50', + 'pbAg': '0.50', + 'pbDg': '0.50', + 'pbCg': '', + 'size': '300x250', + 'adserverTargeting': { + 'hb_bidder': 'appnexus', + 'hb_adid': '393976d8770041', + 'hb_pb': '0.50', + 'hb_size': '300x250', + 'hb_source': 'client', + 'hb_format': 'banner' + } + } + ], + 'winningBids': [], + 'timeout': 1000 + }, + 'setTargeting': { + 'div-gpt-ad-1460505748561-0': { + 'hb_format': 'banner', + 'hb_source': 'client', + 'hb_size': '300x250', + 'hb_pb': '0.50', + 'hb_adid': '393976d8770041', + 'hb_bidder': 'appnexus', + 'hb_format_appnexus': 'banner', + 'hb_source_appnexus': 'client', + 'hb_size_appnexus': '300x250', + 'hb_pb_appnexus': '0.50', + 'hb_adid_appnexus': '393976d8770041', + 'hb_bidder_appnexus': 'appnexus' } + }, + 'bidderDone': { + 'bidderCode': 'appnexus', + 'auctionId': 'db377024-d866-4a24-98ac-5e430f881313', + 'bidderRequestId': '155975c76e13b1', + 'bids': [ + { + 'bidder': 'appnexus', + 'params': { + 'placementId': 13144370 + }, + 'crumbs': { + 'pubcid': 'ff4002c4-ce05-4a61-b4ef-45a3cd93991a' + }, + 'mediaTypes': { + 'banner': { + 'sizes': [ + [ + 300, + 250 + ], + [ + 300, + 600 + ] + ] + } + }, + 'adUnitCode': 'div-gpt-ad-1460505748561-0', + 'transactionId': '6d275806-1943-4f3e-9cd5-624cbd05ad98', + 'sizes': [ + [ + 300, + 250 + ], + [ + 300, + 600 + ] + ], + 'bidId': '263efc09896d0c', + 'bidderRequestId': '155975c76e13b1', + 'auctionId': 'db377024-d866-4a24-98ac-5e430f881313', + 'src': 'client', + 'bidRequestsCount': 1, + 'bidderRequestsCount': 1, + 'bidderWinsCount': 0 + } ], - 'auctionStart': 1522265863591, - 'timeout': 3000, - 'start': 1522265863600, - 'doneCbCallCount': 1 - }; - let bidResponse = { + 'auctionStart': 1576823893836, + 'timeout': 1000, + 'refererInfo': { + 'referer': 'http://observer.com/integrationExamples/gpt/hello_world.html', + 'reachedTop': true, + 'numIframes': 0, + 'stack': [ + 'http://observer.com/integrationExamples/gpt/hello_world.html' + ] + }, + 'start': 1576823893838 + }, + 'bidWon': { + 'bidderCode': 'appnexus', + 'width': 300, 'height': 250, 'statusMessage': 'Bid available', - 'adId': '2eddfdc0c791dc', + 'adId': '393976d8770041', + 'requestId': '263efc09896d0c', 'mediaType': 'banner', 'source': 'client', - 'requestId': '2eddfdc0c791dc', 'cpm': 0.5, - 'creativeId': 29681110, + 'creativeId': 96846035, 'currency': 'USD', 'netRevenue': true, 'ttl': 300, - 'auctionId': 'a5b849e5-87d7-4205-8300-d063084fcfb7', - 'responseTimestamp': 1522265866110, - 'requestTimestamp': 1522265863600, + 'adUnitCode': 'div-gpt-ad-1460505748561-0', + 'appnexus': { + 'buyerMemberId': 9325 + }, + 'meta': { + 'advertiserId': 2529885 + }, + 'ad': '', + 'originalCpm': 0.5, + 'originalCurrency': 'USD', + 'auctionId': 'db377024-d866-4a24-98ac-5e430f881313', + 'responseTimestamp': 1576823894050, + 'requestTimestamp': 1576823893838, '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' + 'timeToRespond': 212, + 'pbLg': '0.50', + 'pbMg': '0.50', + 'pbHg': '0.50', + 'pbAg': '0.50', + 'pbDg': '0.50', + 'pbCg': '', + 'size': '300x250', + 'adserverTargeting': { + 'hb_bidder': 'appnexus', + 'hb_adid': '393976d8770041', + 'hb_pb': '0.50', + 'hb_size': '300x250', + 'hb_source': 'client', + 'hb_format': 'banner' }, + 'status': 'rendered', + 'params': [ + { + 'placementId': 13144370 + } + ] + } + }; + let location = utils.getWindowLocation(); + + let expectedAfterBid = { + 'bids': [ { - bidId: '6fe3b4c2c23092', - bidder: 'bidderTwo', - adUnitCode: '/19968336/header-bid-tag-0', - auctionId: '66529d4c-8998-47c2-ab3e-5b953490b98f' + 'adUnitCode': 'div-gpt-ad-1460505748561-0', + 'auctionId': 'db377024-d866-4a24-98ac-5e430f881313', + 'bidId': '263efc09896d0c', + 'bidderCode': 'appnexus', + 'cpm': 0.5, + 'creativeId': 96846035, + 'currency': 'USD', + 'mediaType': 'banner', + 'netRevenue': true, + 'renderStatus': 2, + 'requestId': '155975c76e13b1', + 'requestTimestamp': 1576823893838, + 'responseTimestamp': 1576823894050, + 'sizes': '300x250,300x600', + 'statusMessage': 'Bid available', + 'timeToRespond': 212 } - ]; - let bid = { + ], + 'auctionInit': { + 'host': location.host, + 'path': location.pathname, + 'search': location.search, + 'auctionId': 'db377024-d866-4a24-98ac-5e430f881313', + 'timestamp': 1576823893836, + 'auctionStatus': 'inProgress', + 'adUnits': [ + { + 'code': 'div-gpt-ad-1460505748561-0', + 'mediaTypes': { + 'banner': { + 'sizes': [ + [ + 300, + 250 + ], + [ + 300, + 600 + ] + ] + } + }, + 'bids': [ + { + 'bidder': 'appnexus', + 'params': { + 'placementId': 13144370 + }, + 'crumbs': { + 'pubcid': 'ff4002c4-ce05-4a61-b4ef-45a3cd93991a' + } + } + ], + 'sizes': [ + [ + 300, + 250 + ], + [ + 300, + 600 + ] + ], + 'transactionId': '6d275806-1943-4f3e-9cd5-624cbd05ad98' + } + ], + 'adUnitCodes': [ + 'div-gpt-ad-1460505748561-0' + ], + 'bidderRequests': [ + { + 'bidderCode': 'appnexus', + 'auctionId': 'db377024-d866-4a24-98ac-5e430f881313', + 'bidderRequestId': '155975c76e13b1', + 'bids': [ + { + 'bidder': 'appnexus', + 'params': { + 'placementId': 13144370 + }, + 'crumbs': { + 'pubcid': 'ff4002c4-ce05-4a61-b4ef-45a3cd93991a' + }, + 'mediaTypes': { + 'banner': { + 'sizes': [ + [ + 300, + 250 + ], + [ + 300, + 600 + ] + ] + } + }, + 'adUnitCode': 'div-gpt-ad-1460505748561-0', + 'transactionId': '6d275806-1943-4f3e-9cd5-624cbd05ad98', + 'sizes': [ + [ + 300, + 250 + ], + [ + 300, + 600 + ] + ], + 'bidId': '263efc09896d0c', + 'bidderRequestId': '155975c76e13b1', + 'auctionId': 'db377024-d866-4a24-98ac-5e430f881313', + 'src': 'client', + 'bidRequestsCount': 1, + 'bidderRequestsCount': 1, + 'bidderWinsCount': 0 + } + ], + 'auctionStart': 1576823893836, + 'timeout': 1000, + 'refererInfo': { + 'referer': 'http://observer.com/integrationExamples/gpt/hello_world.html', + 'reachedTop': true, + 'numIframes': 0, + 'stack': [ + 'http://observer.com/integrationExamples/gpt/hello_world.html' + ] + }, + 'start': 1576823893838 + } + ], + 'noBids': [], + 'bidsReceived': [], + 'winningBids': [], + 'timeout': 1000, + 'config': initOptions + }, + 'initOptions': initOptions + }; + + let expectedAfterBidWon = { + 'bidWon': { '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, + 'bidId': '263efc09896d0c', + 'adUnitCode': 'div-gpt-ad-1460505748561-0', + 'auctionId': 'db377024-d866-4a24-98ac-5e430f881313', + 'creativeId': 96846035, 'currency': 'USD', - 'mediaType': 'banner', + 'cpm': 0.5, 'netRevenue': true, - 'requestTimestamp': 1522265863600, - 'responseTimestamp': 1522265866110, - 'sizes': '300x250,300x600', + 'renderedSize': '300x250', + 'mediaType': 'banner', 'statusMessage': 'Bid available', - 'timeToRespond': 2510 + 'status': 'rendered', + 'renderStatus': 4, + 'timeToRespond': 212, + 'requestTimestamp': 1576823893838, + 'responseTimestamp': 1576823894050 + }, + 'initOptions': { + 'pubId': '1', + 'pubKey': 'ZXlKaGJHY2lPaUpJVXpJMU5pSjkuT==' } + } - // Step 1: Send auction init event - events.emit(constants.EVENTS.AUCTION_INIT, { - timestamp: auctionTimestamp + 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 () { + // Step 1: Send auction init event + events.emit(constants.EVENTS.AUCTION_INIT, prebidEvent['auctionInit']); // Step 2: Send bid requested event - events.emit(constants.EVENTS.BID_REQUESTED, bidRequest); + events.emit(constants.EVENTS.BID_REQUESTED, prebidEvent['bidRequested']); // Step 3: Send bid response event - events.emit(constants.EVENTS.BID_RESPONSE, bidResponse); + events.emit(constants.EVENTS.BID_RESPONSE, prebidEvent['bidResponse']); // Step 4: Send bid time out event - events.emit(constants.EVENTS.BID_TIMEOUT, bidTimeoutArgsV1); + events.emit(constants.EVENTS.BID_TIMEOUT, prebidEvent['bidTimeout']); // Step 5: Send auction end event - events.emit(constants.EVENTS.AUCTION_END, {}, 'auctionEnd'); - - expect(requests.length).to.equal(1); + events.emit(constants.EVENTS.AUCTION_END, prebidEvent['auctionEnd']); - let auctionEventData = JSON.parse(requests[0].requestBody); + expect(server.requests.length).to.equal(1); - expect(auctionEventData.bids.length).to.equal(1); - expect(auctionEventData.bids[0]).to.deep.equal(bid); + let realAfterBid = JSON.parse(server.requests[0].requestBody); - expect(auctionEventData.initOptions).to.deep.equal(initOptions); + expect(realAfterBid).to.deep.equal(expectedAfterBid); // 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'); + events.emit(constants.EVENTS.BID_WON, prebidEvent['bidWon']); - expect(requests.length).to.equal(2); + expect(server.requests.length).to.equal(2); - let winEventData = JSON.parse(requests[1].requestBody); + let winEventData = JSON.parse(server.requests[1].requestBody); - expect(winEventData.bidWon.status).to.equal('rendered'); - expect(winEventData.initOptions).to.deep.equal(initOptions); + expect(winEventData).to.deep.equal(expectedAfterBidWon); }); }); }); diff --git a/test/spec/modules/zedoBidAdapter_spec.js b/test/spec/modules/zedoBidAdapter_spec.js deleted file mode 100644 index f6702e6f459..00000000000 --- 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/native_spec.js b/test/spec/native_spec.js index 824f8686464..cd58dcb2cf7 100644 --- a/test/spec/native_spec.js +++ b/test/spec/native_spec.js @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import { fireNativeTrackers, getNativeTargeting, nativeBidIsValid, getAssetMessage } from 'src/native'; +import { fireNativeTrackers, getNativeTargeting, nativeBidIsValid, getAssetMessage } from 'src/native.js'; import CONSTANTS from 'src/constants.json'; const utils = require('src/utils'); diff --git a/test/spec/refererDetection_spec.js b/test/spec/refererDetection_spec.js index b2ef4e2058f..90892d915fe 100644 --- a/test/spec/refererDetection_spec.js +++ b/test/spec/refererDetection_spec.js @@ -1,4 +1,4 @@ -import { detectReferer } from 'src/refererDetection'; +import { detectReferer } from 'src/refererDetection.js'; import { expect } from 'chai'; var mocks = { diff --git a/test/spec/renderer_spec.js b/test/spec/renderer_spec.js index f9a670c1315..2688c6437fe 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 { Renderer } from 'src/Renderer.js'; +import * as utils from 'src/utils.js'; +import { loadExternalScript } from 'src/adloader.js'; 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/sizeMapping_spec.js b/test/spec/sizeMapping_spec.js index 254dcb8003e..b6b8c00ada3 100644 --- a/test/spec/sizeMapping_spec.js +++ b/test/spec/sizeMapping_spec.js @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import { resolveStatus, setSizeConfig, sizeSupported } from 'src/sizeMapping'; -import includes from 'core-js/library/fn/array/includes'; +import { resolveStatus, setSizeConfig, sizeSupported } from 'src/sizeMapping.js'; +import includes from 'core-js/library/fn/array/includes.js'; let utils = require('src/utils'); let deepClone = utils.deepClone; diff --git a/test/spec/unit/adServerManager_spec.js b/test/spec/unit/adServerManager_spec.js index 4ae475ac013..ec58ff7f5b3 100644 --- a/test/spec/unit/adServerManager_spec.js +++ b/test/spec/unit/adServerManager_spec.js @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import { getGlobal } from 'src/prebidGlobal'; -import { registerVideoSupport } from 'src/adServerManager'; +import { getGlobal } from 'src/prebidGlobal.js'; +import { registerVideoSupport } from 'src/adServerManager.js'; const prebid = getGlobal(); diff --git a/test/spec/unit/adUnits_spec.js b/test/spec/unit/adUnits_spec.js index fb666feb9b8..a8443d36522 100644 --- a/test/spec/unit/adUnits_spec.js +++ b/test/spec/unit/adUnits_spec.js @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import { adunitCounter } from 'src/adUnits'; +import { adunitCounter } from 'src/adUnits.js'; describe('Adunit Counter', function () { const ADUNIT_ID_1 = 'test1'; diff --git a/test/spec/unit/core/adapterManager_spec.js b/test/spec/unit/core/adapterManager_spec.js index e94824fb791..f0b6b03952e 100644 --- a/test/spec/unit/core/adapterManager_spec.js +++ b/test/spec/unit/core/adapterManager_spec.js @@ -1,19 +1,19 @@ import { expect } from 'chai'; -import adapterManager, { gdprDataHandler } from 'src/adapterManager'; +import adapterManager, { gdprDataHandler } from 'src/adapterManager.js'; import { getAdUnits, getServerTestingConfig, getServerTestingsAds, getBidRequests -} from 'test/fixtures/fixtures'; +} from 'test/fixtures/fixtures.js'; import CONSTANTS from 'src/constants.json'; -import * as utils from 'src/utils'; -import { config } from 'src/config'; -import { registerBidder } from 'src/adapters/bidderFactory'; -import { setSizeConfig } from 'src/sizeMapping'; -import find from 'core-js/library/fn/array/find'; -import includes from 'core-js/library/fn/array/includes'; -import s2sTesting from 'modules/s2sTesting'; +import * as utils from 'src/utils.js'; +import { config } from 'src/config.js'; +import { registerBidder } from 'src/adapters/bidderFactory.js'; +import { setSizeConfig } from 'src/sizeMapping.js'; +import find from 'core-js/library/fn/array/find.js'; +import includes from 'core-js/library/fn/array/includes.js'; +import s2sTesting from 'modules/s2sTesting.js'; var events = require('../../../../src/events'); const CONFIG = { @@ -43,16 +43,23 @@ var rubiconAdapterMock = { callBids: sinon.stub() }; +var badAdapterMock = { + bidder: 'badBidder', + callBids: sinon.stub().throws(Error('some fake error')) +}; + describe('adapterManager tests', function () { let orgAppnexusAdapter; let orgAdequantAdapter; let orgPrebidServerAdapter; let orgRubiconAdapter; + let orgBadBidderAdapter; before(function () { orgAppnexusAdapter = adapterManager.bidderRegistry['appnexus']; orgAdequantAdapter = adapterManager.bidderRegistry['adequant']; orgPrebidServerAdapter = adapterManager.bidderRegistry['prebidServer']; orgRubiconAdapter = adapterManager.bidderRegistry['rubicon']; + orgBadBidderAdapter = adapterManager.bidderRegistry['badBidder']; }); after(function () { @@ -60,6 +67,7 @@ describe('adapterManager tests', function () { adapterManager.bidderRegistry['adequant'] = orgAdequantAdapter; adapterManager.bidderRegistry['prebidServer'] = orgPrebidServerAdapter; adapterManager.bidderRegistry['rubicon'] = orgRubiconAdapter; + adapterManager.bidderRegistry['badBidder'] = orgBadBidderAdapter; config.setConfig({s2sConfig: { enabled: false }}); }); @@ -72,11 +80,16 @@ describe('adapterManager tests', function () { sinon.stub(utils, 'logError'); appnexusAdapterMock.callBids.reset(); adapterManager.bidderRegistry['appnexus'] = appnexusAdapterMock; + adapterManager.bidderRegistry['rubicon'] = rubiconAdapterMock; + adapterManager.bidderRegistry['badBidder'] = badAdapterMock; }); afterEach(function () { utils.logError.restore(); delete adapterManager.bidderRegistry['appnexus']; + delete adapterManager.bidderRegistry['rubicon']; + delete adapterManager.bidderRegistry['badBidder']; + config.resetConfig(); }); it('should log an error if a bidder is used that does not exist', function () { @@ -95,6 +108,34 @@ describe('adapterManager tests', function () { sinon.assert.called(utils.logError); }); + it('should catch a bidder adapter thrown error and continue with other bidders', function () { + const adUnits = [{ + code: 'adUnit-code', + sizes: [[728, 90]], + bids: [ + {bidder: 'appnexus', params: {placementId: 'id'}}, + {bidder: 'badBidder', params: {placementId: 'id'}}, + {bidder: 'rubicon', params: {account: 1111, site: 2222, zone: 3333}} + ] + }]; + let bidRequests = adapterManager.makeBidRequests(adUnits, 1111, 2222, 1000); + + let doneBidders = []; + function mockDoneCB() { + doneBidders.push(this.bidderCode) + } + adapterManager.callBids(adUnits, bidRequests, () => {}, mockDoneCB); + sinon.assert.calledOnce(appnexusAdapterMock.callBids); + sinon.assert.calledOnce(badAdapterMock.callBids); + sinon.assert.calledOnce(rubiconAdapterMock.callBids); + + expect(utils.logError.calledOnce).to.be.true; + expect(utils.logError.calledWith( + 'badBidder Bid Adapter emitted an uncaught error when parsing their bidRequest' + )).to.be.true; + // done should be called for our bidder! + expect(doneBidders.indexOf('badBidder') === -1).to.be.false; + }); it('should emit BID_REQUESTED event', function () { // function to count BID_REQUESTED events let cnt = 0; @@ -175,7 +216,7 @@ describe('adapterManager tests', function () { buildRequests: { data: 1 }, - test1: { speedy: true }, + test1: { speedy: true, fun: { test: true } }, interpretResponse: 'baseInterpret', afterInterpretResponse: 'anotherBaseInterpret' }); @@ -212,7 +253,7 @@ describe('adapterManager tests', function () { data: 1, test: 2 }, - { fun: { safe: true, cheap: false }, speedy: true }, + { fun: { safe: true, cheap: false, test: true }, speedy: true }, { amazing: true }, 'appnexusInterpret', 'anotherBaseInterpret' @@ -221,14 +262,14 @@ describe('adapterManager tests', function () { { data: 1 }, - { speedy: true }, + { fun: { test: true }, speedy: true }, undefined, 'baseInterpret', 'anotherBaseInterpret' ], 'rubicon': [ 'rubiconBuild', - { speedy: true }, + { fun: { test: true }, speedy: true }, { amazing: true }, null, 'anotherBaseInterpret' diff --git a/test/spec/unit/core/bidderFactory_spec.js b/test/spec/unit/core/bidderFactory_spec.js index e8ddf52c128..6d0595ba4d8 100644 --- a/test/spec/unit/core/bidderFactory_spec.js +++ b/test/spec/unit/core/bidderFactory_spec.js @@ -1,11 +1,11 @@ -import { newBidder, registerBidder, preloadBidderMappingFile } from 'src/adapters/bidderFactory'; -import adapterManager from 'src/adapterManager'; -import * as ajax from 'src/ajax'; +import { newBidder, registerBidder, preloadBidderMappingFile, storage } from 'src/adapters/bidderFactory.js'; +import adapterManager from 'src/adapterManager.js'; +import * as ajax from 'src/ajax.js'; import { expect } from 'chai'; -import { STATUS } from 'src/constants'; -import { userSync } from 'src/userSync' -import * as utils from 'src/utils'; -import { config } from 'src/config'; +import { userSync } from 'src/userSync.js' +import * as utils from 'src/utils.js'; +import { config } from 'src/config.js'; +import { server } from 'test/mocks/xhr.js'; const CODE = 'sampleBidder'; const MOCK_BIDS_REQUEST = { @@ -56,15 +56,66 @@ describe('bidders created by newBidder', function () { describe('when the ajax response is irrelevant', function () { let ajaxStub; + let getConfigSpy; beforeEach(function () { ajaxStub = sinon.stub(ajax, 'ajax'); addBidResponseStub.reset(); + getConfigSpy = sinon.spy(config, 'getConfig'); doneStub.reset(); }); afterEach(function () { ajaxStub.restore(); + getConfigSpy.restore(); + }); + + it('should let registerSyncs run with invalid alias and aliasSync enabled', function () { + config.setConfig({ + userSync: { + aliasSyncEnabled: true + } + }); + spec.code = 'fakeBidder'; + const bidder = newBidder(spec); + bidder.callBids({ bids: [] }, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); + expect(getConfigSpy.withArgs('userSync.filterSettings').calledOnce).to.equal(true); + }); + + it('should let registerSyncs run with valid alias and aliasSync enabled', function () { + config.setConfig({ + userSync: { + aliasSyncEnabled: true + } + }); + spec.code = 'aliasBidder'; + const bidder = newBidder(spec); + bidder.callBids({ bids: [] }, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); + expect(getConfigSpy.withArgs('userSync.filterSettings').calledOnce).to.equal(true); + }); + + it('should let registerSyncs run with invalid alias and aliasSync disabled', function () { + config.setConfig({ + userSync: { + aliasSyncEnabled: false + } + }); + spec.code = 'fakeBidder'; + const bidder = newBidder(spec); + bidder.callBids({ bids: [] }, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); + expect(getConfigSpy.withArgs('userSync.filterSettings').calledOnce).to.equal(true); + }); + + it('should not let registerSyncs run with valid alias and aliasSync disabled', function () { + config.setConfig({ + userSync: { + aliasSyncEnabled: false + } + }); + spec.code = 'aliasBidder'; + const bidder = newBidder(spec); + bidder.callBids({ bids: [] }, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); + expect(getConfigSpy.withArgs('userSync.filterSettings').calledOnce).to.equal(false); }); it('should handle bad bid requests gracefully', function () { @@ -196,7 +247,7 @@ describe('bidders created by newBidder', function () { bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); expect(ajaxStub.calledOnce).to.equal(true); - expect(ajaxStub.firstCall.args[0]).to.equal(`${url}?arg=2&`); + expect(ajaxStub.firstCall.args[0]).to.equal(`${url}?arg=2`); expect(ajaxStub.firstCall.args[2]).to.be.undefined; expect(ajaxStub.firstCall.args[3]).to.deep.equal({ method: 'GET', @@ -220,7 +271,7 @@ describe('bidders created by newBidder', function () { bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); expect(ajaxStub.calledOnce).to.equal(true); - expect(ajaxStub.firstCall.args[0]).to.equal(`${url}?arg=2&`); + expect(ajaxStub.firstCall.args[0]).to.equal(`${url}?arg=2`); expect(ajaxStub.firstCall.args[2]).to.be.undefined; expect(ajaxStub.firstCall.args[3]).to.deep.equal({ method: 'GET', @@ -792,8 +843,8 @@ describe('preload mapping url hook', function() { let adapterManagerStub; beforeEach(function () { - fakeTranslationServer = sinon.fakeServer.create(); - getLocalStorageStub = sinon.stub(utils, 'getDataFromLocalStorage'); + fakeTranslationServer = server; + getLocalStorageStub = sinon.stub(storage, 'getDataFromLocalStorage'); adapterManagerStub = sinon.stub(adapterManager, 'getBidAdapter'); }); diff --git a/test/spec/unit/core/storageManager_spec.js b/test/spec/unit/core/storageManager_spec.js new file mode 100644 index 00000000000..0b406242f90 --- /dev/null +++ b/test/spec/unit/core/storageManager_spec.js @@ -0,0 +1,46 @@ +import { resetData, getCoreStorageManager, storageCallbacks, getStorageManager } from 'src/storageManager.js'; +import { config } from 'src/config.js'; +import * as utils from 'src/utils.js'; + +describe('storage manager', function() { + beforeEach(function() { + resetData(); + }); + + afterEach(function() { + config.resetConfig(); + }) + + it('should allow to set cookie for core modules without checking gdpr enforcements', function() { + const coreStorage = getCoreStorageManager(); + let date = new Date(); + date.setTime(date.getTime() + (24 * 60 * 60 * 1000)); + let expires = date.toUTCString(); + coreStorage.setCookie('hello', 'world', expires); + expect(coreStorage.getCookie('hello')).to.equal('world'); + }); + + it('should add done callbacks to storageCallbacks array', function() { + let noop = sinon.spy(); + const coreStorage = getStorageManager(); + + coreStorage.setCookie('foo', 'bar', null, null, null, noop); + coreStorage.getCookie('foo', noop); + coreStorage.localStorageIsEnabled(noop); + coreStorage.cookiesAreEnabled(noop); + coreStorage.setDataInLocalStorage('foo', 'bar', noop); + coreStorage.getDataFromLocalStorage('foo', noop); + coreStorage.removeDataFromLocalStorage('foo', noop); + coreStorage.hasLocalStorage(noop); + + expect(storageCallbacks.length).to.equal(8); + }); + + it('should allow bidder to access device if gdpr enforcement module is not included', function() { + let deviceAccessSpy = sinon.spy(utils, 'hasDeviceAccess'); + const storage = getStorageManager(); + storage.setCookie('foo1', 'baz1'); + expect(deviceAccessSpy.calledOnce).to.equal(true); + deviceAccessSpy.restore(); + }) +}); diff --git a/test/spec/unit/core/targeting_spec.js b/test/spec/unit/core/targeting_spec.js index 753eb39d88c..4640e97ab4d 100644 --- a/test/spec/unit/core/targeting_spec.js +++ b/test/spec/unit/core/targeting_spec.js @@ -1,10 +1,10 @@ import { expect } from 'chai'; -import { targeting as targetingInstance, filters, sortByDealAndPriceBucket } from 'src/targeting'; -import { config } from 'src/config'; -import { getAdUnits, createBidReceived } from 'test/fixtures/fixtures'; +import { targeting as targetingInstance, filters, sortByDealAndPriceBucketOrCpm } from 'src/targeting.js'; +import { config } from 'src/config.js'; +import { getAdUnits, createBidReceived } from 'test/fixtures/fixtures.js'; import CONSTANTS from 'src/constants.json'; -import { auctionManager } from 'src/auctionManager'; -import * as utils from 'src/utils'; +import { auctionManager } from 'src/auctionManager.js'; +import * as utils from 'src/utils.js'; const bid1 = { 'bidderCode': 'rubicon', @@ -687,7 +687,7 @@ describe('targeting tests', function () { }); }); - describe('sortByDealAndPriceBucket', function() { + describe('sortByDealAndPriceBucketOrCpm', function() { it('will properly sort bids when some bids have deals and some do not', function () { let bids = [{ adUnitTargeting: { @@ -723,7 +723,7 @@ describe('targeting tests', function () { hb_pb: '100.00', } }]; - bids.sort(sortByDealAndPriceBucket); + bids.sort(sortByDealAndPriceBucketOrCpm()); expect(bids[0].adUnitTargeting.hb_adid).to.equal('ghi'); expect(bids[1].adUnitTargeting.hb_adid).to.equal('jkl'); expect(bids[2].adUnitTargeting.hb_adid).to.equal('abc'); @@ -758,7 +758,7 @@ describe('targeting tests', function () { hb_deal: '9864' } }]; - bids.sort(sortByDealAndPriceBucket); + bids.sort(sortByDealAndPriceBucketOrCpm()); expect(bids[0].adUnitTargeting.hb_adid).to.equal('ghi'); expect(bids[1].adUnitTargeting.hb_adid).to.equal('jkl'); expect(bids[2].adUnitTargeting.hb_adid).to.equal('abc'); @@ -797,7 +797,7 @@ describe('targeting tests', function () { hb_pb: '100.00' } }]; - bids.sort(sortByDealAndPriceBucket); + bids.sort(sortByDealAndPriceBucketOrCpm()); expect(bids[0].adUnitTargeting.hb_adid).to.equal('pqr'); expect(bids[1].adUnitTargeting.hb_adid).to.equal('jkl'); expect(bids[2].adUnitTargeting.hb_adid).to.equal('ghi'); @@ -805,6 +805,57 @@ describe('targeting tests', function () { expect(bids[4].adUnitTargeting.hb_adid).to.equal('mno'); expect(bids[5].adUnitTargeting.hb_adid).to.equal('def'); }); + + it('will properly sort bids when some bids have deals and some do not and by cpm when flag is set to true', function () { + let bids = [{ + cpm: 1.04, + adUnitTargeting: { + hb_adid: 'abc', + hb_pb: '1.00', + hb_deal: '1234' + } + }, { + cpm: 0.50, + adUnitTargeting: { + hb_adid: 'def', + hb_pb: '0.50', + hb_deal: '4532' + } + }, { + cpm: 0.53, + adUnitTargeting: { + hb_adid: 'ghi', + hb_pb: '0.50', + hb_deal: '4532' + } + }, { + cpm: 9.04, + adUnitTargeting: { + hb_adid: 'jkl', + hb_pb: '9.00', + hb_deal: '9864' + } + }, { + cpm: 50.00, + adUnitTargeting: { + hb_adid: 'mno', + hb_pb: '50.00', + } + }, { + cpm: 100.00, + adUnitTargeting: { + hb_adid: 'pqr', + hb_pb: '100.00', + } + }]; + bids.sort(sortByDealAndPriceBucketOrCpm(true)); + expect(bids[0].adUnitTargeting.hb_adid).to.equal('jkl'); + expect(bids[1].adUnitTargeting.hb_adid).to.equal('abc'); + expect(bids[2].adUnitTargeting.hb_adid).to.equal('ghi'); + expect(bids[3].adUnitTargeting.hb_adid).to.equal('def'); + expect(bids[4].adUnitTargeting.hb_adid).to.equal('pqr'); + expect(bids[5].adUnitTargeting.hb_adid).to.equal('mno'); + }); }); describe('setTargetingForAst', function () { diff --git a/test/spec/unit/pbjs_api_spec.js b/test/spec/unit/pbjs_api_spec.js index 485dd5cf077..252c074cd61 100644 --- a/test/spec/unit/pbjs_api_spec.js +++ b/test/spec/unit/pbjs_api_spec.js @@ -7,14 +7,15 @@ import { getTargetingKeysBidLandscape, getAdUnits, createBidReceived -} from 'test/fixtures/fixtures'; -import { auctionManager, newAuctionManager } from 'src/auctionManager'; -import { targeting, newTargeting, filters } from 'src/targeting'; -import { config as configObj } from 'src/config'; -import * as ajaxLib from 'src/ajax'; -import * as auctionModule from 'src/auction'; -import { newBidder, registerBidder } from 'src/adapters/bidderFactory'; -import find from 'core-js/library/fn/array/find'; +} from 'test/fixtures/fixtures.js'; +import { auctionManager, newAuctionManager } from 'src/auctionManager.js'; +import { targeting, newTargeting, filters } from 'src/targeting.js'; +import { config as configObj } from 'src/config.js'; +import * as ajaxLib from 'src/ajax.js'; +import * as auctionModule from 'src/auction.js'; +import { newBidder, registerBidder } from 'src/adapters/bidderFactory.js'; +import { _sendAdToCreative } from 'src/secureCreatives.js'; +import find from 'core-js/library/fn/array/find.js'; var assert = require('chai').assert; var expect = require('chai').expect; @@ -56,7 +57,7 @@ function resetAuction() { var Slot = function Slot(elementId, pathId) { var slot = { - targeting: [], + targeting: {}, getSlotElementId: function getSlotElementId() { return elementId; }, @@ -66,24 +67,24 @@ var Slot = function Slot(elementId, pathId) { }, setTargeting: function setTargeting(key, value) { - var obj = []; - obj[key] = value; - this.targeting.push(obj); + this.targeting[key] = Array.isArray(value) ? value : [value]; }, - getTargeting: function getTargeting() { - return this.targeting; + getTargeting: function getTargeting(key) { + return this.targeting[key] || []; }, getTargetingKeys: function getTargetingKeys() { - return []; + return Object.getOwnPropertyNames(this.targeting); }, clearTargeting: function clearTargeting() { - return googletag.pubads().getSlots(); + this.targeting = {}; + return this; } }; slot.spySetTargeting = sinon.spy(slot, 'setTargeting'); + slot.spyGetSlotElementId = sinon.spy(slot, 'getSlotElementId'); return slot; }; @@ -121,11 +122,15 @@ window.googletag = { }, setTargeting: function(key, arrayOfValues) { - self._targeting[key] = arrayOfValues; + self._targeting[key] = Array.isArray(arrayOfValues) ? arrayOfValues : [arrayOfValues]; }, - getTargeting: function() { - return self._targeting; + getTargeting: function(key) { + return self._targeting[key] || []; + }, + + getTargetingKeys: function() { + return Object.getOwnPropertyNames(self._targeting); }, clearTargeting: function() { @@ -406,10 +411,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 +705,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', @@ -856,17 +861,57 @@ describe('Unit: Prebid Module', function () { it('should set googletag targeting keys after calling setTargetingForGPTAsync function', function () { var slots = createSlotArrayScenario2(); window.googletag.pubads().setSlots(slots); - $$PREBID_GLOBAL$$.setTargetingForGPTAsync(); + $$PREBID_GLOBAL$$.setTargetingForGPTAsync([config.adUnitCodes[0]]); + + // we need to transform the spySetTargeting into something that looks like + // googletag's targeting structure + // googletag setTargeting will override old value if invoked with same key + + const targeting = []; + slots[1].getTargetingKeys().map(function (key) { + const value = slots[1].getTargeting(key); + targeting.push([key, value]); + }); + + var invokedTargetingMap = {}; + slots[1].spySetTargeting.args.map(function (entry) { + invokedTargetingMap[entry[0]] = entry[1]; + }); + + var invokedTargeting = []; + + Object.getOwnPropertyNames(invokedTargetingMap).map(function (key) { + const value = Array.isArray(invokedTargetingMap[key]) ? invokedTargetingMap[key] : [invokedTargetingMap[key]]; // values are always returned as array in googletag + invokedTargeting.push([key, value]); + }); + assert.deepEqual(targeting, invokedTargeting, 'google tag targeting options not matching'); + }); + + it('should set googletag targeting keys to specific slot with customSlotMatching', function () { + // same ad unit code but two differnt divs + // we make sure we can set targeting for a specific one with customSlotMatching + + $$PREBID_GLOBAL$$.setConfig({ enableSendAllBids: false }); + + var slots = [ + new Slot('div-id-one', config.adUnitCodes[0]), + new Slot('div-id-two', config.adUnitCodes[0]), + new Slot(config.adUnitElementIDs[2], config.adUnitCodes[2]) + ]; - var targeting = []; - slots[1].getTargeting().map(function (value) { - var temp = []; - temp.push(Object.keys(value).toString()); - temp.push(value[Object.keys(value)]); - targeting.push(temp); + slots[0].spySetTargeting.resetHistory(); + slots[1].spySetTargeting.resetHistory(); + window.googletag.pubads().setSlots(slots); + + $$PREBID_GLOBAL$$.setTargetingForGPTAsync([config.adUnitCodes[0]], (slot) => { + return (adUnitCode) => { + return slots[0].getSlotElementId() === slot.getSlotElementId(); + }; }); - assert.deepEqual(slots[1].spySetTargeting.args, targeting, 'google tag targeting options not matching'); + var expected = getTargetingKeys(); + expect(slots[0].spySetTargeting.args).to.deep.contain.members(expected); + expect(slots[1].spySetTargeting.args).to.not.deep.contain.members(expected); }); it('should set targeting when passed a string ad unit code with enableSendAllBids', function () { @@ -898,6 +943,40 @@ describe('Unit: Prebid Module', function () { expect(slots[0].spySetTargeting.args).to.deep.contain.members(expected); }); + it('should find correct gpt slot based on ad id rather than ad unit code when resizing secure creative', function () { + var slots = [ + new Slot('div-not-matching-adunit-code-1', config.adUnitCodes[0]), + new Slot('div-not-matching-adunit-code-2', config.adUnitCodes[0]), + new Slot('div-not-matching-adunit-code-3', config.adUnitCodes[0]) + ]; + + slots[1].setTargeting('hb_adid', ['someAdId']); + slots[1].spyGetSlotElementId.resetHistory(); + window.googletag.pubads().setSlots(slots); + + const mockAdObject = { + adId: 'someAdId', + ad: '', + adUrl: 'http://creative.prebid.org/${AUCTION_PRICE}', + width: 300, + height: 250, + renderer: null, + cpm: '1.00', + adUnitCode: config.adUnitCodes[0], + }; + + const remoteDomain = '*'; + const source = { + postMessage: sinon.stub() + }; + + _sendAdToCreative(mockAdObject, remoteDomain, source); + + expect(slots[0].spyGetSlotElementId.called).to.equal(false); + expect(slots[1].spyGetSlotElementId.called).to.equal(true); + expect(slots[2].spyGetSlotElementId.called).to.equal(false); + }); + it('Calling enableSendAllBids should set targeting to include standard keys with bidder' + ' append to key name', function () { var slots = createSlotArray(); @@ -1142,9 +1221,14 @@ describe('Unit: Prebid Module', function () { describe('requestBids', function () { let logMessageSpy; let makeRequestsStub; - let xhr; let adUnits; let clock; + before(function () { + clock = sinon.useFakeTimers(); + }); + after(function () { + clock.restore(); + }); let bidsBackHandlerStub = sinon.stub(); const BIDDER_CODE = 'sampleBidder'; @@ -1186,10 +1270,14 @@ describe('Unit: Prebid Module', function () { logMessageSpy = sinon.spy(utils, 'logMessage'); makeRequestsStub = sinon.stub(adapterManager, 'makeBidRequests'); makeRequestsStub.returns(bidRequests); - xhr = sinon.useFakeXMLHttpRequest(); adUnits = [{ code: 'adUnit-code', + mediaTypes: { + banner: { + sizes: [[300, 250]] + } + }, bids: [ {bidder: BIDDER_CODE, params: {placementId: 'id'}}, ] @@ -1210,7 +1298,6 @@ describe('Unit: Prebid Module', function () { adapterManager.makeBidRequests.restore(); auctionModule.newAuction.restore(); utils.logMessage.restore(); - xhr.restore(); }); it('should execute callback after timeout', function () { @@ -1228,7 +1315,6 @@ describe('Unit: Prebid Module', function () { spec.isBidRequestValid.returns(true); spec.interpretResponse.returns(bids); - clock = sinon.useFakeTimers(); let requestObj = { bidsBackHandler: null, // does not need to be defined because of newAuction mock in beforeEach timeout: 2000, @@ -1282,7 +1368,6 @@ describe('Unit: Prebid Module', function () { auction.getBidsReceived = function() { return [adResponse]; } auction.getAuctionId = () => auctionId; - clock = sinon.useFakeTimers(); let requestObj = { bidsBackHandler: null, // does not need to be defined because of newAuction mock in beforeEach timeout: 2000, @@ -1314,9 +1399,11 @@ describe('Unit: Prebid Module', function () { adUnits: [ { code: 'test1', + mediaTypes: { banner: { sizes: [] } }, bids: [], }, { code: 'test2', + mediaTypes: { banner: { sizes: [] } }, bids: [], } ], @@ -1330,18 +1417,6 @@ describe('Unit: Prebid Module', function () { }); describe('requestBids', function () { - let xhr; - let requests; - - beforeEach(function () { - xhr = sinon.useFakeXMLHttpRequest(); - requests = []; - xhr.onCreate = request => requests.push(request); - }); - - afterEach(function () { - xhr.restore(); - }); var adUnitsBackup; var auctionManagerStub; let logMessageSpy; @@ -1385,7 +1460,7 @@ describe('Unit: Prebid Module', function () { try { $$PREBID_GLOBAL$$.requestBids({}); } catch (e) { - console.log(e); + console.log(e); // eslint-disable-line } assert.ok(logMessageSpy.calledWith('No adUnits configured. No bids requested.'), 'expected message was logged'); }); @@ -1396,9 +1471,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 +1496,11 @@ describe('Unit: Prebid Module', function () { adUnits: [ { code: 'test1', + mediaTypes: { banner: { sizes: [] } }, bids: [] }, { code: 'test2', + mediaTypes: { banner: { sizes: [] } }, bids: [] } ] @@ -1562,7 +1641,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 +1679,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 +1841,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 +1849,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 +1889,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 +1901,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'}} ] @@ -1972,6 +2049,228 @@ describe('Unit: Prebid Module', function () { assert.ok(spyEventsOn.calledWith('bidWon', Function)); events.on.restore(); }); + + describe('beforeRequestBids', function () { + let bidRequestedHandler; + let beforeRequestBidsHandler; + let bidsBackHandler = function bidsBackHandler() {}; + + let bidsBackSpy; + let bidRequestedSpy; + let beforeRequestBidsSpy; + + beforeEach(function () { + resetAuction(); + bidsBackSpy = sinon.spy(bidsBackHandler); + googletag.pubads().setSlots(createSlotArrayScenario2()); + }); + + afterEach(function () { + bidsBackSpy.resetHistory(); + + if (bidRequestedSpy) { + $$PREBID_GLOBAL$$.offEvent('bidRequested', bidRequestedSpy); + bidRequestedSpy.resetHistory(); + } + + if (beforeRequestBidsSpy) { + $$PREBID_GLOBAL$$.offEvent('beforeRequestBids', beforeRequestBidsSpy); + beforeRequestBidsSpy.resetHistory(); + } + }); + + it('should allow creation of a fpd.context.pbAdSlot property on adUnits from inside the event handler', function () { + // verify adUnits passed to handler then alter the adUnits + beforeRequestBidsHandler = function beforeRequestBidsHandler(beforeRequestBidsAdUnits) { + expect(beforeRequestBidsAdUnits).to.be.a('array'); + expect(beforeRequestBidsAdUnits).to.have.lengthOf(1); + expect(beforeRequestBidsAdUnits[0]).to.be.a('object'); + // adUnit should not contain a context property yet + expect(beforeRequestBidsAdUnits[0]).to.not.have.property('fpd') + // alter the adUnit by adding the property for context.pbAdSlot + beforeRequestBidsAdUnits[0].fpd = { + context: { + pbAdSlot: '/19968336/header-bid-tag-pbadslot-0' + } + }; + }; + beforeRequestBidsSpy = sinon.spy(beforeRequestBidsHandler); + + // use this handler to verify if the adUnits alterations were applied successfully by the beforeRequestBids handler + bidRequestedHandler = function bidRequestedHandler(bidRequest) { + expect(bidRequest).to.be.a('object'); + expect(bidRequest).to.have.property('bids'); + expect(bidRequest.bids).to.be.a('array'); + expect(bidRequest.bids).to.have.lengthOf(1); + const bid = bidRequest['bids'][0]; + expect(bid).to.be.a('object'); + expect(bid).to.have.property('fpd'); + expect(bid.fpd).to.be.a('object'); + expect(bid.fpd).to.have.property('context'); + expect(bid.fpd.context).to.be.a('object'); + expect(bid.fpd.context).to.have.property('pbAdSlot'); + expect(bid.fpd.context.pbAdSlot).to.equal('/19968336/header-bid-tag-pbadslot-0'); + }; + bidRequestedSpy = sinon.spy(bidRequestedHandler); + + $$PREBID_GLOBAL$$.onEvent('beforeRequestBids', beforeRequestBidsSpy); + $$PREBID_GLOBAL$$.onEvent('bidRequested', bidRequestedSpy); + $$PREBID_GLOBAL$$.requestBids({ + adUnits: [{ + code: '/19968336/header-bid-tag-0', + mediaTypes: { + banner: { + sizes: [[750, 350]] + } + }, + bids: [{ + bidder: 'appnexus', + params: { + placementId: 13122370 + } + }] + }], + bidsBackHandler: bidsBackSpy + }); + + sinon.assert.calledOnce(beforeRequestBidsSpy); + sinon.assert.calledOnce(bidRequestedSpy); + }); + + it('should allow creation of a fpd.context.pbAdSlot property on adUnits from inside the event handler', function () { + // verify adUnits passed to handler then alter the adUnits + beforeRequestBidsHandler = function beforeRequestBidsHandler(beforeRequestBidsAdUnits) { + expect(beforeRequestBidsAdUnits).to.be.a('array'); + expect(beforeRequestBidsAdUnits).to.have.lengthOf(2); + expect(beforeRequestBidsAdUnits[0]).to.be.a('object'); + expect(beforeRequestBidsAdUnits[1]).to.be.a('object'); + // adUnit should not contain a context property yet + expect(beforeRequestBidsAdUnits[0]).to.not.have.property('fpd'); + expect(beforeRequestBidsAdUnits[1]).to.not.have.property('fpd'); + // alter the adUnit by adding the property for context.pbAdSlot + beforeRequestBidsAdUnits[0].fpd = { + context: { + pbAdSlot: '/19968336/header-bid-tag-pbadslot-0' + } + }; + beforeRequestBidsAdUnits[1].fpd = { + context: { + pbAdSlot: '/19968336/header-bid-tag-pbadslot-1' + } + }; + }; + beforeRequestBidsSpy = sinon.spy(beforeRequestBidsHandler); + + // use this handler to verify if the adUnits alterations were applied successfully by the beforeRequestBids handler + bidRequestedHandler = function bidRequestedHandler(bidRequest) { + expect(bidRequest).to.be.a('object'); + expect(bidRequest).to.have.property('bids'); + expect(bidRequest.bids).to.be.a('array'); + expect(bidRequest.bids).to.have.lengthOf(2); + const bid0 = bidRequest['bids'][0]; + expect(bid0).to.be.a('object'); + expect(bid0).to.have.property('fpd'); + expect(bid0.fpd).to.be.a('object'); + expect(bid0.fpd).to.have.property('context'); + expect(bid0.fpd.context).to.be.a('object'); + expect(bid0.fpd.context).to.have.property('pbAdSlot'); + expect(bid0.fpd.context.pbAdSlot).to.equal('/19968336/header-bid-tag-pbadslot-0'); + + const bid1 = bidRequest['bids'][1]; + expect(bid1).to.be.a('object'); + expect(bid1).to.have.property('fpd'); + expect(bid1.fpd).to.be.a('object'); + expect(bid1.fpd).to.have.property('context'); + expect(bid1.fpd.context).to.be.a('object'); + expect(bid1.fpd.context).to.have.property('pbAdSlot'); + expect(bid1.fpd.context.pbAdSlot).to.equal('/19968336/header-bid-tag-pbadslot-1'); + }; + bidRequestedSpy = sinon.spy(bidRequestedHandler); + + $$PREBID_GLOBAL$$.onEvent('beforeRequestBids', beforeRequestBidsSpy); + $$PREBID_GLOBAL$$.onEvent('bidRequested', bidRequestedSpy); + $$PREBID_GLOBAL$$.requestBids({ + adUnits: [{ + code: '/19968336/header-bid-tag-0', + mediaTypes: { + banner: { + sizes: [[750, 350]] + } + }, + bids: [{ + bidder: 'appnexus', + params: { + placementId: 13122370 + } + }] + }, { + code: '/19968336/header-bid-tag-1', + mediaTypes: { + banner: { + sizes: [[750, 350]] + } + }, + bids: [{ + bidder: 'appnexus', + params: { + placementId: 14122380 + } + }] + }], + bidsBackHandler: bidsBackSpy + }); + + sinon.assert.calledOnce(beforeRequestBidsSpy); + sinon.assert.calledOnce(bidRequestedSpy); + }); + + it('should not create a context property on adUnits if not added by handler', function () { + // verify adUnits passed to handler then alter the adUnits + beforeRequestBidsHandler = function beforeRequestBidsHandler(beforeRequestBidsAdUnits) { + expect(beforeRequestBidsAdUnits).to.be.a('array'); + expect(beforeRequestBidsAdUnits).to.have.lengthOf(1); + expect(beforeRequestBidsAdUnits[0]).to.be.a('object'); + // adUnit should not contain a context property yet + expect(beforeRequestBidsAdUnits[0]).to.not.have.property('context') + }; + beforeRequestBidsSpy = sinon.spy(beforeRequestBidsHandler); + + // use this handler to verify if the adUnits alterations were applied successfully by the beforeRequestBids handler + bidRequestedHandler = function bidRequestedHandler(bidRequest) { + expect(bidRequest).to.be.a('object'); + expect(bidRequest).to.have.property('bids'); + expect(bidRequest.bids).to.be.a('array'); + expect(bidRequest.bids).to.have.lengthOf(1); + const bid = bidRequest['bids'][0]; + expect(bid).to.be.a('object'); + expect(bid).to.not.have.property('context'); + }; + bidRequestedSpy = sinon.spy(bidRequestedHandler); + + $$PREBID_GLOBAL$$.onEvent('beforeRequestBids', beforeRequestBidsSpy); + $$PREBID_GLOBAL$$.onEvent('bidRequested', bidRequestedSpy); + $$PREBID_GLOBAL$$.requestBids({ + adUnits: [{ + code: '/19968336/header-bid-tag-0', + mediaTypes: { + banner: { + sizes: [[750, 350]] + } + }, + bids: [{ + bidder: 'appnexus', + params: { + placementId: 13122370 + } + }] + }], + bidsBackHandler: bidsBackSpy + }); + + sinon.assert.calledOnce(beforeRequestBidsSpy); + sinon.assert.calledOnce(bidRequestedSpy); + }); + }); }); describe('offEvent', function () { @@ -2033,17 +2332,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 +2368,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 +2388,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 +2555,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 +2576,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/unit/secureCreatives_spec.js b/test/spec/unit/secureCreatives_spec.js index f0f26bf5653..97dfa119193 100644 --- a/test/spec/unit/secureCreatives_spec.js +++ b/test/spec/unit/secureCreatives_spec.js @@ -1,8 +1,8 @@ import { _sendAdToCreative -} from '../../../src/secureCreatives'; +} from '../../../src/secureCreatives.js'; import { expect } from 'chai'; -import * as utils from 'src/utils'; +import * as utils from 'src/utils.js'; describe('secureCreatives', () => { describe('_sendAdToCreative', () => { diff --git a/test/spec/url_spec.js b/test/spec/url_spec.js deleted file mode 100644 index 90047273043..00000000000 --- a/test/spec/url_spec.js +++ /dev/null @@ -1,94 +0,0 @@ -import {format, parse} from '../../src/url'; -import { expect } from 'chai'; - -describe('helpers.url', function () { - describe('parse()', function () { - let parsed; - - beforeEach(function () { - parsed = parse('http://example.com:3000/pathname/?search=test&foo=bar&bar=foo%26foo%3Dxxx#hash'); - }); - - it('extracts the protocol', function () { - expect(parsed).to.have.property('protocol', 'http'); - }); - - it('extracts the hostname', function () { - expect(parsed).to.have.property('hostname', 'example.com'); - }); - - it('extracts the port', function () { - expect(parsed).to.have.property('port', 3000); - }); - - it('extracts the pathname', function () { - expect(parsed).to.have.property('pathname', '/pathname/'); - }); - - it('extracts the search query', function () { - expect(parsed).to.have.property('search'); - expect(parsed.search).to.eql({ - foo: 'xxx', - search: 'test', - bar: 'foo', - }); - }); - - it('extracts the hash', function () { - expect(parsed).to.have.property('hash', 'hash'); - }); - - it('extracts the host', function () { - expect(parsed).to.have.property('host', 'example.com:3000'); - }); - }); - - describe('parse(url, {noDecodeWholeURL: true})', function () { - let parsed; - - beforeEach(function () { - parsed = parse('http://example.com:3000/pathname/?search=test&foo=bar&bar=foo%26foo%3Dxxx#hash', {noDecodeWholeURL: true}); - }); - - it('extracts the search query', function () { - expect(parsed).to.have.property('search'); - expect(parsed.search).to.eql({ - foo: 'bar', - search: 'test', - bar: 'foo%26foo%3Dxxx', - }); - }); - }); - - describe('format()', function () { - it('formats an object in to a URL', function () { - expect(format({ - protocol: 'http', - hostname: 'example.com', - port: 3000, - pathname: '/pathname/', - search: {foo: 'bar', search: 'test', bar: 'foo%26foo%3Dxxx'}, - hash: 'hash' - })).to.equal('http://example.com:3000/pathname/?foo=bar&search=test&bar=foo%26foo%3Dxxx#hash'); - }); - - it('will use defaults for missing properties', function () { - expect(format({ - hostname: 'example.com' - })).to.equal('http://example.com'); - }); - }); - - describe('parse(url, {decodeSearchAsString: true})', function () { - let parsed; - - beforeEach(function () { - parsed = parse('http://example.com:3000/pathname/?search=test&foo=bar&bar=foo%26foo%3Dxxx#hash', {decodeSearchAsString: true}); - }); - - it('extracts the search query', function () { - expect(parsed).to.have.property('search'); - expect(parsed.search).to.equal('?search=test&foo=bar&bar=foo&foo=xxx'); - }); - }); -}); diff --git a/test/spec/userSync_spec.js b/test/spec/userSync_spec.js index f55fe13c528..2b68349ca31 100644 --- a/test/spec/userSync_spec.js +++ b/test/spec/userSync_spec.js @@ -1,8 +1,8 @@ import { expect } from 'chai'; -import { config } from 'src/config'; +import { config } from 'src/config.js'; // Use require since we need to be able to write to these vars const utils = require('../../src/utils'); -let { newUserSync } = require('../../src/userSync'); +let { newUserSync, USERSYNC_DEFAULT_CONFIG } = require('../../src/userSync'); describe('user sync', function () { let triggerPixelStub; @@ -34,6 +34,7 @@ describe('user sync', function () { }); beforeEach(function () { + config.setConfig({ userSync: USERSYNC_DEFAULT_CONFIG }); triggerPixelStub = sinon.stub(utils, 'triggerPixel'); logWarnStub = sinon.stub(utils, 'logWarn'); shuffleStub = sinon.stub(utils, 'shuffle').callsFake((array) => array.reverse()); @@ -47,6 +48,7 @@ describe('user sync', function () { shuffleStub.restore(); getUniqueIdentifierStrStub.restore(); insertUserSyncIframeStub.restore(); + config.resetConfig(); }); it('should register and fire a pixel URL', function () { @@ -85,21 +87,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 +125,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 +144,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 +163,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 +194,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 +202,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 +218,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; @@ -359,9 +376,88 @@ describe('user sync', function () { expect(insertUserSyncIframeStub.getCall(0)).to.be.null; }); + it('should still allow default image syncs if setConfig only defined iframe', function () { + const userSync = newUserSync({ + config: config.getConfig('userSync'), + browserSupportsCookies: true + }); + + config.setConfig({ + userSync: { + filterSettings: { + iframe: { + bidders: ['bidderXYZ'], + filter: 'include' + } + } + } + }); + + userSync.registerSync('image', 'testBidder', 'http://example.com'); + userSync.registerSync('iframe', 'bidderXYZ', 'http://example.com/iframe'); + userSync.syncUsers(); + expect(triggerPixelStub.getCall(0)).to.not.be.null; + expect(triggerPixelStub.getCall(0).args[0]).to.exist.and.to.equal('http://example.com'); + expect(insertUserSyncIframeStub.getCall(0).args[0]).to.equal('http://example.com/iframe'); + }); + + it('should override default image syncs if setConfig used image filter', function () { + const userSync = newUserSync({ + config: config.getConfig('userSync'), + browserSupportsCookies: true + }); + + config.setConfig({ + userSync: { + filterSettings: { + image: { + bidders: ['bidderXYZ'], + filter: 'exclude' + } + } + } + }); + + userSync.registerSync('image', 'testBidder', 'http://example.com'); + userSync.registerSync('image', 'bidderXYZ', 'http://example.com/image-blocked'); + userSync.syncUsers(); + expect(triggerPixelStub.getCall(0)).to.not.be.null; + expect(triggerPixelStub.getCall(0).args[0]).to.exist.and.to.equal('http://example.com'); + expect(triggerPixelStub.getCall(1)).to.be.null; + }); + + it('should override default image syncs if setConfig used all filter', function() { + const userSync = newUserSync({ + config: config.getConfig('userSync'), + browserSupportsCookies: true + }); + + config.setConfig({ + userSync: { + filterSettings: { + all: { + bidders: ['bidderXYZ'], + filter: 'exclude' + } + } + } + }); + + userSync.registerSync('image', 'testBidder', 'http://example.com'); + userSync.registerSync('image', 'bidderXYZ', 'http://example.com/image-blocked'); + userSync.registerSync('iframe', 'testBidder', 'http://example.com/iframe'); + userSync.registerSync('iframe', 'bidderXYZ', 'http://example.com/iframe-blocked'); + userSync.syncUsers(); + expect(triggerPixelStub.getCall(0)).to.not.be.null; + expect(triggerPixelStub.getCall(0).args[0]).to.exist.and.to.equal('http://example.com'); + expect(triggerPixelStub.getCall(1)).to.be.null; + expect(insertUserSyncIframeStub.getCall(0).args[0]).to.equal('http://example.com/iframe'); + expect(insertUserSyncIframeStub.getCall(1)).to.be.null; + }); + 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 +493,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 +523,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 +546,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 old mode 100755 new mode 100644 index 5bee79d39c2..96df3cf996c --- a/test/spec/utils_spec.js +++ b/test/spec/utils_spec.js @@ -1,7 +1,7 @@ -import { getAdServerTargeting } from 'test/fixtures/fixtures'; +import { getAdServerTargeting } from 'test/fixtures/fixtures.js'; import { expect } from 'chai'; import CONSTANTS from 'src/constants.json'; -import * as utils from 'src/utils'; +import * as utils from 'src/utils.js'; var assert = require('assert'); @@ -18,24 +18,6 @@ describe('Utils', function () { type_array = 'Array', type_function = 'Function'; - describe('replaceTokenInString', function () { - it('should replace all given tokens in a String', function () { - var tokensToReplace = { - foo: 'bar', - zap: 'quux' - }; - - var output = utils.replaceTokenInString('hello %FOO%, I am %ZAP%', tokensToReplace, '%'); - assert.equal(output, 'hello bar, I am quux'); - }); - - it('should ignore tokens it does not see', function () { - var output = utils.replaceTokenInString('hello %FOO%', {}, '%'); - - assert.equal(output, 'hello %FOO%'); - }); - }); - describe('getBidIdParameter', function () { it('should return value of the key in input object', function () { var obj = { @@ -86,7 +68,7 @@ describe('Utils', function () { }; var output = utils.parseQueryStringParameters(obj); - var expectedResult = 'a=' + encodeURIComponent('1') + '&b=' + encodeURIComponent('2') + '&'; + var expectedResult = 'a=' + encodeURIComponent('1') + '&b=' + encodeURIComponent('2'); assert.equal(output, expectedResult); }); @@ -699,20 +681,6 @@ describe('Utils', function () { }); }); - describe('createContentToExecuteExtScriptInFriendlyFrame', function () { - it('should return empty string if url is not passed', function () { - var output = utils.createContentToExecuteExtScriptInFriendlyFrame(); - assert.equal(output, ''); - }); - - it('should have URL in returned value if url is passed', function () { - var url = 'https://abcd.com/service?a=1&b=2&c=3'; - var output = utils.createContentToExecuteExtScriptInFriendlyFrame(url); - var expected = ``; - assert.equal(output, expected); - }); - }); - describe('getDefinedParams', function () { it('builds an object consisting of defined params', function () { const adUnit = { @@ -793,93 +761,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'; @@ -920,6 +801,98 @@ describe('Utils', function () { }); }); + describe('URL helpers', function () { + describe('parseUrl()', function () { + let parsed; + + beforeEach(function () { + parsed = utils.parseUrl('http://example.com:3000/pathname/?search=test&foo=bar&bar=foo%26foo%3Dxxx#hash'); + }); + + it('extracts the protocol', function () { + expect(parsed).to.have.property('protocol', 'http'); + }); + + it('extracts the hostname', function () { + expect(parsed).to.have.property('hostname', 'example.com'); + }); + + it('extracts the port', function () { + expect(parsed).to.have.property('port', 3000); + }); + + it('extracts the pathname', function () { + expect(parsed).to.have.property('pathname', '/pathname/'); + }); + + it('extracts the search query', function () { + expect(parsed).to.have.property('search'); + expect(parsed.search).to.eql({ + foo: 'xxx', + search: 'test', + bar: 'foo', + }); + }); + + it('extracts the hash', function () { + expect(parsed).to.have.property('hash', 'hash'); + }); + + it('extracts the host', function () { + expect(parsed).to.have.property('host', 'example.com:3000'); + }); + }); + + describe('parseUrl(url, {noDecodeWholeURL: true})', function () { + let parsed; + + beforeEach(function () { + parsed = utils.parseUrl('http://example.com:3000/pathname/?search=test&foo=bar&bar=foo%26foo%3Dxxx#hash', {noDecodeWholeURL: true}); + }); + + it('extracts the search query', function () { + expect(parsed).to.have.property('search'); + expect(parsed.search).to.eql({ + foo: 'bar', + search: 'test', + bar: 'foo%26foo%3Dxxx', + }); + }); + }); + + describe('buildUrl()', function () { + it('formats an object in to a URL', function () { + expect(utils.buildUrl({ + protocol: 'http', + hostname: 'example.com', + port: 3000, + pathname: '/pathname/', + search: {foo: 'bar', search: 'test', bar: 'foo%26foo%3Dxxx'}, + hash: 'hash' + })).to.equal('http://example.com:3000/pathname/?foo=bar&search=test&bar=foo%26foo%3Dxxx#hash'); + }); + + it('will use defaults for missing properties', function () { + expect(utils.buildUrl({ + hostname: 'example.com' + })).to.equal('http://example.com'); + }); + }); + + describe('parseUrl(url, {decodeSearchAsString: true})', function () { + let parsed; + + beforeEach(function () { + parsed = utils.parseUrl('http://example.com:3000/pathname/?search=test&foo=bar&bar=foo%26foo%3Dxxx#hash', {decodeSearchAsString: true}); + }); + + it('extracts the search query', function () { + expect(parsed).to.have.property('search'); + expect(parsed.search).to.equal('?search=test&foo=bar&bar=foo&foo=xxx'); + }); + }); + }); + describe('transformBidderParamKeywords', function () { it('returns an array of objects when keyvalue is an array', function () { let keywords = { @@ -1009,4 +982,137 @@ describe('Utils', function () { }); }); }); + + describe('isSafariBrowser', function () { + let userAgentStub; + let userAgent; + + before(function () { + userAgentStub = sinon.stub(navigator, 'userAgent').get(function () { + return userAgent; + }); + }); + + after(function () { + userAgentStub.restore(); + }); + + it('properly detects safari', function () { + userAgent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/536.25 (KHTML, like Gecko) Version/6.0 Safari/536.25'; + expect(utils.isSafariBrowser()).to.equal(true); + }); + it('does not flag Chrome on MacOS', function () { + userAgent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.163 Safari/537.36'; + expect(utils.isSafariBrowser()).to.equal(false); + }); + it('does not flag Chrome iOS', function () { + userAgent = 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/80.0.3987.95 Mobile/15E148 Safari/604.1'; + expect(utils.isSafariBrowser()).to.equal(false); + }); + it('does not flag Firefox iOS', function () { + userAgent = 'Mozilla/5.0 (iPhone; CPU OS 13_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) FxiOS/23.0 Mobile/15E148 Safari/605.1.15'; + expect(utils.isSafariBrowser()).to.equal(false); + }); + it('does not flag Windows Edge', function () { + userAgent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.74 Safari/537.36 Edg/79.0.309.43'; + expect(utils.isSafariBrowser()).to.equal(false); + }); + }); + + describe('mergeDeep', function() { + it('properly merge objects that share same property names', function() { + const object1 = { + propA: { + subPropA: 'abc' + } + }; + const object2 = { + propA: { + subPropB: 'def' + } + }; + + const resultWithoutMergeDeep = Object.assign({}, object1, object2); + expect(resultWithoutMergeDeep).to.deep.equal({ + propA: { + subPropB: 'def' + } + }); + + const resultWithMergeDeep = utils.mergeDeep({}, object1, object2); + expect(resultWithMergeDeep).to.deep.equal({ + propA: { + subPropA: 'abc', + subPropB: 'def' + } + }); + }); + + it('properly merge objects that have different depths', function() { + const object1 = { + depth0_A: { + depth1_A: { + depth2_A: 123 + } + } + }; + const object2 = { + depth0_A: { + depth1_A: { + depth2_B: { + depth3_A: { + depth4_A: 'def' + } + } + }, + depth1_B: 'abc' + } + }; + const object3 = { + depth0_B: 456 + }; + + const result = utils.mergeDeep({}, object1, object2, object3); + expect(result).to.deep.equal({ + depth0_A: { + depth1_A: { + depth2_A: 123, + depth2_B: { + depth3_A: { + depth4_A: 'def' + } + } + }, + depth1_B: 'abc' + }, + depth0_B: 456 + }); + }); + + it('properly merge objects with various property types', function() { + const object1 = { + depth0_A: { + depth1_A: ['a', 'b', 'c'], + depth1_B: 'abc', + depth1_C: 123 + } + }; + const object2 = { + depth0_A: { + depth1_A: ['d', 'e', 'f'], + depth1_D: true, + } + }; + + const result = utils.mergeDeep({}, object1, object2); + expect(result).to.deep.equal({ + depth0_A: { + depth1_A: ['a', 'b', 'c', 'd', 'e', 'f'], + depth1_B: 'abc', + depth1_C: 123, + depth1_D: true, + } + }); + }); + }); }); diff --git a/test/spec/videoCache_spec.js b/test/spec/videoCache_spec.js index 8f423a799ac..7d706947416 100644 --- a/test/spec/videoCache_spec.js +++ b/test/spec/videoCache_spec.js @@ -1,7 +1,7 @@ -import 'mocha/mocha'; import chai from 'chai'; -import { getCacheUrl, store } from 'src/videoCache'; -import { config } from 'src/config'; +import { getCacheUrl, store } from 'src/videoCache.js'; +import { config } from 'src/config.js'; +import { server } from 'test/mocks/xhr.js'; const should = chai.should(); @@ -17,24 +17,11 @@ describe('The video cache', function () { } describe('when the cache server is unreachable', function () { - let xhr; - let requests; - - beforeEach(function () { - xhr = sinon.useFakeXMLHttpRequest(); - requests = []; - xhr.onCreate = (request) => requests.push(request); - }); - - afterEach(function () { - xhr.restore(); - }); - it('should execute the callback with an error when store() is called', function () { const callback = sinon.spy(); store([{ vastUrl: 'my-mock-url.com' }], callback); - requests[0].respond(503, { + server.requests[0].respond(503, { 'Content-Type': 'plain/text', }, 'The server could not save anything at the moment.'); @@ -44,13 +31,7 @@ describe('The video cache', function () { }); describe('when the cache server is available', function () { - let xhr; - let requests; - beforeEach(function () { - xhr = sinon.useFakeXMLHttpRequest(); - requests = []; - xhr.onCreate = (request) => requests.push(request); config.setConfig({ cache: { url: 'https://prebid.adnxs.com/pbc/v1/cache' @@ -59,7 +40,6 @@ describe('The video cache', function () { }); afterEach(function () { - xhr.restore(); config.resetConfig(); }); @@ -139,7 +119,7 @@ describe('The video cache', function () { }]; store(bids, function () { }); - const request = requests[0]; + const request = server.requests[0]; request.method.should.equal('POST'); request.url.should.equal('https://prebid.adnxs.com/pbc/v1/cache'); request.requestHeaders['Content-Type'].should.equal('text/plain;charset=utf-8'); @@ -187,7 +167,7 @@ describe('The video cache', function () { }]; store(bids, function () { }); - const request = requests[0]; + const request = server.requests[0]; request.method.should.equal('POST'); request.url.should.equal('https://prebid.adnxs.com/pbc/v1/cache'); request.requestHeaders['Content-Type'].should.equal('text/plain;charset=utf-8'); @@ -215,7 +195,7 @@ describe('The video cache', function () { function assertRequestMade(bid, expectedValue) { store([bid], function () { }); - const request = requests[0]; + const request = server.requests[0]; request.method.should.equal('POST'); request.url.should.equal('https://prebid.adnxs.com/pbc/v1/cache'); request.requestHeaders['Content-Type'].should.equal('text/plain;charset=utf-8'); @@ -232,7 +212,7 @@ describe('The video cache', function () { function fakeServerCall(bid, responseBody) { const callback = sinon.spy(); store([bid], callback); - requests[0].respond( + server.requests[0].respond( 200, { 'Content-Type': 'application/json', diff --git a/test/spec/video_spec.js b/test/spec/video_spec.js index dc6c11a7491..72a585049c3 100644 --- a/test/spec/video_spec.js +++ b/test/spec/video_spec.js @@ -1,4 +1,4 @@ -import { isValidVideoBid } from 'src/video'; +import { isValidVideoBid } from 'src/video.js'; describe('video.js', function () { it('validates valid instream bids', function () { diff --git a/test/test_index.js b/test/test_index.js index 206f1be1f52..53d75e36176 100644 --- a/test/test_index.js +++ b/test/test_index.js @@ -1,5 +1,6 @@ require('test/helpers/prebidGlobal.js'); require('test/mocks/adloaderStub.js'); +require('test/mocks/xhr.js'); var testsContext = require.context('.', true, /_spec$/); testsContext.keys().forEach(testsContext); diff --git a/wdio.conf.js b/wdio.conf.js index 22765e34346..dd94e82cf90 100644 --- a/wdio.conf.js +++ b/wdio.conf.js @@ -35,9 +35,8 @@ function getCapabilities() { } exports.config = { - // TODO: below change is only for testing and is to be removed. specs: [ - './test/spec/e2e/banner/*.spec.js' + './test/spec/e2e/**/*.spec.js' ], services: ['browserstack'], user: process.env.BROWSERSTACK_USERNAME,