Skip to content

Commit

Permalink
Ogury Bid Adapter: Handle TTD as a new source (prebid#7558)
Browse files Browse the repository at this point in the history
* add TTD URL in getUserSyncs method and related unit tests

* Refactor unit tests naming

* refactor unit test name
  • Loading branch information
AurelienMozoo authored and Chris Pabst committed Jan 10, 2022
1 parent 9bdfc0d commit dce3eac
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 19 deletions.
14 changes: 10 additions & 4 deletions modules/oguryBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,16 @@ function isBidRequestValid(bid) {
function getUserSyncs(syncOptions, serverResponses, gdprConsent, uspConsent) {
if (!syncOptions.pixelEnabled) return [];

return [{
type: 'image',
url: `${MS_COOKIE_SYNC_DOMAIN}/v1/init-sync/bid-switch?iab_string=${(gdprConsent && gdprConsent.consentString) || ''}&source=prebid`
}]
return [
{
type: 'image',
url: `${MS_COOKIE_SYNC_DOMAIN}/v1/init-sync/bid-switch?iab_string=${(gdprConsent && gdprConsent.consentString) || ''}&source=prebid`
},
{
type: 'image',
url: `${MS_COOKIE_SYNC_DOMAIN}/ttd/init-sync?iab_string=${(gdprConsent && gdprConsent.consentString) || ''}&source=prebid`
}
]
}

function buildRequests(validBidRequests, bidderRequest) {
Expand Down
46 changes: 31 additions & 15 deletions test/spec/modules/oguryBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,93 +119,109 @@ describe('OguryBidAdapter', function () {
};
});

it('should return syncs array with an element of type image', () => {
it('should return sync array with two elements of type image', () => {
const userSyncs = spec.getUserSyncs(syncOptions, [], gdprConsent);

expect(userSyncs).to.have.lengthOf(1);
expect(userSyncs).to.have.lengthOf(2);
expect(userSyncs[0].type).to.equal('image');
expect(userSyncs[0].url).to.contain('https://ms-cookie-sync.presage.io/v1/init-sync/bid-switch');
expect(userSyncs[1].type).to.equal('image');
expect(userSyncs[1].url).to.contain('https://ms-cookie-sync.presage.io/ttd/init-sync');
});

it('should set the source as query param', () => {
it('should set the same source as query param', () => {
const userSyncs = spec.getUserSyncs(syncOptions, [], gdprConsent);
expect(userSyncs[0].url).to.contain('source=prebid');
expect(userSyncs[1].url).to.contain('source=prebid');
});

it('should set the tcString as query param', () => {
const userSyncs = spec.getUserSyncs(syncOptions, [], gdprConsent);
expect(userSyncs[0].url).to.contain(`iab_string=${gdprConsent.consentString}`);
expect(userSyncs[1].url).to.contain(`iab_string=${gdprConsent.consentString}`);
});

it('should return an empty array when pixel is disable', () => {
syncOptions.pixelEnabled = false;
expect(spec.getUserSyncs(syncOptions, [], gdprConsent)).to.have.lengthOf(0);
});

it('should return syncs array with an element of type image when consentString is undefined', () => {
it('should return sync array with two elements of type image when consentString is undefined', () => {
gdprConsent = {
gdprApplies: true,
consentString: undefined
};

const userSyncs = spec.getUserSyncs(syncOptions, [], gdprConsent);
expect(userSyncs).to.have.lengthOf(1);
expect(userSyncs).to.have.lengthOf(2);
expect(userSyncs[0].type).to.equal('image');
expect(userSyncs[0].url).to.equal('https://ms-cookie-sync.presage.io/v1/init-sync/bid-switch?iab_string=&source=prebid')
expect(userSyncs[1].type).to.equal('image');
expect(userSyncs[1].url).to.equal('https://ms-cookie-sync.presage.io/ttd/init-sync?iab_string=&source=prebid')
});

it('should return syncs array with an element of type image when consentString is null', () => {
it('should return sync array with two elements of type image when consentString is null', () => {
gdprConsent = {
gdprApplies: true,
consentString: null
};

const userSyncs = spec.getUserSyncs(syncOptions, [], gdprConsent);
expect(userSyncs).to.have.lengthOf(1);
expect(userSyncs).to.have.lengthOf(2);
expect(userSyncs[0].type).to.equal('image');
expect(userSyncs[0].url).to.equal('https://ms-cookie-sync.presage.io/v1/init-sync/bid-switch?iab_string=&source=prebid')
expect(userSyncs[1].type).to.equal('image');
expect(userSyncs[1].url).to.equal('https://ms-cookie-sync.presage.io/ttd/init-sync?iab_string=&source=prebid')
});

it('should return syncs array with an element of type image when gdprConsent is undefined', () => {
it('should return sync array with two elements of type image when gdprConsent is undefined', () => {
gdprConsent = undefined;

const userSyncs = spec.getUserSyncs(syncOptions, [], gdprConsent);
expect(userSyncs).to.have.lengthOf(1);
expect(userSyncs).to.have.lengthOf(2);
expect(userSyncs[0].type).to.equal('image');
expect(userSyncs[0].url).to.equal('https://ms-cookie-sync.presage.io/v1/init-sync/bid-switch?iab_string=&source=prebid')
expect(userSyncs[1].type).to.equal('image');
expect(userSyncs[1].url).to.equal('https://ms-cookie-sync.presage.io/ttd/init-sync?iab_string=&source=prebid')
});

it('should return syncs array with an element of type image when gdprConsent is null', () => {
it('should return sync array with two elements of type image when gdprConsent is null', () => {
gdprConsent = null;

const userSyncs = spec.getUserSyncs(syncOptions, [], gdprConsent);
expect(userSyncs).to.have.lengthOf(1);
expect(userSyncs).to.have.lengthOf(2);
expect(userSyncs[0].type).to.equal('image');
expect(userSyncs[0].url).to.equal('https://ms-cookie-sync.presage.io/v1/init-sync/bid-switch?iab_string=&source=prebid')
expect(userSyncs[1].type).to.equal('image');
expect(userSyncs[1].url).to.equal('https://ms-cookie-sync.presage.io/ttd/init-sync?iab_string=&source=prebid')
});

it('should return syncs array with an element of type image when gdprConsent is null and gdprApplies is false', () => {
it('should return sync array with two elements of type image when gdprConsent is null and gdprApplies is false', () => {
gdprConsent = {
gdprApplies: false,
consentString: null
};

const userSyncs = spec.getUserSyncs(syncOptions, [], gdprConsent);
expect(userSyncs).to.have.lengthOf(1);
expect(userSyncs).to.have.lengthOf(2);
expect(userSyncs[0].type).to.equal('image');
expect(userSyncs[0].url).to.equal('https://ms-cookie-sync.presage.io/v1/init-sync/bid-switch?iab_string=&source=prebid')
expect(userSyncs[1].type).to.equal('image');
expect(userSyncs[1].url).to.equal('https://ms-cookie-sync.presage.io/ttd/init-sync?iab_string=&source=prebid')
});

it('should return syncs array with an element of type image when gdprConsent is empty string and gdprApplies is false', () => {
it('should return sync array with two elements of type image when gdprConsent is empty string and gdprApplies is false', () => {
gdprConsent = {
gdprApplies: false,
consentString: ''
};

const userSyncs = spec.getUserSyncs(syncOptions, [], gdprConsent);
expect(userSyncs).to.have.lengthOf(1);
expect(userSyncs).to.have.lengthOf(2);
expect(userSyncs[0].type).to.equal('image');
expect(userSyncs[0].url).to.equal('https://ms-cookie-sync.presage.io/v1/init-sync/bid-switch?iab_string=&source=prebid')
expect(userSyncs[1].type).to.equal('image');
expect(userSyncs[1].url).to.equal('https://ms-cookie-sync.presage.io/ttd/init-sync?iab_string=&source=prebid')
});
});

Expand Down

0 comments on commit dce3eac

Please sign in to comment.