From 8f909d8d3d8bc5acaa5682ea145450d5954d0468 Mon Sep 17 00:00:00 2001 From: vrishko Date: Mon, 11 Sep 2023 12:01:13 +0300 Subject: [PATCH] SmartyadsBidAdapter/send_notifics_noly_on_prebid_host --- modules/smartyadsBidAdapter.js | 12 +++-- test/spec/modules/smartyadsBidAdapter_spec.js | 48 +++++++++++++++++-- 2 files changed, 54 insertions(+), 6 deletions(-) diff --git a/modules/smartyadsBidAdapter.js b/modules/smartyadsBidAdapter.js index 1644a15e92d..3e6c5cf360b 100644 --- a/modules/smartyadsBidAdapter.js +++ b/modules/smartyadsBidAdapter.js @@ -129,16 +129,22 @@ export const spec = { if (bid.winUrl) { ajax(bid.winUrl, () => {}, JSON.stringify(bid)); } else { - ajax('https://et-nd43.itdsmr.com/?c=o&m=prebid&secret_key=prebid_js&winTest=1', () => {}, JSON.stringify(bid)); + if (bid?.postData && bid?.postData[0] && bid?.postData[0].params && bid?.postData[0].params[0].host == 'prebid') { + ajax('https://et-nd43.itdsmr.com/?c=o&m=prebid&secret_key=prebid_js&winTest=1', () => {}, JSON.stringify(bid)); + } } }, onTimeout: function(bid) { - ajax('https://et-nd43.itdsmr.com/?c=o&m=prebid&secret_key=prebid_js&bidTimeout=1', () => {}, JSON.stringify(bid)); + if (bid?.postData && bid?.postData[0] && bid?.postData[0].params && bid?.postData[0].params[0].host == 'prebid') { + ajax('https://et-nd43.itdsmr.com/?c=o&m=prebid&secret_key=prebid_js&bidTimeout=1', () => {}, JSON.stringify(bid)); + } }, onBidderError: function(bid) { - ajax('https://et-nd43.itdsmr.com/?c=o&m=prebid&secret_key=prebid_js&bidderError=1', () => {}, JSON.stringify(bid)); + if (bid?.postData && bid?.postData[0] && bid?.postData[0].params && bid?.postData[0].params[0].host == 'prebid') { + ajax('https://et-nd43.itdsmr.com/?c=o&m=prebid&secret_key=prebid_js&bidderError=1', () => {}, JSON.stringify(bid)); + } }, }; diff --git a/test/spec/modules/smartyadsBidAdapter_spec.js b/test/spec/modules/smartyadsBidAdapter_spec.js index 350cad33704..992fff14f33 100644 --- a/test/spec/modules/smartyadsBidAdapter_spec.js +++ b/test/spec/modules/smartyadsBidAdapter_spec.js @@ -280,7 +280,21 @@ describe('SmartyadsAdapter', function () { }); it('should send a valid bid won notice', function () { - spec.onBidWon(bidResponse); + const bid = { + 'c': 'o', + 'm': 'prebid', + 'secret_key': 'prebid_js', + 'winTest': '1', + 'postData': [{ + 'bidder': 'smartyads', + 'params': [ + {'host': 'prebid', + 'accountid': '123', + 'sourceid': '12345' + }] + }] + }; + spec.onBidWon(bid); expect(server.requests.length).to.equal(1); }); }); @@ -291,7 +305,21 @@ describe('SmartyadsAdapter', function () { }); it('should send a valid bid timeout notice', function () { - spec.onTimeout({}); + const bid = { + 'c': 'o', + 'm': 'prebid', + 'secret_key': 'prebid_js', + 'bidTimeout': '1', + 'postData': [{ + 'bidder': 'smartyads', + 'params': [ + {'host': 'prebid', + 'accountid': '123', + 'sourceid': '12345' + }] + }] + }; + spec.onTimeout(bid); expect(server.requests.length).to.equal(1); }); }); @@ -302,7 +330,21 @@ describe('SmartyadsAdapter', function () { }); it('should send a valid bidder error notice', function () { - spec.onBidderError({}); + const bid = { + 'c': 'o', + 'm': 'prebid', + 'secret_key': 'prebid_js', + 'bidderError': '1', + 'postData': [{ + 'bidder': 'smartyads', + 'params': [ + {'host': 'prebid', + 'accountid': '123', + 'sourceid': '12345' + }] + }] + }; + spec.onBidderError(bid); expect(server.requests.length).to.equal(1); }); });