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

RTB House Bid Adapter: Process FLEDGE request/response #5

Merged
merged 1 commit into from
Nov 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions modules/rtbhouseBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,10 @@ function mapImpression(slot, bidderRequest) {
if (bidderRequest.fledgeEnabled) {
imp.ext = imp.ext || {};
imp.ext.ae = slot?.ortb2Imp?.ext?.ae
} else {
if (imp.ext?.ae) {
delete imp.ext.ae;
}
}
return imp;
}
Expand Down
79 changes: 79 additions & 0 deletions test/spec/modules/rtbhouseBidAdapter_spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { expect } from 'chai';
import { OPENRTB, spec } from 'modules/rtbhouseBidAdapter.js';
import { newBidder } from 'src/adapters/bidderFactory.js';
import { config } from 'src/config.js';

describe('RTBHouseAdapter', () => {
const adapter = newBidder(spec);
Expand Down Expand Up @@ -97,6 +98,10 @@ describe('RTBHouseAdapter', () => {
];
});

afterEach(function () {
config.resetConfig();
});

it('should build test param into the request', () => {
let builtTestRequest = spec.buildRequests(bidRequests, bidderRequest).data;
expect(JSON.parse(builtTestRequest).test).to.equal(1);
Expand Down Expand Up @@ -263,6 +268,45 @@ describe('RTBHouseAdapter', () => {
expect(data.source).to.not.have.property('ext');
});

context('FLEDGE', function() {
afterEach(function () {
config.resetConfig();
});

it('sends bid request to FLEDGE ENDPOINT via POST', function () {
let bidRequest = Object.assign([], bidRequests);
delete bidRequest[0].params.test;
config.setConfig({ fledgeConfig: true });
const request = spec.buildRequests(bidRequest, { ...bidderRequest, fledgeEnabled: true });
expect(request.url).to.equal('https://prebid-eu.creativecdn.com/bidder/prebidfledge/bids');
expect(request.method).to.equal('POST');
});

it('when FLEDGE is disabled, should not send imp.ext.ae', function () {
let bidRequest = Object.assign([], bidRequests);
delete bidRequest[0].params.test;
bidRequest[0].ortb2Imp = {
ext: { ae: 2 }
};
const request = spec.buildRequests(bidRequest, { ...bidderRequest, fledgeEnabled: false });
let data = JSON.parse(request.data);
if (data.imp[0].ext) {
expect(data.imp[0].ext).to.not.have.property('ae');
}
});

it('when FLEDGE is enabled, should send whatever is set in ortb2imp.ext.ae in all bid requests', function () {
let bidRequest = Object.assign([], bidRequests);
delete bidRequest[0].params.test;
bidRequest[0].ortb2Imp = {
ext: { ae: 2 }
};
const request = spec.buildRequests(bidRequest, { ...bidderRequest, fledgeEnabled: true });
let data = JSON.parse(request.data);
expect(data.imp[0].ext.ae).to.equal(2);
});
});

describe('native imp', () => {
function basicRequest(extension) {
return Object.assign({
Expand Down Expand Up @@ -460,6 +504,29 @@ describe('RTBHouseAdapter', () => {
'h': 250
}];

let fledgeResponse = {
'id': 'bid-identifier',
'ext': {
'igbid': [{
'impid': 'test-bid-id',
'igbuyer': [{
'igdomain': 'https://buyer-domain.com',
'buyersignal': {}
}]
}],
'sellerTimeout': 500,
'seller': 'https://seller-domain.com',
'decisionLogicUrl': 'https://seller-domain.com/decision-logic.js'
},
'bidid': 'bid-identifier',
'seatbid': [{
'bid': [{
'id': 'bid-response-id',
'impid': 'test-bid-id'
}]
}]
};

it('should get correct bid response', function () {
let expectedResponse = [
{
Expand Down Expand Up @@ -488,6 +555,18 @@ describe('RTBHouseAdapter', () => {
expect(result.length).to.equal(0);
});

context('when the response contains FLEDGE interest groups config', function () {
let bidderRequest;
let response = spec.interpretResponse({body: fledgeResponse}, {bidderRequest});

it('should return FLEDGE auction_configs alongside bids', function () {
expect(response).to.have.property('bids');
expect(response).to.have.property('fledgeAuctionConfigs');
expect(response.fledgeAuctionConfigs.length).to.equal(1);
expect(response.fledgeAuctionConfigs[0].bidId).to.equal('test-bid-id');
});
});

describe('native', () => {
const adm = {
native: {
Expand Down