Skip to content

Commit

Permalink
fix handling of gdpr object (#3756)
Browse files Browse the repository at this point in the history
* initial orbidder version in personal github repo

* use adUnits from orbidder_example.html

* replace obsolete functions

* forgot to commit the test

* check if bidderRequest object is available

* try to fix weird safari/ie issue

* ebayK: add more params

* update orbidderBidAdapter.md

* use spec.<function> instead of this.<function> for consistency reasons

* add bidfloor parameter to params object

* fix gdpr object handling
  • Loading branch information
Hendrik Iseke authored and jaiminpanchal27 committed Apr 23, 2019
1 parent 253cbf4 commit c14f915
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 32 deletions.
8 changes: 4 additions & 4 deletions modules/orbidderBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ export const spec = {
}
};
spec.bidParams[bidRequest.bidId] = bidRequest.params;
if (bidRequest && bidRequest.gdprConsent) {
if (bidderRequest && bidderRequest.gdprConsent) {
ret.data.gdprConsent = {
consentString: bidRequest.gdprConsent.consentString,
consentRequired: (typeof bidRequest.gdprConsent.gdprApplies === 'boolean')
? bidRequest.gdprConsent.gdprApplies
consentString: bidderRequest.gdprConsent.consentString,
consentRequired: (typeof bidderRequest.gdprConsent.gdprApplies === 'boolean')
? bidderRequest.gdprConsent.gdprApplies
: true
};
}
Expand Down
57 changes: 29 additions & 28 deletions test/spec/modules/orbidderBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,17 @@ describe('orbidderBidAdapter', () => {
return JSON.parse(JSON.stringify(val));
};

const buildRequest = function (buildRequest) {
return spec.buildRequests(
[buildRequest],
{
refererInfo: {
referer: 'http://localhost:9876/'
}
})[0];
const buildRequest = (buildRequest, bidderRequest) => {
if (!Array.isArray(buildRequest)) {
buildRequest = [buildRequest];
}

return spec.buildRequests(buildRequest, {
...bidderRequest || {},
refererInfo: {
referer: 'http://localhost:9876/'
}
})[0];
};

describe('inherited functions', () => {
Expand Down Expand Up @@ -101,44 +104,42 @@ describe('orbidderBidAdapter', () => {
});

it('handles empty gdpr object', () => {
const bidRequest = deepClone(defaultBidRequest);
bidRequest.gdprConsent = {};

const request = buildRequest(bidRequest);
const request = buildRequest(defaultBidRequest, {
gdprConsent: {}
});
expect(request.data.gdprConsent.consentRequired).to.be.equal(true);
});

it('handles non-existent gdpr object', () => {
const bidRequest = deepClone(defaultBidRequest);
bidRequest.gdprConsent = null;

const request = buildRequest(bidRequest);
const request = buildRequest(defaultBidRequest, {
gdprConsent: null
});
expect(request.data.gdprConsent).to.be.undefined;
});

it('handles properly filled gdpr object where gdpr applies', () => {
const consentString = 'someWeirdString';
const bidRequest = deepClone(defaultBidRequest);
bidRequest.gdprConsent = {
gdprApplies: true,
consentString: 'someWeirdString'
};
const request = buildRequest(defaultBidRequest, {
gdprConsent: {
gdprApplies: true,
consentString: consentString
}
});

const request = buildRequest(bidRequest);
const gdprConsent = request.data.gdprConsent;
expect(gdprConsent.consentRequired).to.be.equal(true);
expect(gdprConsent.consentString).to.be.equal(consentString);
});

it('handles properly filled gdpr object where gdpr does not apply', () => {
const consentString = 'someWeirdString';
const bidRequest = deepClone(defaultBidRequest);
bidRequest.gdprConsent = {
gdprApplies: false,
consentString: 'someWeirdString'
};
const request = buildRequest(defaultBidRequest, {
gdprConsent: {
gdprApplies: false,
consentString: consentString
}
});

const request = buildRequest(bidRequest);
const gdprConsent = request.data.gdprConsent;
expect(gdprConsent.consentRequired).to.be.equal(false);
expect(gdprConsent.consentString).to.be.equal(consentString);
Expand Down

0 comments on commit c14f915

Please sign in to comment.