From a3e4d713f6adda8be9e85447dd18be2963218f57 Mon Sep 17 00:00:00 2001 From: AdmixerTech <35560933+admixertech@users.noreply.github.com> Date: Tue, 28 May 2019 16:29:54 +0300 Subject: [PATCH 1/4] BIDDER_CODE check removed --- modules/admixerBidAdapter.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/modules/admixerBidAdapter.js b/modules/admixerBidAdapter.js index ee224dc6a5c..c6d6dd34a11 100644 --- a/modules/admixerBidAdapter.js +++ b/modules/admixerBidAdapter.js @@ -29,9 +29,7 @@ export const spec = { referrer: encodeURIComponent(utils.getTopWindowUrl()), }; bidderRequest.forEach((bid) => { - if (bid.bidder === BIDDER_CODE || ALIASES.indexOf(bid.bidder) > -1) { - payload.imps.push(bid); - } + payload.imps.push(bid); }); const payloadString = JSON.stringify(payload); return { From 9cf9f9a8bb30b87b6c5b0646e28858b00f559ba2 Mon Sep 17 00:00:00 2001 From: atkachov Date: Tue, 17 Dec 2019 11:33:23 +0200 Subject: [PATCH 2/4] update 2.0 -> 3.0 --- modules/admixerBidAdapter.js | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/modules/admixerBidAdapter.js b/modules/admixerBidAdapter.js index c6d6dd34a11..81ad324f5cd 100644 --- a/modules/admixerBidAdapter.js +++ b/modules/admixerBidAdapter.js @@ -10,25 +10,20 @@ export const spec = { 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) { + console.log(arguments); 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 +35,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 = []; From 8439075e87cfe8076a6bc62db9df6deb6cfddb43 Mon Sep 17 00:00:00 2001 From: atkachov Date: Tue, 17 Dec 2019 15:13:10 +0200 Subject: [PATCH 3/4] add spec --- test/spec/modules/admixerBidAdapter_spec.js | 122 ++++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100644 test/spec/modules/admixerBidAdapter_spec.js diff --git a/test/spec/modules/admixerBidAdapter_spec.js b/test/spec/modules/admixerBidAdapter_spec.js new file mode 100644 index 00000000000..a0aaf8940bf --- /dev/null +++ b/test/spec/modules/admixerBidAdapter_spec.js @@ -0,0 +1,122 @@ +import {expect} from 'chai'; +import {spec} from 'modules/admixerBidAdapter'; +import {newBidder} from 'src/adapters/bidderFactory'; + +const BIDDER_CODE = 'admixer'; +const ENDPOINT_URL = '//inv-nets.admixer.net/prebid.1.0.aspx'; +const ZONE_ID = '2eb6bd58-865c-47ce-af7f-a918108c3fd2'; + +describe('AdmixerAdapter', function () { + const adapter = newBidder(spec); + + describe('inherited functions', function () { + it('exists and is a function', function () { + expect(adapter.callBids).to.be.exist.and.to.be.a('function'); + }); + }); + + describe('isBidRequestValid', function () { + let bid = { + 'bidder': BIDDER_CODE, + 'params': { + 'zone': ZONE_ID + }, + 'adUnitCode': 'adunit-code', + 'sizes': [[300, 250], [300, 600]], + 'bidId': '30b31c1838de1e', + 'bidderRequestId': '22edbae2733bf6', + 'auctionId': '1d1a030790a475', + }; + + it('should return true when required params found', function () { + expect(spec.isBidRequestValid(bid)).to.equal(true); + }); + + it('should return false when required params are not passed', function () { + let bid = Object.assign({}, bid); + delete bid.params; + bid.params = { + 'placementId': 0 + }; + expect(spec.isBidRequestValid(bid)).to.equal(false); + }); + }); + + describe('buildRequests', function () { + let validRequest = [ + { + 'bidder': BIDDER_CODE, + 'params': { + 'zone': ZONE_ID + }, + 'adUnitCode': 'adunit-code', + 'sizes': [[300, 250], [300, 600]], + 'bidId': '30b31c1838de1e', + 'bidderRequestId': '22edbae2733bf6', + 'auctionId': '1d1a030790a475', + } + ]; + let bidderRequest = { + refererInfo: { + referer: 'https://example.com' + } + }; + + it('should add referrer and imp to be equal bidRequest', function () { + 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(validRequest[0]); + }); + + it('sends bid request to ENDPOINT via GET', function () { + const request = spec.buildRequests(validRequest, bidderRequest); + expect(request.url).to.equal(ENDPOINT_URL); + expect(request.method).to.equal('GET'); + }); + }); + + describe('interpretResponse', function () { + let response = { + body: [{ + 'currency': 'USD', + 'cpm': 6.210000, + 'ad': '
ad
', + 'width': 300, + 'height': 600, + 'creativeId': 'ccca3e5e-0c54-4761-9667-771322fbdffc', + 'ttl': 360, + 'netRevenue': false, + 'bidId': '5e4e763b6bc60b' + }] + }; + + it('should get correct bid response', function () { + const body = response.body; + let expectedResponse = [ + { + 'requestId': body[0].bidId, + 'cpm': body[0].cpm, + 'creativeId': body[0].creativeId, + 'width': body[0].width, + 'height': body[0].height, + 'ad': body[0].ad, + 'vastUrl': undefined, + 'currency': body[0].currency, + 'netRevenue': body[0].netRevenue, + 'ttl': body[0].ttl, + } + ]; + + let result = spec.interpretResponse(response); + expect(result[0]).to.deep.equal(expectedResponse[0]); + }); + + it('handles nobid responses', function () { + let response = []; + + let result = spec.interpretResponse(response); + expect(result.length).to.equal(0); + }); + }); +}); From 68bd708f7416b754ea1820d22c690d7b7980839b Mon Sep 17 00:00:00 2001 From: AdmixerTech Date: Fri, 20 Dec 2019 10:42:18 +0200 Subject: [PATCH 4/4] review_fix --- modules/admixerBidAdapter.js | 3 +-- test/spec/modules/admixerBidAdapter_spec.js | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/modules/admixerBidAdapter.js b/modules/admixerBidAdapter.js index 81ad324f5cd..0818c6c8281 100644 --- a/modules/admixerBidAdapter.js +++ b/modules/admixerBidAdapter.js @@ -3,7 +3,7 @@ import {registerBidder} from '../src/adapters/bidderFactory'; 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, @@ -18,7 +18,6 @@ export const spec = { * Make a server request from the list of BidRequests. */ buildRequests: function (validRequest, bidderRequest) { - console.log(arguments); const payload = { imps: [], referrer: encodeURIComponent(bidderRequest.refererInfo.referer), diff --git a/test/spec/modules/admixerBidAdapter_spec.js b/test/spec/modules/admixerBidAdapter_spec.js index a0aaf8940bf..dce3d9a42c7 100644 --- a/test/spec/modules/admixerBidAdapter_spec.js +++ b/test/spec/modules/admixerBidAdapter_spec.js @@ -3,7 +3,7 @@ import {spec} from 'modules/admixerBidAdapter'; import {newBidder} from 'src/adapters/bidderFactory'; const BIDDER_CODE = 'admixer'; -const ENDPOINT_URL = '//inv-nets.admixer.net/prebid.1.0.aspx'; +const ENDPOINT_URL = 'https://inv-nets.admixer.net/prebid.1.0.aspx'; const ZONE_ID = '2eb6bd58-865c-47ce-af7f-a918108c3fd2'; describe('AdmixerAdapter', function () {