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

Change site getting method #4

Merged
merged 1 commit into from
Oct 30, 2018
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
7 changes: 4 additions & 3 deletions modules/rtbhouseBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export const spec = {
const request = {
id: validBidRequests[0].auctionId,
imp: validBidRequests.map(slot => mapImpression(slot)),
site: mapSite(validBidRequests),
site: mapSite(validBidRequests, bidderRequest),
cur: DEFAULT_CURRENCY_ARR,
test: validBidRequests[0].params.test || 0,
source: {
Expand Down Expand Up @@ -121,17 +121,18 @@ function mapBanner(slot) {

/**
* @param {object} slot Ad Unit Params by Prebid
* @param {object} bidderRequest by Prebid
* @returns {object} Site by OpenRTB 2.5 §3.2.13
*/
function mapSite(slot) {
function mapSite(slot, bidderRequest) {
const pubId = slot && slot.length > 0
? slot[0].params.publisherId
: 'unknown';
return {
publisher: {
id: pubId.toString(),
},
page: utils.getTopWindowUrl(),
page: bidderRequest.refererInfo.referer,
name: utils.getOrigin()
}
}
Expand Down
47 changes: 33 additions & 14 deletions test/spec/modules/rtbhouseBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,22 @@ describe('RTBHouseAdapter', () => {
'transactionId': 'example-transaction-id',
}
];
const bidderRequest = {
'refererInfo': {
'numIframes': 0,
'reachedTop': true,
'referer': 'http://example.com',
'stack': ['http://example.com']
}
};

it('should build test param into the request', () => {
let builtTestRequest = spec.buildRequests(bidRequests).data;
let builtTestRequest = spec.buildRequests(bidRequests, bidderRequest).data;
expect(JSON.parse(builtTestRequest).test).to.equal(1);
});

it('should build valid OpenRTB banner object', () => {
const request = JSON.parse(spec.buildRequests((bidRequests)).data);
const request = JSON.parse(spec.buildRequests(bidRequests, bidderRequest).data);
const imp = request.imp[0];
expect(imp.banner).to.deep.equal({
w: 300,
Expand All @@ -81,15 +89,15 @@ describe('RTBHouseAdapter', () => {
it('sends bid request to ENDPOINT via POST', function () {
let bidRequest = Object.assign([], bidRequests);
delete bidRequest[0].params.test;
const request = spec.buildRequests(bidRequest);
const request = spec.buildRequests(bidRequest, bidderRequest);
expect(request.url).to.equal('https://prebid-eu.creativecdn.com/bidder/prebid/bids');
expect(request.method).to.equal('POST');
});

it('should not populate GDPR if for non-EEA users', function () {
let bidRequest = Object.assign([], bidRequests);
delete bidRequest[0].params.test;
const request = spec.buildRequests(bidRequest);
const request = spec.buildRequests(bidRequest, bidderRequest);
let data = JSON.parse(request.data);
expect(data).to.not.have.property('regs');
expect(data).to.not.have.property('user');
Expand All @@ -98,12 +106,15 @@ describe('RTBHouseAdapter', () => {
it('should populate GDPR and consent string if available for EEA users', function () {
let bidRequest = Object.assign([], bidRequests);
delete bidRequest[0].params.test;
const request = spec.buildRequests(bidRequest, {
gdprConsent: {
gdprApplies: true,
consentString: 'BOJ8RZsOJ8RZsABAB8AAAAAZ+A=='
}
});
const request = spec.buildRequests(
bidRequest,
Object.assign({}, bidderRequest, {
gdprConsent: {
gdprApplies: true,
consentString: 'BOJ8RZsOJ8RZsABAB8AAAAAZ+A=='
}
})
);
let data = JSON.parse(request.data);
expect(data.regs.ext.gdpr).to.equal(1);
expect(data.user.ext.consent).to.equal('BOJ8RZsOJ8RZsABAB8AAAAAZ-A');
Expand All @@ -112,22 +123,29 @@ describe('RTBHouseAdapter', () => {
it('should populate GDPR and empty consent string if available for EEA users without consent string but with consent', function () {
let bidRequest = Object.assign([], bidRequests);
delete bidRequest[0].params.test;
const request = spec.buildRequests(bidRequest, {gdprConsent: {gdprApplies: true}});
const request = spec.buildRequests(
bidRequest,
Object.assign({}, bidderRequest, {
gdprConsent: {
gdprApplies: true
}
})
);
let data = JSON.parse(request.data);
expect(data.regs.ext.gdpr).to.equal(1);
expect(data.user.ext.consent).to.equal('');
});

it('should include banner imp in request', () => {
const bidRequest = Object.assign([], bidRequests);
const request = spec.buildRequests(bidRequest);
const request = spec.buildRequests(bidRequest, bidderRequest);
const data = JSON.parse(request.data);
expect(data.imp[0].banner).to.not.be.empty;
});

it('should include source.tid in request', () => {
const bidRequest = Object.assign([], bidRequests);
const request = spec.buildRequests(bidRequest);
const request = spec.buildRequests(bidRequest, bidderRequest);
const data = JSON.parse(request.data);
expect(data.source.tid).to.equal('example-transaction-id');
});
Expand All @@ -147,7 +165,8 @@ describe('RTBHouseAdapter', () => {
}

function buildImp(request) {
return JSON.parse(spec.buildRequests([request]).data).imp[0];
const resultRequest = spec.buildRequests([request], bidderRequest);
return JSON.parse(resultRequest.data).imp[0];
}

it('should extract native params when single mediaType', () => {
Expand Down