Skip to content

Commit

Permalink
AdagioBidAdapter: GPP: remove useless logic
Browse files Browse the repository at this point in the history
  • Loading branch information
osazos committed Jul 12, 2024
1 parent 85e6ef1 commit f5d0a09
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 75 deletions.
19 changes: 4 additions & 15 deletions modules/adagioBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ import {
import { getRefererInfo, parseDomain } from '../src/refererDetection.js';
import { OUTSTREAM } from '../src/video.js';
import { Renderer } from '../src/Renderer.js';
import { _ADAGIO } from '../libraries/adagioUtils/adagioUtils.js';
import { config } from '../src/config.js';
import { convertOrtbRequestToProprietaryNative } from '../src/native.js';
import { find } from '../src/polyfill.js';
import { getGptSlotInfoForAdUnitCode } from '../libraries/gptUtils/gptUtils.js';
import { _ADAGIO } from '../libraries/adagioUtils/adagioUtils.js';
import { registerBidder } from '../src/adapters/bidderFactory.js';
import { userSync } from '../src/userSync.js';

Expand Down Expand Up @@ -176,17 +176,6 @@ function _getUspConsent(bidderRequest) {
return (deepAccess(bidderRequest, 'uspConsent')) ? { uspConsent: bidderRequest.uspConsent } : false;
}

function _getGppConsent(bidderRequest) {
let gpp = deepAccess(bidderRequest, 'gppConsent.gppString')
let gppSid = deepAccess(bidderRequest, 'gppConsent.applicableSections')

if (!gpp || !gppSid) {
gpp = deepAccess(bidderRequest, 'ortb2.regs.gpp', '')
gppSid = deepAccess(bidderRequest, 'ortb2.regs.gpp_sid', [])
}
return { gpp, gppSid }
}

function _getSchain(bidRequest) {
return deepAccess(bidRequest, 'schain');
}
Expand Down Expand Up @@ -559,7 +548,7 @@ export const spec = {
const gdprConsent = _getGdprConsent(bidderRequest) || {};
const uspConsent = _getUspConsent(bidderRequest) || {};
const coppa = _getCoppa();
const gppConsent = _getGppConsent(bidderRequest)
const { gpp, gpp_sid: gppSid } = deepAccess(bidderRequest, 'ortb2.regs', {});
const schain = _getSchain(validBidRequests[0]);
const eids = _getEids(validBidRequests[0]) || [];
const syncEnabled = deepAccess(config.getConfig('userSync'), 'syncEnabled')
Expand Down Expand Up @@ -747,8 +736,8 @@ export const spec = {
gdpr: gdprConsent,
coppa: coppa,
ccpa: uspConsent,
gpp: gppConsent.gpp,
gppSid: gppConsent.gppSid,
gpp: gpp || '',
gppSid: gppSid || [],
dsa: dsa // populated if exists
},
schain: schain,
Expand Down
67 changes: 7 additions & 60 deletions test/spec/modules/adagioBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -801,77 +801,24 @@ describe('Adagio bid adapter', () => {
describe('with GPP', function() {
const bid01 = new BidRequestBuilder().withParams().build();

const regsGpp = 'regs_gpp_consent_string';
const regsApplicableSections = [2];
const gpp = 'gpp_consent_string';
const gppSid = [1];

const ortb2Gpp = 'ortb2_gpp_consent_string';
const ortb2GppSid = [1];

context('When GPP in regs module', function() {
it('send gpp and gppSid to the server', function() {
const bidderRequest = new BidderRequestBuilder({
gppConsent: {
gppString: regsGpp,
applicableSections: regsApplicableSections,
}
}).build();

const requests = spec.buildRequests([bid01], bidderRequest);

expect(requests[0].data.regs.gpp).to.equal(regsGpp);
expect(requests[0].data.regs.gppSid).to.equal(regsApplicableSections);
});
});

context('When GPP partially defined in regs module', function() {
it('send gpp and gppSid coming from ortb2 to the server', function() {
const bidderRequest = new BidderRequestBuilder({
gppConsent: {
gppString: regsGpp,
},
ortb2: {
regs: {
gpp: ortb2Gpp,
gpp_sid: ortb2GppSid,
}
}
}).build();

const requests = spec.buildRequests([bid01], bidderRequest);

expect(requests[0].data.regs.gpp).to.equal(ortb2Gpp);
expect(requests[0].data.regs.gppSid).to.equal(ortb2GppSid);
});

it('send empty gpp and gppSid if no ortb2 fields to the server', function() {
const bidderRequest = new BidderRequestBuilder({
gppConsent: {
gppString: regsGpp,
}
}).build();

const requests = spec.buildRequests([bid01], bidderRequest);

expect(requests[0].data.regs.gpp).to.equal('');
expect(requests[0].data.regs.gppSid).to.be.empty;
});
});

context('When GPP defined in ortb2 module', function() {
context('When GPP is defined', function() {
it('send gpp and gppSid coming from ortb2 to the server', function() {
const bidderRequest = new BidderRequestBuilder({
ortb2: {
regs: {
gpp: ortb2Gpp,
gpp_sid: ortb2GppSid,
gpp,
gpp_sid: gppSid,
}
}
}).build();

const requests = spec.buildRequests([bid01], bidderRequest);

expect(requests[0].data.regs.gpp).to.equal(ortb2Gpp);
expect(requests[0].data.regs.gppSid).to.equal(ortb2GppSid);
expect(requests[0].data.regs.gpp).to.equal(gpp);
expect(requests[0].data.regs.gppSid).to.equal(gppSid);
});
});

Expand Down

0 comments on commit f5d0a09

Please sign in to comment.