Skip to content

Commit

Permalink
AIDEM Bid Adapter : fixed getConfig cleanup of consent management (#1…
Browse files Browse the repository at this point in the history
…1575)

* AIDEM Bid Adapter

* Added _spec.js

* update

* Fix Navigator in _spec.js

* Removed timeout handler.

* Added publisherId as required bidder params

* moved publisherId into site publisher object

* Added wpar to environment

* Added placementId parameter

* added unit tests for the wpar environment object

* PlacementId is now a required parameter
Added optional rateLimit parameter
Added publisherId, siteId, placementId in win notice payload
Added unit tests

* Revert to optional placementId parameter
Added missing semicolons

* Extended win notice

* Added arbitrary ext field to win notice

* Moved aidemBidAdapter implementation to comply with ortbConverter

* disabled video-specific tests

* Fixed getConfig cleanup of consent management (Issue #10658)

* Fixed getConfig cleanup of consent management (Issue #10658)

* Fixed getConfig cleanup of consent management (Issue #10658)

* Fixed getConfig cleanup of consent management (Issue #10658)

---------

Co-authored-by: Giovanni Sollazzo <[email protected]>
Co-authored-by: darkstar <[email protected]>
Co-authored-by: AndreaC <[email protected]>
  • Loading branch information
4 people committed May 28, 2024
1 parent 8620ae4 commit b44deb8
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 45 deletions.
18 changes: 9 additions & 9 deletions modules/aidemBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const converter = ortbConverter({
const request = buildRequest(imps, bidderRequest, context);
deepSetValue(request, 'at', 1);
setPrebidRequestEnvironment(request);
deepSetValue(request, 'regs', getRegs());
deepSetValue(request, 'regs', getRegs(bidderRequest));
deepSetValue(request, 'site.publisher.id', bidderRequest.bids[0].params.publisherId);
deepSetValue(request, 'site.id', bidderRequest.bids[0].params.siteId);
return request;
Expand Down Expand Up @@ -106,22 +106,22 @@ function recur(obj) {
return result;
}

function getRegs() {
function getRegs(bidderRequest) {
let regs = {};
const consentManagement = config.getConfig('consentManagement');
const euConsentManagement = bidderRequest.gdprConsent;
const usConsentManagement = bidderRequest.uspConsent;
const coppa = config.getConfig('coppa');
if (consentManagement && !!(consentManagement.gdpr)) {
deepSetValue(regs, 'gdpr_applies', !!consentManagement.gdpr);
if (euConsentManagement && euConsentManagement.consentString) {
deepSetValue(regs, 'gdpr_applies', !!euConsentManagement.consentString);
} else {
deepSetValue(regs, 'gdpr_applies', false);
}
if (consentManagement && deepAccess(consentManagement, 'usp.cmpApi') === 'static') {
deepSetValue(regs, 'usp_applies', !!deepAccess(consentManagement, 'usp'));
deepSetValue(regs, 'us_privacy', deepAccess(consentManagement, 'usp.consentData.getUSPData.uspString'));
if (usConsentManagement) {
deepSetValue(regs, 'usp_applies', true);
deepSetValue(regs, 'us_privacy', bidderRequest.uspConsent);
} else {
deepSetValue(regs, 'usp_applies', false);
}

if (isBoolean(coppa)) {
deepSetValue(regs, 'coppa_applies', !!coppa);
} else {
Expand Down
120 changes: 84 additions & 36 deletions test/spec/modules/aidemBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ const DEFAULT_VALID_BANNER_REQUESTS = [
},
params: {
siteId: '1',
placementId: '13144370'
placementId: '13144370',
},
src: 'client',
transactionId: 'db739693-9b4a-4669-9945-8eab938783cc'
Expand All @@ -193,7 +193,7 @@ const DEFAULT_VALID_VIDEO_REQUESTS = [
},
params: {
siteId: '1',
placementId: '13144370'
placementId: '13144370',
},
src: 'client',
transactionId: 'db739693-9b4a-4669-9945-8eab938783cc'
Expand All @@ -209,7 +209,50 @@ const VALID_BIDDER_REQUEST = {
params: {
placementId: '13144370',
siteId: '23434',
publisherId: '7689670753'
publisherId: '7689670753',
},
}
],
refererInfo: {
page: 'test-page',
domain: 'test-domain',
ref: 'test-referer'
},
}

const VALID_GDPR_BIDDER_REQUEST = {
auctionId: '19c97f22-5bd1-4b16-a128-80f75fb0a8a0',
bidderCode: 'aidem',
bidderRequestId: '1bbb7854dfa0d8',
bids: [
{
params: {
placementId: '13144370',
siteId: '23434',
publisherId: '7689670753',
},
}
],
refererInfo: {
page: 'test-page',
domain: 'test-domain',
ref: 'test-referer'
},
gdprConsent: {
consentString: 'test-gdpr-string'
}
}

const VALID_USP_BIDDER_REQUEST = {
auctionId: '19c97f22-5bd1-4b16-a128-80f75fb0a8a0',
bidderCode: 'aidem',
bidderRequestId: '1bbb7854dfa0d8',
bids: [
{
params: {
placementId: '13144370',
siteId: '23434',
publisherId: '7689670753',
},
}
],
Expand All @@ -218,6 +261,7 @@ const VALID_BIDDER_REQUEST = {
domain: 'test-domain',
ref: 'test-referer'
},
uspConsent: '1YYY'
}

const SERVER_RESPONSE_BANNER = {
Expand Down Expand Up @@ -601,47 +645,51 @@ describe('Aidem adapter', () => {
});

it(`should set gdpr to true`, function () {
config.setConfig({
consentManagement: {
gdpr: {
// any data here set gdpr to true
},
}
});
const { data } = spec.buildRequests(DEFAULT_VALID_BANNER_REQUESTS, VALID_BIDDER_REQUEST);
// config.setConfig({
// consentManagement: {
// gdpr: {
// consentData: {
// getTCData: {
// tcString: 'test-gdpr-string'
// }
// }
// },
// }
// });
const { data } = spec.buildRequests(DEFAULT_VALID_BANNER_REQUESTS, VALID_GDPR_BIDDER_REQUEST);
expect(data.regs.gdpr_applies).to.equal(true)
});

it(`should set usp_consent string`, function () {
config.setConfig({
consentManagement: {
usp: {
cmpApi: 'static',
consentData: {
getUSPData: {
uspString: '1YYY'
}
}
}
}
});
const { data } = spec.buildRequests(DEFAULT_VALID_BANNER_REQUESTS, VALID_BIDDER_REQUEST);
// config.setConfig({
// consentManagement: {
// usp: {
// cmpApi: 'static',
// consentData: {
// getUSPData: {
// uspString: '1YYY'
// }
// }
// }
// }
// });
const { data } = spec.buildRequests(DEFAULT_VALID_BANNER_REQUESTS, VALID_USP_BIDDER_REQUEST);
expect(data.regs.us_privacy).to.equal('1YYY')
});

it(`should not set usp_consent string`, function () {
config.setConfig({
consentManagement: {
usp: {
cmpApi: 'iab',
consentData: {
getUSPData: {
uspString: '1YYY'
}
}
}
}
});
// config.setConfig({
// consentManagement: {
// usp: {
// cmpApi: 'iab',
// consentData: {
// getUSPData: {
// uspString: '1YYY'
// }
// }
// }
// }
// });
const { data } = spec.buildRequests(DEFAULT_VALID_BANNER_REQUESTS, VALID_BIDDER_REQUEST);
expect(data.regs.us_privacy).to.undefined
});
Expand Down

0 comments on commit b44deb8

Please sign in to comment.