Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add usersync to adpone adapter #4245

Merged
merged 23 commits into from
Oct 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
9f98358
add user sync to adpone adapter
seergiioo6 Sep 23, 2019
f15e536
move adpone usersync to global variable
seergiioo6 Sep 23, 2019
35631ce
added withcredentials to http request
seergiioo6 Sep 23, 2019
5b8da8c
fix http request options
seergiioo6 Sep 23, 2019
cf278b0
fix http request options
seergiioo6 Sep 23, 2019
e422ba7
add withCredentials: true
seergiioo6 Sep 23, 2019
a0b95d0
add withCredentials: true
seergiioo6 Sep 23, 2019
1c76a52
added test coverage to usersync
seergiioo6 Sep 25, 2019
f63105b
update sync function
seergiioo6 Sep 25, 2019
196a41f
add test coverage
seergiioo6 Sep 25, 2019
0f7ca06
adpone adapter
seergiioo6 Sep 30, 2019
65c3a2e
adpone adapter
seergiioo6 Sep 30, 2019
38cbc87
Merge branch 'master' of https://github.com/prebid/Prebid.js
seergiioo6 Sep 30, 2019
831205f
package lock
seergiioo6 Sep 30, 2019
bc185ce
Merge branch 'master' of https://github.com/prebid/Prebid.js
seergiioo6 Oct 7, 2019
0da5146
add more testing
seergiioo6 Oct 7, 2019
df562d0
add more testing
seergiioo6 Oct 8, 2019
d45b2b6
Merge branch 'master' of https://github.com/prebid/Prebid.js
seergiioo6 Oct 8, 2019
c813899
testing for onBidWon fucntion
seergiioo6 Oct 8, 2019
4951302
Merge branch 'master' of https://github.com/prebid/Prebid.js
seergiioo6 Oct 8, 2019
c9fbd4c
Merge branch 'master' of https://github.com/prebid/Prebid.js
seergiioo6 Oct 9, 2019
8bacc78
test onbidwon function
seergiioo6 Oct 9, 2019
55414c1
trigger build
seergiioo6 Oct 9, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 26 additions & 3 deletions modules/adponeBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,29 @@ import {registerBidder} from '../src/adapters/bidderFactory';

const ADPONE_CODE = 'adpone';
const ADPONE_ENDPOINT = 'https://rtb.adpone.com/bid-request';
const ADPONE_SYNC_ENDPOINT = 'https://eu-ads.adpone.com';
const ADPONE_REQUEST_METHOD = 'POST';
const ADPONE_CURRENCY = 'EUR';

function _createSync() {
return {
type: 'iframe',
url: ADPONE_SYNC_ENDPOINT
}
}

function getUserSyncs(syncOptions) {
return (syncOptions && syncOptions.iframeEnabled) ? _createSync() : ([]);
}

export const spec = {
code: ADPONE_CODE,
supportedMediaTypes: [BANNER],

getUserSyncs,

isBidRequestValid: bid => {
return !!bid.params.placementId && !!bid.bidId;
return !!bid.params.placementId && !!bid.bidId && bid.bidder === 'adpone'
},

buildRequests: bidRequests => {
Expand All @@ -30,7 +44,16 @@ export const spec = {
}))
};

return { method: ADPONE_REQUEST_METHOD, url, data }
const options = {
withCredentials: true
};

return {
method: ADPONE_REQUEST_METHOD,
url,
data,
options,
};
});
},

Expand Down Expand Up @@ -66,7 +89,7 @@ export const spec = {
const encodedBuf = window.btoa(bidString);
const img = new Image(1, 1);
img.src = `https://rtb.adpone.com/prebid/analytics?q=${encodedBuf}`;
}
},

};

Expand Down
121 changes: 121 additions & 0 deletions test/spec/modules/adponeBidAdapter_spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { expect } from 'chai';
import { spec } from 'modules/adponeBidAdapter';
import {newBidder} from '../../../src/adapters/bidderFactory';

const EMPTY_ARRAY = [];
describe('adponeBidAdapter', function () {
let bid = {
bidder: 'adpone',
Expand All @@ -14,6 +16,48 @@ describe('adponeBidAdapter', function () {
}
};

describe('build requests', () => {
it('sends bid request to ENDPOINT via POST', function () {
const request = spec.buildRequests([
{
bidder: 'adpone',
adUnitCode: 'adunit-code',
sizes: [[300, 250]],
bidId: '30b31c1838de1e',
bidderRequestId: '22edbae2733bf6',
auctionId: '1d1a030790a475',
params: {
placementId: '1',
}
}
]);
expect(request[0].method).to.equal('POST');
});
it('sends bid request to adpone endpoint', function () {
const request = spec.buildRequests([
{
bidder: 'adpone',
adUnitCode: 'adunit-code',
sizes: [[300, 250]],
bidId: '30b31c1838de1e',
bidderRequestId: '22edbae2733bf6',
auctionId: '1d1a030790a475',
params: {
placementId: '1',
}
}
]);
expect(request[0].url).to.equal('https://rtb.adpone.com/bid-request?pid=1');
});
});

describe('inherited functions', () => {
const adapter = newBidder(spec);
it('exists and is a function', () => {
expect(adapter.callBids).to.exist.and.to.be.a('function');
});
});

describe('isBidRequestValid', function () {
it('should return true when necessary information is found', function () {
expect(spec.isBidRequestValid(bid)).to.be.true;
Expand All @@ -34,6 +78,36 @@ describe('adponeBidAdapter', function () {

bid.adUnitCode = 'adunit-code';
});

it('returns false when bidder not set to "adpone"', function() {
const invalidBid = {
bidder: 'enopda',
adUnitCode: 'adunit-code',
sizes: [[300, 250]],
bidId: '30b31c1838de1e',
bidderRequestId: '22edbae2733bf6',
auctionId: '1d1a030790a475',
params: {
placementId: '1',
}
};
expect(spec.isBidRequestValid(invalidBid)).to.be.false;
});

it('returns false when placementId is not set in params', function() {
const invalidBid = {
bidder: 'adpone',
adUnitCode: 'adunit-code',
sizes: [[300, 250]],
bidId: '30b31c1838de1e',
bidderRequestId: '22edbae2733bf6',
auctionId: '1d1a030790a475',
params: {
}
};

expect(spec.isBidRequestValid(invalidBid)).to.be.false;
});
});
});

Expand Down Expand Up @@ -73,6 +147,19 @@ describe('interpretResponse', function () {
};
});

it('validate_response_params', function() {
const newResponse = spec.interpretResponse(serverResponse, bidRequest);
expect(newResponse[0].id).to.be.equal('613673EF-A07C-4486-8EE9-3FC71A7DC73D');
expect(newResponse[0].requestId).to.be.equal('1234');
expect(newResponse[0].cpm).to.be.equal(1);
expect(newResponse[0].width).to.be.equal(300);
expect(newResponse[0].height).to.be.equal(250);
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('<html><a href="http://www.adpone.com" target="_blank"><img src ="https://placehold.it/300x250" /></a></html>');
});

it('should correctly reorder the server response', function () {
const newResponse = spec.interpretResponse(serverResponse, bidRequest);
expect(newResponse.length).to.be.equal(1);
Expand All @@ -99,4 +186,38 @@ describe('interpretResponse', function () {
response = spec.interpretResponse(serverResponse, bidRequest);
expect(response).to.deep.equal([])
});
it('should add responses if the cpm is valid', function () {
serverResponse.body.seatbid[0].bid[0].price = 0.5;
let response = spec.interpretResponse(serverResponse, bidRequest);
expect(response).to.not.deep.equal([]);
});
});

describe('getUserSyncs', function () {
it('Verifies that getUserSyncs is a function', function () {
expect((typeof (spec.getUserSyncs)).should.equals('function'));
});
it('Verifies getUserSyncs returns expected result', function () {
expect((typeof (spec.getUserSyncs)).should.equals('function'));
expect(spec.getUserSyncs({iframeEnabled: true})).to.deep.equal({
type: 'iframe',
url: 'https://eu-ads.adpone.com'
});
});
it('Verifies that iframeEnabled: false returns an empty array', function () {
expect(spec.getUserSyncs({iframeEnabled: false})).to.deep.equal(EMPTY_ARRAY);
});
it('Verifies that iframeEnabled: null returns an empty array', function () {
expect(spec.getUserSyncs(null)).to.deep.equal(EMPTY_ARRAY);
});
});

describe('test onBidWon function', function () {
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')
});
});