Skip to content

Commit

Permalink
Fix bug Not Passing GPP Consent Object as a string (#10530)
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinGumGum committed Sep 26, 2023
1 parent ac37f9b commit 0c7b14d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 18 deletions.
12 changes: 4 additions & 8 deletions modules/gumgumBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -383,15 +383,11 @@ function buildRequests(validBidRequests, bidderRequest) {
data.uspConsent = uspConsent;
}
if (gppConsent) {
data.gppConsent = {
gppString: bidderRequest.gppConsent.gppString,
gpp_sid: bidderRequest.gppConsent.applicableSections
}
data.gppString = bidderRequest.gppConsent.gppString ? bidderRequest.gppConsent.gppString : ''
data.gppSid = Array.isArray(bidderRequest.gppConsent.applicableSections) ? bidderRequest.gppConsent.applicableSections.join(',') : ''
} else if (!gppConsent && bidderRequest?.ortb2?.regs?.gpp) {
data.gppConsent = {
gppString: bidderRequest.ortb2.regs.gpp,
gpp_sid: bidderRequest.ortb2.regs.gpp_sid
};
data.gppString = bidderRequest.ortb2.regs.gpp
data.gppSid = Array.isArray(bidderRequest.ortb2.regs.gpp_sid) ? bidderRequest.ortb2.regs.gpp_sid.join(',') : ''
}
if (coppa) {
data.coppa = coppa;
Expand Down
20 changes: 10 additions & 10 deletions test/spec/modules/gumgumBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ describe('gumgumAdapter', function () {
let sizesArray = [[300, 250], [300, 600]];
let bidRequests = [
{
gppString: 'DBACNYA~CPXxRfAPXxRfAAfKABENB-CgAAAAAAAAAAYgAAAAAAAA~1YNN',
gppSid: [7],
bidder: 'gumgum',
params: {
inSlot: 9
Expand Down Expand Up @@ -503,10 +505,9 @@ describe('gumgumAdapter', function () {
const gppConsent = { gppString: 'DBACNYA~CPXxRfAPXxRfAAfKABENB-CgAAAAAAAAAAYgAAAAAAAA~1YNN', applicableSections: [7] }
const fakeBidRequest = { gppConsent: gppConsent };
const bidRequest = spec.buildRequests(bidRequests, fakeBidRequest)[0];
expect(bidRequest.data.gppConsent).to.exist;
expect(bidRequest.data.gppConsent.gppString).to.equal(gppConsent.gppString);
expect(bidRequest.data.gppConsent.gpp_sid).to.equal(gppConsent.applicableSections);
expect(bidRequest.data.gppConsent.gppString).to.eq('DBACNYA~CPXxRfAPXxRfAAfKABENB-CgAAAAAAAAAAYgAAAAAAAA~1YNN');
expect(bidRequest.data.gppString).to.equal(gppConsent.gppString);
expect(bidRequest.data.gppSid).to.equal(gppConsent.applicableSections.join(','));
expect(bidRequest.data.gppString).to.eq('DBACNYA~CPXxRfAPXxRfAAfKABENB-CgAAAAAAAAAAYgAAAAAAAA~1YNN');
});
it('should handle ortb2 parameters', function () {
const ortb2 = {
Expand All @@ -517,15 +518,14 @@ describe('gumgumAdapter', function () {
}
const fakeBidRequest = { gppConsent: ortb2 };
const bidRequest = spec.buildRequests(bidRequests, fakeBidRequest)[0];
expect(bidRequest.data.gppConsent.gppString).to.eq(fakeBidRequest[0])
expect(bidRequest.data.gpp).to.eq(fakeBidRequest[0])
});
it('should handle gppConsent is present but values are undefined case', function () {
const gppConsent = { gppString: undefined, applicableSections: undefined }
const fakeBidRequest = { gppConsent: gppConsent };
const bidRequest = spec.buildRequests(bidRequests, fakeBidRequest)[0];
expect(bidRequest.data.gppConsent).to.exist;
expect(bidRequest.data.gppConsent.gppString).to.equal(undefined);
expect(bidRequest.data.gppConsent.gpp_sid).to.equal(undefined);
expect(bidRequest.data.gppString).to.equal('');
expect(bidRequest.data.gppSid).to.equal('');
});
it('should handle ortb2 undefined parameters', function () {
const ortb2 = {
Expand All @@ -536,8 +536,8 @@ describe('gumgumAdapter', function () {
}
const fakeBidRequest = { gppConsent: ortb2 };
const bidRequest = spec.buildRequests(bidRequests, fakeBidRequest)[0];
expect(bidRequest.data.gppConsent.gppString).to.eq(undefined)
expect(bidRequest.data.gppConsent.gpp_sid).to.eq(undefined)
expect(bidRequest.data.gppString).to.eq('')
expect(bidRequest.data.gppSid).to.eq('')
});
it('should not set coppa parameter if coppa config is set to false', function () {
config.setConfig({
Expand Down

0 comments on commit 0c7b14d

Please sign in to comment.