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

merge master #12027

Merged
merged 3 commits into from
Jul 23, 2024
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
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ For any user facing change, submit a link to a PR on the docs repo at https://gi
}
```

Be sure to test the integration with your adserver using the [Hello World](/integrationExamples/gpt/hello_world.html) sample page. -->
Be sure to test the integration with your adserver using the [Hello World](https://github.com/prebid/Prebid.js/blob/master/integrationExamples/gpt/hello_world.html) sample page. -->


## Other information
Expand Down
20 changes: 4 additions & 16 deletions modules/mobianRtdProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,9 @@ function getBidRequestData(bidReqConfig, callback, config) {
return;
}

let mobianGarmRisk = response.garm_risk || 'unknown';
let mobianRisk = response.garm_risk || 'unknown';

if (mobianGarmRisk === 'unknown') {
const risks = ['garm_high_risk', 'garm_medium_risk', 'garm_low_risk', 'garm_no_risk'];
const riskLevels = ['high', 'medium', 'low', 'none'];

for (let i = 0; i < risks.length; i++) {
if (response[risks[i]]) {
mobianGarmRisk = riskLevels[i];
break;
}
}
}

const garmCategories = Object.keys(response)
const categories = Object.keys(response)
.filter(key => key.startsWith('garm_content_category_') && response[key])
.map(key => key.replace('garm_content_category_', ''));

Expand All @@ -67,8 +55,8 @@ function getBidRequestData(bidReqConfig, callback, config) {
.map(key => key.replace('emotion_', ''));

const risk = {
'mobianGarmRisk': mobianGarmRisk,
'garmContentCategories': garmCategories,
'risk': mobianRisk,
'contentCategories': categories,
'sentiment': sentiment,
'emotions': emotions
};
Expand Down
3 changes: 2 additions & 1 deletion modules/pubmaticBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,8 @@ function _createImpressionObject(bid, bidderRequest) {
},
bidfloorcur: bid.params.currency ? _parseSlotParam('currency', bid.params.currency) : DEFAULT_CURRENCY,
displaymanager: 'Prebid.js',
displaymanagerver: '$prebid.version$' // prebid version
displaymanagerver: '$prebid.version$', // prebid version
pmp: bid.ortb2Imp?.pmp || undefined
};

_addPMPDealsInImpression(impObj, bid);
Expand Down
110 changes: 31 additions & 79 deletions test/spec/modules/mobianRtdProvider_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,70 +23,63 @@ describe('Mobian RTD Submodule', function () {
ajaxStub.restore();
});

it('should return no_risk when server responds with garm_no_risk', function () {
it('should return risk level when server responds with garm_risk', function () {
ajaxStub = sinon.stub(ajax, 'ajaxBuilder').returns(function(url, callbacks) {
callbacks.success(JSON.stringify({
garm_no_risk: true,
garm_low_risk: false,
garm_medium_risk: false,
garm_high_risk: false
}));
});

return mobianBrandSafetySubmodule.getBidRequestData(bidReqConfig, {}, {}).then((risk) => {
expect(risk).to.have.property('mobianGarmRisk');
expect(risk['mobianGarmRisk']).to.equal('none');
expect(bidReqConfig.ortb2Fragments.global.site.ext.data.mobian).to.deep.equal(risk);
});
});

it('should return low_risk when server responds with garm_low_risk', function () {
ajaxStub = sinon.stub(ajax, 'ajaxBuilder').returns(function(url, callbacks) {
callbacks.success(JSON.stringify({
garm_no_risk: false,
garm_low_risk: true,
garm_medium_risk: false,
garm_high_risk: false
garm_risk: 'low',
sentiment_positive: true,
emotion_joy: true
}));
});

return mobianBrandSafetySubmodule.getBidRequestData(bidReqConfig, {}, {}).then((risk) => {
expect(risk).to.have.property('mobianGarmRisk');
expect(risk['mobianGarmRisk']).to.equal('low');
expect(risk).to.deep.equal({
risk: 'low',
contentCategories: [],
sentiment: 'positive',
emotions: ['joy']
});
expect(bidReqConfig.ortb2Fragments.global.site.ext.data.mobian).to.deep.equal(risk);
});
});

it('should return medium_risk when server responds with garm_medium_risk', function () {
it('should handle response with GARM content categories, sentiment, and emotions', function () {
ajaxStub = sinon.stub(ajax, 'ajaxBuilder').returns(function(url, callbacks) {
callbacks.success(JSON.stringify({
garm_no_risk: false,
garm_low_risk: false,
garm_medium_risk: true,
garm_high_risk: false
garm_risk: 'medium',
garm_content_category_arms: true,
garm_content_category_crime: true,
sentiment_negative: true,
emotion_anger: true,
emotion_fear: true
}));
});

return mobianBrandSafetySubmodule.getBidRequestData(bidReqConfig, {}, {}).then((risk) => {
expect(risk).to.have.property('mobianGarmRisk');
expect(risk['mobianGarmRisk']).to.equal('medium');
expect(risk).to.deep.equal({
risk: 'medium',
contentCategories: ['arms', 'crime'],
sentiment: 'negative',
emotions: ['anger', 'fear']
});
expect(bidReqConfig.ortb2Fragments.global.site.ext.data.mobian).to.deep.equal(risk);
});
});

it('should return high_risk when server responds with garm_high_risk', function () {
it('should return unknown risk when garm_risk is not present', function () {
ajaxStub = sinon.stub(ajax, 'ajaxBuilder').returns(function(url, callbacks) {
callbacks.success(JSON.stringify({
garm_no_risk: false,
garm_low_risk: false,
garm_medium_risk: false,
garm_high_risk: true
sentiment_neutral: true
}));
});

return mobianBrandSafetySubmodule.getBidRequestData(bidReqConfig, {}, {}).then((risk) => {
expect(risk).to.have.property('mobianGarmRisk');
expect(risk['mobianGarmRisk']).to.equal('high');
expect(risk).to.deep.equal({
risk: 'unknown',
contentCategories: [],
sentiment: 'neutral',
emotions: []
});
expect(bidReqConfig.ortb2Fragments.global.site.ext.data.mobian).to.deep.equal(risk);
});
});
Expand All @@ -103,47 +96,6 @@ describe('Mobian RTD Submodule', function () {
});
});

it('should handle response with direct garm_risk field', function () {
ajaxStub = sinon.stub(ajax, 'ajaxBuilder').returns(function(url, callbacks) {
callbacks.success(JSON.stringify({
garm_risk: 'low',
sentiment_positive: true,
emotion_joy: true
}));
});

return mobianBrandSafetySubmodule.getBidRequestData(bidReqConfig, {}, {}).then((risk) => {
expect(risk).to.deep.equal({
mobianGarmRisk: 'low',
garmContentCategories: [],
sentiment: 'positive',
emotions: ['joy']
});
});
});

it('should handle response with GARM content categories, sentiment, and emotions', function () {
ajaxStub = sinon.stub(ajax, 'ajaxBuilder').returns(function(url, callbacks) {
callbacks.success(JSON.stringify({
garm_risk: 'medium',
garm_content_category_arms: true,
garm_content_category_crime: true,
sentiment_negative: true,
emotion_anger: true,
emotion_fear: true
}));
});

return mobianBrandSafetySubmodule.getBidRequestData(bidReqConfig, {}, {}).then((risk) => {
expect(risk).to.deep.equal({
mobianGarmRisk: 'medium',
garmContentCategories: ['arms', 'crime'],
sentiment: 'negative',
emotions: ['anger', 'fear']
});
});
});

it('should handle error response', function () {
ajaxStub = sinon.stub(ajax, 'ajaxBuilder').returns(function(url, callbacks) {
callbacks.error();
Expand Down
18 changes: 18 additions & 0 deletions test/spec/modules/pubmaticBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2974,6 +2974,24 @@ describe('PubMatic adapter', function () {
expect(data.device).to.include.any.keys('connectiontype');
}
});

it('should send imp.pmp in request if pmp json is present in adUnit ortb2Imp object', function () {
let originalBidRequests = utils.deepClone(bidRequests);
originalBidRequests[0].ortb2Imp.pmp = {
'private_auction': 0,
'deals': [{ 'id': '5678' }]
}
const bidRequest = spec.buildRequests(originalBidRequests);
let data = JSON.parse(bidRequest.data);
expect(data.imp[0].pmp).to.exist.and.to.be.an('object');
})

it('should not send imp.pmp in request if pmp json is not present in adUnit ortb2Imp object', function () {
let originalBidRequests = utils.deepClone(bidRequests);
const bidRequest = spec.buildRequests(originalBidRequests);
let data = JSON.parse(bidRequest.data);
expect(data.imp[0].pmp).to.deep.equal(undefined);
})
});

it('Request params dctr check', function () {
Expand Down